From: Tejun Heo <tj@kernel.org>
To: Will Deacon <will@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
marcan@marcan.st, peterz@infradead.org, jirislaby@kernel.org,
maz@kernel.org, mark.rutland@arm.com, boqun.feng@gmail.com,
catalin.marinas@arm.com, oneukum@suse.com,
roman.penyaev@profitbricks.com, asahi@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] workqueue: Fix memory ordering race in queue_work*()
Date: Tue, 16 Aug 2022 07:01:17 -1000 [thread overview]
Message-ID: <YvvNXdkrtlmKZRex@slm.duckdns.org> (raw)
In-Reply-To: <20220816134156.GB11202@willie-the-truck>
Hello, Will.
On Tue, Aug 16, 2022 at 02:41:57PM +0100, Will Deacon wrote:
> /**
> * test_and_set_bit - Set a bit and return its old value
> * @nr: Bit to set
> * @addr: Address to count from
> *
> * This operation is atomic and cannot be reordered.
> * It may be reordered on other architectures than x86.
> * It also implies a memory barrier.
> */
>
> so while Peter and I were trying to improve the documentation for
> atomics and memory barriers we clearly ended up making the wrong call
> trying to treat this like e.g. a cmpxchg() (which has the
> unordered-on-failure semantics).
I think the doc can be improved here. atomic_t.txt says under ORDERING:
- RMW operations that have a return value are fully ordered;
- RMW operations that are conditional are unordered on FAILURE,
otherwise the above rules apply.
But nothing spells out what's conditional. Maybe it's okay to expect people
to read this doc and extrapolate how it applies, but I think it'd be better
if we spell out clearly per operaiton so that readers can search for a
speicific operation and then follow what the rules are from there.
It bothers me that there doesn't seem to be a comprehensive
operation-indexed doc on the subject. memory-barrier.txt doesn't cover which
operations do what barriers. atomic_t.txt and atomic_bitops.txt cover the
atomic_t operations but not in a comprehensive or searchable manner (e.g.
does test_and_set_bit() return 0 or 1 on success?) and it's not clear where
to look for non-atomic_t atomic operations. I guess it's implied that they
follow the same rules as atomic_t counterparts but I can't seem to find that
spelled out anywhere. The source code docs are layered and dispersed for
generic and arch implemetnations making them difficult to follow.
It'd be awesome if the documentation situation can be improved.
Thanks.
--
tejun
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-08-16 17:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 17:58 [PATCH] workqueue: Fix memory ordering race in queue_work*() Hector Martin
2022-08-15 19:10 ` Tejun Heo
2022-08-16 4:15 ` Herbert Xu
2022-08-16 5:27 ` Linus Torvalds
2022-08-16 5:36 ` Hector Martin
2022-08-16 5:52 ` Linus Torvalds
2022-08-16 6:28 ` Hector Martin
2022-08-16 7:48 ` Herbert Xu
2022-08-16 8:01 ` Hector Martin
2022-08-16 5:48 ` Herbert Xu
2022-08-16 6:03 ` Linus Torvalds
2022-08-16 13:41 ` Will Deacon
2022-08-16 14:55 ` Boqun Feng
2022-08-16 16:22 ` Hector Martin
2022-08-16 16:43 ` Boqun Feng
2022-08-16 16:58 ` Linus Torvalds
2022-08-16 16:41 ` Linus Torvalds
2022-08-17 5:05 ` Herbert Xu
2022-08-16 17:01 ` Tejun Heo [this message]
2022-08-16 16:26 ` Tejun Heo
2022-08-16 17:21 ` Hector Martin
2022-08-16 4:14 ` Herbert Xu
2022-08-16 5:37 ` Hector Martin
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=YvvNXdkrtlmKZRex@slm.duckdns.org \
--to=tj@kernel.org \
--cc=asahi@lists.linux.dev \
--cc=boqun.feng@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=herbert@gondor.apana.org.au \
--cc=jirislaby@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oneukum@suse.com \
--cc=peterz@infradead.org \
--cc=roman.penyaev@profitbricks.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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