mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: linux-kernel@vger.kernel.org, ardb@kernel.org, arnd@arndb.de,
	peterz@infradead.org, will@kernel.org
Subject: Re: [PATCH v2] atomics: fix atomic64_{read_acquire,set_release} fallbacks
Date: Fri, 4 Feb 2022 11:16:02 +0000	[thread overview]
Message-ID: <Yf0K8oxan1NvjKmE@FVFF77S0Q05N> (raw)
In-Reply-To: <YfxxSX3v6nSJ0tKo@tardis>

On Fri, Feb 04, 2022 at 08:20:25AM +0800, Boqun Feng wrote:
> On Thu, Feb 03, 2022 at 04:12:43PM +0000, Mark Rutland wrote:
> > diff --git a/include/linux/atomic/atomic-arch-fallback.h b/include/linux/atomic/atomic-arch-fallback.h
> > index a3dba31df01e..6db58d180866 100644
> > --- a/include/linux/atomic/atomic-arch-fallback.h
> > +++ b/include/linux/atomic/atomic-arch-fallback.h
> > @@ -151,7 +151,16 @@
> >  static __always_inline int
> >  arch_atomic_read_acquire(const atomic_t *v)
> >  {
> > -	return smp_load_acquire(&(v)->counter);
> > +	int ret;
> > +
> > +	if (__native_word(atomic_t)) {
> > +		ret = smp_load_acquire(&(v)->counter);
> > +	} else {
> > +		ret = arch_atomic_read(v);
> > +		__atomic_acquire_fence();
> > +	}
> > +
> > +	return ret;
> >  }
> >  #define arch_atomic_read_acquire arch_atomic_read_acquire
> >  #endif
> > @@ -160,7 +169,12 @@ arch_atomic_read_acquire(const atomic_t *v)
> >  static __always_inline void
> >  arch_atomic_set_release(atomic_t *v, int i)
> >  {
> > -	smp_store_release(&(v)->counter, i);
> > +	if (__native_word(atomic_t)) {
> > +		smp_store_release(&(v)->counter, i);
> > +	} else {
> > +		__atomic_release_fence();
> > +		arch_atomic_set(v, i);
> > +	}
> >  }
> 
> The changes for atomic_t are not necessary, right? They are correct but
> "side effects" because of the change in scripts.

Correct -- those aren't necessary, but aren't harmful, and it's simpler to have
than than it is to special-case the scripts.

> If so, it's better to mention this somewhere.

Sure; how about I add the following to the commit message:

| Since the fallback templates are used to generate the atomic64_*() and
| atomic_*() operations, the __native_word() check is added to both. For
| the atomic_*() operations, which are always 32-bit, the __native_word()
| check is redundant but not harmful, as it is always true.

... ?

Thanks,
Mark.

  reply	other threads:[~2022-02-04 11:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 16:12 Mark Rutland
2022-02-03 16:18 ` Ard Biesheuvel
2022-02-04  0:20 ` Boqun Feng
2022-02-04 11:16   ` Mark Rutland [this message]
2022-02-04 15:45     ` Boqun Feng
2022-02-06 14:06     ` Peter Zijlstra
2022-11-04 23:05 ` Thorsten Glaser
2022-11-07 10:37   ` Mark Rutland
2022-11-07 11:14     ` Thorsten Glaser

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=Yf0K8oxan1NvjKmE@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=will@kernel.org \
    /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®