[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <166201996350.401.14184268596375790493.tip-bot2@tip-bot2>
Date: Thu, 01 Sep 2022 08:12:43 -0000
From: "tip-bot2 for Marco Elver" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Marco Elver <elver@...gle.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Dmitry Vyukov <dvyukov@...gle.com>,
Ian Rogers <irogers@...gle.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: perf/core] locking/percpu-rwsem: Add percpu_is_write_locked()
and percpu_is_read_locked()
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 01fe8a3f818e1074a9a95d624be4549ee7ea2b2b
Gitweb: https://git.kernel.org/tip/01fe8a3f818e1074a9a95d624be4549ee7ea2b2b
Author: Marco Elver <elver@...gle.com>
AuthorDate: Mon, 29 Aug 2022 14:47:15 +02:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Tue, 30 Aug 2022 10:56:23 +02:00
locking/percpu-rwsem: Add percpu_is_write_locked() and percpu_is_read_locked()
Implement simple accessors to probe percpu-rwsem's locked state:
percpu_is_write_locked(), percpu_is_read_locked().
Signed-off-by: Marco Elver <elver@...gle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Dmitry Vyukov <dvyukov@...gle.com>
Acked-by: Ian Rogers <irogers@...gle.com>
Link: https://lore.kernel.org/r/20220829124719.675715-11-elver@google.com
---
include/linux/percpu-rwsem.h | 6 ++++++
kernel/locking/percpu-rwsem.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h
index 5fda40f..36b942b 100644
--- a/include/linux/percpu-rwsem.h
+++ b/include/linux/percpu-rwsem.h
@@ -121,9 +121,15 @@ static inline void percpu_up_read(struct percpu_rw_semaphore *sem)
preempt_enable();
}
+extern bool percpu_is_read_locked(struct percpu_rw_semaphore *);
extern void percpu_down_write(struct percpu_rw_semaphore *);
extern void percpu_up_write(struct percpu_rw_semaphore *);
+static inline bool percpu_is_write_locked(struct percpu_rw_semaphore *sem)
+{
+ return atomic_read(&sem->block);
+}
+
extern int __percpu_init_rwsem(struct percpu_rw_semaphore *,
const char *, struct lock_class_key *);
diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c
index 5fe4c54..185bd1c 100644
--- a/kernel/locking/percpu-rwsem.c
+++ b/kernel/locking/percpu-rwsem.c
@@ -192,6 +192,12 @@ EXPORT_SYMBOL_GPL(__percpu_down_read);
__sum; \
})
+bool percpu_is_read_locked(struct percpu_rw_semaphore *sem)
+{
+ return per_cpu_sum(*sem->read_count) != 0 && !atomic_read(&sem->block);
+}
+EXPORT_SYMBOL_GPL(percpu_is_read_locked);
+
/*
* Return true if the modular sum of the sem->read_count per-CPU variable is
* zero. If this sum is zero, then it is stable due to the fact that if any
Powered by blists - more mailing lists