linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot2 for Waiman Long" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Waiman Long <longman@redhat.com>, Ingo Molnar <mingo@kernel.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: locking/core] locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint
Date: Wed, 28 Feb 2024 12:53:21 -0000	[thread overview]
Message-ID: <170912480198.398.8722869596829490134.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240222150540.79981-4-longman@redhat.com>

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     d566c78659eccf085f905fd266fc461de92eaa8f
Gitweb:        https://git.kernel.org/tip/d566c78659eccf085f905fd266fc461de92eaa8f
Author:        Waiman Long <longman@redhat.com>
AuthorDate:    Thu, 22 Feb 2024 10:05:39 -05:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 28 Feb 2024 13:08:38 +01:00

locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint

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>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20240222150540.79981-4-longman@redhat.com
---
 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 2340b6d..c6d17ae 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))

  reply	other threads:[~2024-02-28 12:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 15:05 [PATCH v2 0/4] locking: Some locking code cleanups Waiman Long
2024-02-22 15:05 ` [PATCH v2 1/4] locking/qspinlock: Fix 'wait_early' set but not used warning Waiman Long
2024-02-28 12:53   ` [tip: locking/core] " tip-bot2 for Waiman Long
2024-03-11 10:57     ` Ingo Molnar
2024-03-11 13:45       ` Waiman Long
2024-02-22 15:05 ` [PATCH v2 2/4] locking/mutex: Clean up mutex.h Waiman Long
2024-02-28 12:53   ` [tip: locking/core] locking/mutex: Simplify <linux/mutex.h> tip-bot2 for Waiman Long
2024-02-22 15:05 ` [PATCH v2 3/4] locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint Waiman Long
2024-02-28 12:53   ` tip-bot2 for Waiman Long [this message]
2024-02-22 15:05 ` [PATCH v2 4/4] locking/rwsem: Make DEBUG_RWSEMS and PREEMPT_RT mutually exclusive Waiman Long
2024-02-28 12:53   ` [tip: locking/core] " tip-bot2 for Waiman Long

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=170912480198.398.8722869596829490134.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@kernel.org \
    --cc=x86@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).