mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Jack Wang <163wangjack@gmail.com>
Cc: andriy.shevchenko@linux.intel.com, vinicius.gomes@intel.com,
	jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, victor@mojatatu.com,
	mhm.dawod@gmail.com, esalomatkina@ispras.ru,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v5 2/2] net/sched: cbs: use atomic64_t for idleslope and sendslope
Date: Sun, 6 Dec 2026 13:33:53 +0000	[thread overview]
Message-ID: <20261206133353.7315f255@pumpkin> (raw)
In-Reply-To: <B815AF4F-9212-46D2-914C-E5A3392EA7AF@gmail.com>

On Sat, 5 Dec 2026 21:08:39 +0800
Jack Wang <163wangjack@gmail.com> wrote:

> On Sat, 5 Dec 2026 13:22:22 +0200, Andy Shevchenko wrote:
> 
> > So, what's wrong with combining these two now?
> > 
> > 		credits = q->credits + timediff_to_credits(now - q->last, idleslope);
> > 
> > ...  
> 
> Agree with that. 
> 
> >   
> >> -	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).  
> 
> This change is not meant for synchronization. The intent is to
> prevent 64-bit load/store tearing on 32-bit architectures during
> concurrent updates from cbs_change().

Does that actually work?
32bit x86 would have to use cmpxchg to do a 64bit read in a single instruction.
IIRC it mostly (look at READ_ONCE() just does two reads and hopes...

	David

> 
> Thanks,
> JW
> 


  reply	other threads:[~2026-12-06 13:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  7:33 [PATCH net v5 0/2] net/sched: cbs: fix 32-bit rate conversions and slope tearing Jack Wang
2026-12-05  7:33 ` [PATCH net v5 1/2] net/sched: cbs: use signed 64-bit math for BYTES_PER_KBIT conversions Jack Wang
2026-12-05 11:19   ` Andy Shevchenko
2026-12-05 14:00     ` Jack Wang
2026-12-06 13:28     ` David Laight
2026-12-05  7:33 ` [PATCH net v5 2/2] net/sched: cbs: use atomic64_t for idleslope and sendslope Jack Wang
2026-12-05 11:22   ` Andy Shevchenko
2026-12-05 13:08     ` Jack Wang
2026-12-06 13:33       ` David Laight [this message]
2026-12-05  7:38 ` [PATCH net v5 0/2] net/sched: cbs: fix 32-bit rate conversions and slope tearing netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261206133353.7315f255@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=163wangjack@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=esalomatkina@ispras.ru \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhm.dawod@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=victor@mojatatu.com \
    --cc=vinicius.gomes@intel.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®