[PATCH 1/7] percpu-rwsem: DEFINE_STATIC_PERCPU_RWSEM
From: Peter Zijlstra
Date: Mon Sep 05 2016 - 15:43:29 EST
Provide a static init.
Cc: der.herr@xxxxxxx
Cc: viro@xxxxxxxxxxxxxxxxxx
Cc: mingo@xxxxxxxxxx
Cc: torvalds@xxxxxxxxxxxxxxxxxxxx
Cc: dave@xxxxxxxxxxxx
Cc: oleg@xxxxxxxxxx
Cc: riel@xxxxxxxxxx
Cc: tj@xxxxxxxxxx
Cc: paulmck@xxxxxxxxxxxxxxxxxx
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
include/linux/percpu-rwsem.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
--- a/include/linux/percpu-rwsem.h
+++ b/include/linux/percpu-rwsem.h
@@ -16,6 +16,15 @@ struct percpu_rw_semaphore {
int readers_block;
};
+#define DEFINE_STATIC_PERCPU_RWSEM(name) \
+static DEFINE_PER_CPU(unsigned int, __percpu_rwsem_rc_##name); \
+static struct percpu_rw_semaphore name = { \
+ .rss = __RCU_SYNC_INITIALIZER(name.rss, RCU_SCHED_SYNC), \
+ .read_count = &__percpu_rwsem_rc_##name, \
+ .rw_sem = __RWSEM_INITIALIZER(name.rw_sem), \
+ .writer = __WAIT_QUEUE_HEAD_INITIALIZER(name.writer), \
+}
+
extern int __percpu_down_read(struct percpu_rw_semaphore *, int);
extern void __percpu_up_read(struct percpu_rw_semaphore *);
@@ -102,6 +111,9 @@ extern void percpu_free_rwsem(struct per
#define percpu_rwsem_is_held(sem) lockdep_is_held(&(sem)->rw_sem)
+#define percpu_rwsem_assert_held(sem) \
+ lockdep_assert_held(&(sem)->rw_sem)
+
static inline void percpu_rwsem_release(struct percpu_rw_semaphore *sem,
bool read, unsigned long ip)
{