From: Peter Zijlstra <peterz@infradead.org>
To: Jules Maselbas <jmaselbas@kalray.eu>
Cc: Will Deacon <will@kernel.org>, Boqun Feng <boqun.feng@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
Arnd Bergmann <arnd@arndb.de>,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] locking/atomic: atomic: Use arch_atomic_{read,set} in generic atomic ops
Date: Fri, 27 Jan 2023 12:18:13 +0100 [thread overview]
Message-ID: <Y9Oy9ZAj/DQ7O+6e@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20230126173354.13250-1-jmaselbas@kalray.eu>
On Thu, Jan 26, 2023 at 06:33:54PM +0100, Jules Maselbas wrote:
> @@ -58,9 +61,11 @@ static inline int generic_atomic_fetch_##op(int i, atomic_t *v) \
> static inline void generic_atomic_##op(int i, atomic_t *v) \
> { \
> unsigned long flags; \
> + int c; \
> \
> raw_local_irq_save(flags); \
> - v->counter = v->counter c_op i; \
> + c = arch_atomic_read(v); \
> + arch_atomic_set(v, c c_op i); \
> raw_local_irq_restore(flags); \
> }
This and the others like it are a bit sad, it explicitly dis-allows the
compiler from using memops and forces a load-store.
The alternative is writing it like:
*(volatile int *)&v->counter c_op i;
but that's pretty shit too I suppose.
next prev parent reply other threads:[~2023-01-27 11:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 17:33 Jules Maselbas
2023-01-27 11:18 ` Peter Zijlstra [this message]
2023-01-27 13:49 ` Jules Maselbas
2023-01-27 14:34 ` Peter Zijlstra
2023-01-27 22:09 ` Boqun Feng
2023-01-30 12:23 ` Jonas Oberhauser
2023-01-30 18:38 ` Boqun Feng
2023-01-31 15:08 ` Jonas Oberhauser
2023-01-31 22:03 ` Boqun Feng
2023-02-01 10:51 ` Jonas Oberhauser
2023-01-30 18:15 ` Jules Maselbas
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=Y9Oy9ZAj/DQ7O+6e@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=arnd@arndb.de \
--cc=boqun.feng@gmail.com \
--cc=jmaselbas@kalray.eu \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--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®