From: Yury Norov <yury.norov@gmail.com>
To: Ignacio Encinas <ignacio@iencinas.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] riscv: fix test_and_{set,clear}_bit ordering documentation
Date: Wed, 12 Mar 2025 19:38:04 -0400 [thread overview]
Message-ID: <Z9Ia3AMqFpNj6fUb@thinkpad> (raw)
In-Reply-To: <20250311-riscv-fix-test-and-set-bit-comment-v1-1-8d2598e1e43b@iencinas.com>
On Tue, Mar 11, 2025 at 06:20:22PM +0100, Ignacio Encinas wrote:
> test_and_{set,clear}_bit are fully ordered as specified in
> Documentation/atomic_bitops.txt. Fix incorrect comment stating otherwise.
>
> Note that the implementation is correct since commit
> 9347ce54cd69 ("RISC-V: __test_and_op_bit_ord should be strongly ordered")
> was introduced.
>
> Signed-off-by: Ignacio Encinas <ignacio@iencinas.com>
Applied in bitmap-for-next.
Thanks,
Yury
> ---
> This seems to be a leftover comment from the initial implementation
> which assumed these operations were relaxed.
>
> Documentation/atomic_bitops.txt states:
>
> [...]
> RMW atomic operations with return value:
>
> test_and_{set,clear,change}_bit()
> test_and_set_bit_lock()
> [...]
>
> - RMW operations that have a return value are fully ordered.
>
> Similar comments can be found in
> include/asm-generic/bitops/instrumented-atomic.h,
> include/linux/atomic/atomic-long.h, etc...
> ---
> arch/riscv/include/asm/bitops.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/include/asm/bitops.h b/arch/riscv/include/asm/bitops.h
> index c6bd3d8354a96b4e7bbef0e98a201da412301b57..49a0f48d93df5be4d38fe25b437378467e4ca433 100644
> --- a/arch/riscv/include/asm/bitops.h
> +++ b/arch/riscv/include/asm/bitops.h
> @@ -226,7 +226,7 @@ static __always_inline int variable_fls(unsigned int x)
> * @nr: Bit to set
> * @addr: Address to count from
> *
> - * This operation may be reordered on other architectures than x86.
> + * This is an atomic fully-ordered operation (implied full memory barrier).
> */
> static __always_inline int arch_test_and_set_bit(int nr, volatile unsigned long *addr)
> {
> @@ -238,7 +238,7 @@ static __always_inline int arch_test_and_set_bit(int nr, volatile unsigned long
> * @nr: Bit to clear
> * @addr: Address to count from
> *
> - * This operation can be reordered on other architectures other than x86.
> + * This is an atomic fully-ordered operation (implied full memory barrier).
> */
> static __always_inline int arch_test_and_clear_bit(int nr, volatile unsigned long *addr)
> {
>
> ---
> base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
> change-id: 20250311-riscv-fix-test-and-set-bit-comment-aa9081a27d61
>
> Best regards,
> --
> Ignacio Encinas <ignacio@iencinas.com>
prev parent reply other threads:[~2025-03-12 23:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 17:20 [PATCH] riscv: fix test_and_{set,clear}_bit ordering documentation Ignacio Encinas
2025-03-12 23:38 ` Yury Norov [this message]
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=Z9Ia3AMqFpNj6fUb@thinkpad \
--to=yury.norov@gmail.com \
--cc=ignacio@iencinas.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@rasmusvillemoes.dk \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=skhan@linuxfoundation.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