mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	Waiman Long <longman@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	kernel test robot <lkp@intel.com>
Subject: [PATCH 1/2] locking: Wire up rwlock_is_contended() on PREEMPT_RT
Date: Mon,  6 Sep 2021 16:30:03 +0200	[thread overview]
Message-ID: <20210906143004.2259141-2-bigeasy@linutronix.de> (raw)
In-Reply-To: <20210906143004.2259141-1-bigeasy@linutronix.de>

rwlock_is_contended() should return 0 if there are no waiters pending
on that lock on, != 0 otherwise.
PREEMPT_RT's implementation of RW-locks provides
rt_rwlock_is_contended() which returns != 0 if there is a writer about
to acquire the lock. The only downside is that a writter, that is
using that function, will always see that this lock is contended even if
there are no readers or writters pending.

Wire up rwlock_is_contended() with RT's rt_rwlock_is_contended().

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/rwlock_rt.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/rwlock_rt.h b/include/linux/rwlock_rt.h
index 49c1f3842ed5b..e482671ff49ee 100644
--- a/include/linux/rwlock_rt.h
+++ b/include/linux/rwlock_rt.h
@@ -30,6 +30,7 @@ extern void rt_read_unlock(rwlock_t *rwlock);
 extern void rt_write_lock(rwlock_t *rwlock);
 extern int rt_write_trylock(rwlock_t *rwlock);
 extern void rt_write_unlock(rwlock_t *rwlock);
+extern int rt_rwlock_is_contended(rwlock_t *rwlock);
 
 static __always_inline void read_lock(rwlock_t *rwlock)
 {
@@ -135,6 +136,6 @@ static __always_inline void write_unlock_irqrestore(rwlock_t *rwlock,
 	rt_write_unlock(rwlock);
 }
 
-#define rwlock_is_contended(lock)		(((void)(lock), 0))
+#define rwlock_is_contended(lock)		rt_rwlock_is_contended(lock)
 
 #endif /* __LINUX_RWLOCK_RT_H */
-- 
2.33.0


  reply	other threads:[~2021-09-06 14:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06 14:30 [PATCH 0/2] locking: Provide {rwlock|spin}_is_contended " Sebastian Andrzej Siewior
2021-09-06 14:30 ` Sebastian Andrzej Siewior [this message]
2021-09-06 14:30 ` [PATCH 2/2] locking: Provide spin_is_contended() " Sebastian Andrzej Siewior
2021-09-07 10:09 ` [PATCH 0/2] locking: Provide {rwlock|spin}_is_contended " Sebastian Andrzej Siewior
2021-09-07 10:34   ` [PATCH] locking: Remove rt_rwlock_is_contended() Sebastian Andrzej Siewior
2021-09-10 16:16     ` Peter Zijlstra
2021-09-10 16:37       ` Sebastian Andrzej Siewior
2021-09-13 11:20         ` Peter Zijlstra

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=20210906143004.2259141-2-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --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®