On Sat, Dec 05, 2026 at 03:33:04PM +0800, Jack Wang wrote:
> q->idleslope and q->sendslope are s64 written locklessly in > cbs_change() and read concurrently in cbs_dequeue_soft() and cbs_dump(). > On 32-bit kernels, plain 64-bit accesses can tear, especially for > negative sendslope values. > > Convert both fields to atomic64_t, matching q->port_rate.
...
> if (q->credits < 0) { > - credits = timediff_to_credits(now - q->last, q->idleslope); > + s64 idleslope = atomic64_read(&q->idleslope); > + > + credits = timediff_to_credits(now - q->last, idleslope); > > credits = q->credits + credits;
So, what's wrong with combining these two now? credits = q->credits + timediff_to_credits(now - q->last, idleslope); ...
> - credits = credits_from_len(len, q->sendslope, > + credits = credits_from_len(len, atomic64_read(&q->sendslope), > atomic64_read(&q->port_rate));
And how does this help? Any value read by atomic APIs immediately becomes outdated (yes, by luck if not synchronised, it may keep the same value for a while).
-- With Best Regards, Andy Shevchenko