linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
	Vineet Gupta <vgupta@kernel.org>,
	Andi Shyti <andi.shyti@linux.intel.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Palmer Dabbelt <palmer@rivosinc.com>,
	linux-snps-arc@lists.infradead.org
Subject: Re: [PATCH RFC cmpxchg 3/8] ARC: Emulate one-byte and two-byte cmpxchg
Date: Thu, 4 Apr 2024 07:44:47 -0700	[thread overview]
Message-ID: <b84884eb-e23b-480d-827e-06f1188ece9e@paulmck-laptop> (raw)
In-Reply-To: <f9b3c536-887a-4a33-bd03-70e60c5aa517@app.fastmail.com>

On Thu, Apr 04, 2024 at 01:57:32PM +0200, Arnd Bergmann wrote:
> On Tue, Apr 2, 2024, at 19:06, Paul E. McKenney wrote:
> > On Tue, Apr 02, 2024 at 10:14:08AM +0200, Arnd Bergmann wrote:
> >> On Mon, Apr 1, 2024, at 23:39, Paul E. McKenney wrote:
> >> > Use the new cmpxchg_emu_u8() and cmpxchg_emu_u16() to emulate one-byte
> >> > and two-byte cmpxchg() on arc.
> >> >
> >> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> >> 
> >> I'm missing the context here, is it now mandatory to have 16-bit
> >> cmpxchg() everywhere? I think we've historically tried hard to
> >> keep this out of common code since it's expensive on architectures
> >> that don't have native 16-bit load/store instructions (alpha, armv3)
> >> and or sub-word atomics (armv5, riscv, mips).
> >
> > I need 8-bit, and just added 16-bit because it was easy to do so.
> > I would be OK dropping the 16-bit portions of this series, assuming
> > that no-one needs it.  And assuming that it is easier to drop it than
> > to explain why it is not available.  ;-)
> 
> It certainly makes sense to handle both the same, whichever
> way we do this.

Agreed, at least as long as the properties of the relevant hardware are
consistent with doing so.

> >> Does the code that uses this rely on working concurrently with
> >> non-atomic stores to part of the 32-bit word? If we want to
> >> allow that, we need to merge my alpha ev4/45/5 removal series
> >> first.
> >
> > For 8-but cmpxchg(), yes.  There are potentially concurrent
> > smp_load_acquire() and smp_store_release() operations to this same byte.
> >
> > Or is your question specific to the 16-bit primitives?  (Full disclosure:
> > I have no objection to removing Alpha ev4/45/5, having several times
> > suggested removing Alpha entirely.  And having the scars to prove it.)
> 
> For the native sub-word access, alpha ev5 cannot do either of
> them, while armv3 could do byte access but not 16-bit words.
> 
> It sounds like the old alphas are already broken then, which
> is a good reason to finally drop support. It would appear that
> the arm riscpc is not affected by this though.

Good point, given that single-byte load/store and emulated single-byte
cmpxchg() has been in common code for some time.

So armv3 is OK with one-byte emulated cmpxchg(), but not with two-byte,
which is consistent with the current state of this series in the -rcu
tree.  (My plan is to wait until Monday to re-send the series in order
to allow the test robots to find yet more bugs.)

Or is the plan to also drop support for armv3 in the near term?

> >> For the cmpxchg() interface, I would prefer to handle the
> >> 8-bit and 16-bit versions the same way as cmpxchg64() and
> >> provide separate cmpxchg8()/cmpxchg16()/cmpxchg32() functions
> >> by architectures that operate on fixed-size integer values
> >> but not compounds or pointers, and a generic cmpxchg() wrapper
> >> in common code that can handle the abtraction for pointers,
> >> long and (if absolutely necessary) compounds by multiplexing
> >> between cmpxchg32() and cmpxchg64() where needed.
> >
> > So as to support _acquire(), _relaxed(), and _release()?
> >
> > If so, I don't have any use cases for other than full ordering.
> 
> My main goal here would be to simplify the definition of
> the very commonly used cmpxchg() macro so it doesn't have
> to deal with so many corner cases, and make it work the
> same way across all architectures. Without the type
> agnostic wrapper, there would also be the benefit of
> additional type checking that we get by replacing the
> macros with inline functions.
> 
> We'd still need all the combinations of cmpxchg() and xchg()
> with the four sizes and ordering variants, but at least the
> latter should easily collapse on most architectures. At the
> moment, most architectures only provide the full-ordering
> version.

That does make a lot of sense to me.  Though C-language inline functions
have some trouble with type-generic parameters.

However, my patch is down at architecture-specific level, so should not
affect the cmpxchg() macro, right?  Or am I missing some aspect of your
proposed refactoring?

							Thanx, Paul

  reply	other threads:[~2024-04-04 14:44 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01 21:39 [PATCH RFC cmpxchg 0/8] Provide emulation for one- and two-byte cmpxchg() Paul E. McKenney
2024-04-01 21:39 ` [PATCH RFC cmpxchg 1/8] lib: Add one-byte and two-byte cmpxchg() emulation functions Paul E. McKenney
2024-04-02 13:07   ` Marco Elver
2024-04-02 17:15     ` Paul E. McKenney
2024-04-01 21:39 ` [PATCH RFC cmpxchg 2/8] sparc: Emulate one-byte and two-byte cmpxchg Paul E. McKenney
2024-04-01 22:38   ` Al Viro
2024-04-01 23:58     ` Paul E. McKenney
2024-04-02  0:07       ` Al Viro
2024-04-02  3:37         ` Al Viro
2024-04-02  4:11           ` Al Viro
2024-04-02  4:18             ` Paul E. McKenney
2024-04-02  4:28             ` [PATCH 1/8] sparc32: make __cmpxchg_u32() return u32 Al Viro
2024-04-02  4:28               ` [PATCH 2/8] sparc32: make the first argument of __cmpxchg_u64() volatile u64 * Al Viro
2024-04-02  4:28               ` [PATCH 3/8] sparc32: unify __cmpxchg_u{32,64} Al Viro
2024-04-02  7:28                 ` Arnd Bergmann
2024-04-02 20:02                   ` Paul E. McKenney
2024-04-02  4:28               ` [PATCH 4/8] sparc32: add __cmpxchg_u{8,16}() and teach __cmpxchg() to handle those sizes Al Viro
2024-04-02  4:28               ` [PATCH 5/8] parisc: __cmpxchg_u32(): lift conversion into the callers Al Viro
2024-04-02  4:28               ` [PATCH 6/8] parisc: unify implementations of __cmpxchg_u{8,32,64} Al Viro
2024-04-02  4:28               ` [PATCH 7/8] parisc: add missing export of __cmpxchg_u8() Al Viro
2024-04-02  4:28               ` [PATCH 8/8] parisc: add u16 support to cmpxchg() Al Viro
2024-04-02 20:03               ` [PATCH 1/8] sparc32: make __cmpxchg_u32() return u32 Paul E. McKenney
2024-04-03 22:20                 ` Al Viro
2024-04-04  3:09                   ` Paul E. McKenney
2024-04-02  4:17           ` [PATCH RFC cmpxchg 2/8] sparc: Emulate one-byte and two-byte cmpxchg Paul E. McKenney
2024-04-01 21:39 ` [PATCH RFC cmpxchg 3/8] ARC: " Paul E. McKenney
2024-04-02  8:14   ` Arnd Bergmann
2024-04-02 17:06     ` Paul E. McKenney
2024-04-02 20:52       ` Paul E. McKenney
2024-04-04 11:57       ` Arnd Bergmann
2024-04-04 14:44         ` Paul E. McKenney [this message]
2024-04-04 15:06           ` Arnd Bergmann
2024-04-01 21:39 ` [PATCH RFC cmpxchg 4/8] csky: " Paul E. McKenney
2024-04-01 21:39 ` [PATCH RFC cmpxchg 5/8] sh: " Paul E. McKenney
2024-04-01 21:39 ` [PATCH RFC cmpxchg 6/8] xtensa: " Paul E. McKenney
2024-04-01 21:39 ` [PATCH RFC cmpxchg 7/8] parisc: Emulate " Paul E. McKenney
2024-04-01 21:39 ` [PATCH RFC cmpxchg 8/8] riscv: Emulate one-byte and " Paul E. McKenney
2024-04-04 14:15   ` Palmer Dabbelt
2024-04-04 14:50     ` Paul E. McKenney
2024-05-11  6:50     ` Guo Ren
2024-05-11 14:54       ` Paul E. McKenney
2024-05-11 20:44         ` Leonardo Bras
2024-04-08 17:47 ` [PATCH RFC cmpxchg 0/8] Provide emulation for one- and two-byte cmpxchg() Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 01/14] sparc32: make __cmpxchg_u32() return u32 Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 02/14] sparc32: make the first argument of __cmpxchg_u64() volatile u64 * Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 03/14] sparc32: unify __cmpxchg_u{32,64} Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 04/14] sparc32: add __cmpxchg_u{8,16}() and teach __cmpxchg() to handle those sizes Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 05/14] parisc: __cmpxchg_u32(): lift conversion into the callers Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 06/14] parisc: unify implementations of __cmpxchg_u{8,32,64} Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 07/14] parisc: add missing export of __cmpxchg_u8() Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 08/14] parisc: add u16 support to cmpxchg() Paul E. McKenney
2024-04-08 20:10     ` Linus Torvalds
2024-04-08 20:53       ` Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 09/14] lib: Add one-byte emulation function Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 10/14] ARC: Emulate one-byte cmpxchg Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 11/14] csky: " Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 12/14] sh: " Paul E. McKenney
2024-04-18  8:04     ` Geert Uytterhoeven
2024-04-08 17:49   ` [PATCH cmpxchg 13/14] xtensa: " Paul E. McKenney
2024-04-18  8:06     ` Geert Uytterhoeven
2024-04-18 23:21       ` Paul E. McKenney
2024-04-19  5:07         ` Yujie Liu
2024-04-19  8:02           ` Geert Uytterhoeven
2024-04-20 14:03             ` Paul E. McKenney
2024-04-08 17:49   ` [PATCH cmpxchg 14/14] riscv: " Paul E. McKenney
2024-04-09 17:35     ` Andrea Parri
2024-04-09 18:08       ` Paul E. McKenney
2024-05-01 22:58   ` [PATCH v2 cmpxchg 0/8] Provide emulation for one--byte cmpxchg() Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 01/13] sparc32: make __cmpxchg_u32() return u32 Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 02/13] sparc32: make the first argument of __cmpxchg_u64() volatile u64 * Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 03/13] sparc32: unify __cmpxchg_u{32,64} Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 04/13] sparc32: add __cmpxchg_u{8,16}() and teach __cmpxchg() to handle those sizes Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 05/13] parisc: __cmpxchg_u32(): lift conversion into the callers Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 06/13] parisc: unify implementations of __cmpxchg_u{8,32,64} Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 07/13] parisc: add missing export of __cmpxchg_u8() Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 08/13] parisc: add u16 support to cmpxchg() Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 09/13] lib: Add one-byte emulation function Paul E. McKenney
2024-05-13 14:44       ` Boqun Feng
2024-05-13 15:41         ` Paul E. McKenney
2024-05-13 15:57           ` Boqun Feng
2024-05-13 21:19             ` Boqun Feng
2024-05-14 14:22               ` Paul E. McKenney
2024-05-14 14:53                 ` Boqun Feng
2024-05-14 15:02                   ` Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 10/13] ARC: Emulate one-byte cmpxchg Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 11/13] csky: " Paul E. McKenney
2024-05-11  6:42       ` Guo Ren
2024-05-11 14:49         ` Paul E. McKenney
2024-05-01 23:01     ` [PATCH v2 cmpxchg 12/13] sh: " Paul E. McKenney
2024-05-02  4:52       ` John Paul Adrian Glaubitz
2024-05-02  5:06         ` Paul E. McKenney
2024-05-02  5:11           ` John Paul Adrian Glaubitz
2024-05-02 13:33             ` Paul E. McKenney
2024-05-02 20:53               ` Al Viro
2024-05-02 21:01                 ` alpha cmpxchg.h (was Re: [PATCH v2 cmpxchg 12/13] sh: Emulate one-byte cmpxchg) Al Viro
2024-05-02 22:16                   ` Linus Torvalds
2024-05-02 21:18                 ` [PATCH v2 cmpxchg 12/13] sh: Emulate one-byte cmpxchg Paul E. McKenney
2024-05-02 22:07                   ` Al Viro
2024-05-02 23:12                     ` Paul E. McKenney
2024-05-02 23:24                       ` Al Viro
2024-05-02 23:45                         ` Paul E. McKenney
2024-05-02 23:32                       ` Linus Torvalds
2024-05-03  0:16                         ` Paul E. McKenney
2024-05-02 21:50               ` Arnd Bergmann
2024-05-02  5:42           ` D. Jeff Dionne
2024-05-02 11:30             ` Arnd Bergmann
2024-05-01 23:01     ` [PATCH v2 cmpxchg 13/13] xtensa: " Paul E. McKenney
2024-05-02 20:01     ` [PATCH v2 cmpxchg 0/8] Provide emulation for one--byte cmpxchg() Al Viro
2024-05-02 21:20       ` Paul E. McKenney

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=b84884eb-e23b-480d-827e-06f1188ece9e@paulmck-laptop \
    --to=paulmck@kernel.org \
    --cc=andi.shyti@linux.intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=arnd@arndb.de \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=palmer@rivosinc.com \
    --cc=vgupta@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;
as well as URLs for NNTP newsgroup(s).