From: Boqun Feng <boqun.feng@gmail.com>
To: Waiman Long <longman@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
George Stark <gnstark@salutedevices.com>
Subject: Re: [PATCH 3/4] locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint
Date: Wed, 21 Feb 2024 20:12:09 -0800 [thread overview]
Message-ID: <ZdbJmbltYYBPvU-3@boqun-archlinux> (raw)
In-Reply-To: <20240213031656.1375951-4-longman@redhat.com>
On Mon, Feb 12, 2024 at 10:16:55PM -0500, Waiman Long wrote:
> Clarify in the comments that the RWSEM_READER_OWNED bit in the owner
> field is just a hint, not an authoritative state of the rwsem.
>
> Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Regards,
Boqun
> ---
> kernel/locking/rwsem.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
> index 2340b6d90ec6..c6d17aee4209 100644
> --- a/kernel/locking/rwsem.c
> +++ b/kernel/locking/rwsem.c
> @@ -35,7 +35,7 @@
> /*
> * The least significant 2 bits of the owner value has the following
> * meanings when set.
> - * - Bit 0: RWSEM_READER_OWNED - The rwsem is owned by readers
> + * - Bit 0: RWSEM_READER_OWNED - rwsem may be owned by readers (just a hint)
> * - Bit 1: RWSEM_NONSPINNABLE - Cannot spin on a reader-owned lock
> *
> * When the rwsem is reader-owned and a spinning writer has timed out,
> @@ -1002,8 +1002,8 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat
>
> /*
> * To prevent a constant stream of readers from starving a sleeping
> - * waiter, don't attempt optimistic lock stealing if the lock is
> - * currently owned by readers.
> + * writer, don't attempt optimistic lock stealing if the lock is
> + * very likely owned by readers.
> */
> if ((atomic_long_read(&sem->owner) & RWSEM_READER_OWNED) &&
> (rcnt > 1) && !(count & RWSEM_WRITER_LOCKED))
> --
> 2.39.3
>
next prev parent reply other threads:[~2024-02-22 4:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 3:16 [PATCH 0/4] locking: Some locking code cleanups Waiman Long
2024-02-13 3:16 ` [PATCH 1/4] locking/qspinlock: Fix 'wait_early' set but not used warning Waiman Long
2024-02-22 4:09 ` Boqun Feng
2024-02-13 3:16 ` [PATCH 2/4] locking/mutex: Clean up mutex.h Waiman Long
2024-02-22 4:33 ` Boqun Feng
2024-02-22 14:05 ` Waiman Long
2024-02-13 3:16 ` [PATCH 3/4] locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint Waiman Long
2024-02-22 4:12 ` Boqun Feng [this message]
2024-02-13 3:16 ` [PATCH 4/4] locking/rwsem: Make DEBUG_RWSEMS and PREEMPT_RT mutually exclusive Waiman Long
2024-02-22 4:36 ` Boqun Feng
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=ZdbJmbltYYBPvU-3@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=gnstark@salutedevices.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--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