History

locking/percpu-rwsem: Add DEFINE_PERCPU_RWSEM(), use it to initialize cgroup_threadgroup_rwsem

Turn DEFINE_STATIC_PERCPU_RWSEM() into __DEFINE_PERCPU_RWSEM() with the additional "is_static" argument to introduce DEFINE_PERCPU_RWSEM(). Change cgroup.c to use DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem).

Oleg Nesterov committed 7 years ago

Commit 3f2947b1 parent 2bf1acc2 files · +7 −4Browse files

Unified · Split

2 files
  1. include/linux/percpu-rwsem.h +6 −2
  2. kernel/cgroup/cgroup.c +1 −2
include/linux/percpu-rwsem.h+6−2
@@ -17,14 +17,18 @@ struct percpu_rw_semaphore { · 16 unmodified lines
1717 int readers_block;
1818 };
1919
20−#define DEFINE_STATIC_PERCPU_RWSEM(name) \
20+#define __DEFINE_PERCPU_RWSEM(name, is_static) \
2121 static DEFINE_PER_CPU(unsigned int, __percpu_rwsem_rc_##name); \
22−static struct percpu_rw_semaphore name = { \
22+is_static struct percpu_rw_semaphore name = { \
2323 .rss = __RCU_SYNC_INITIALIZER(name.rss), \
2424 .read_count = &__percpu_rwsem_rc_##name, \
2525 .rw_sem = __RWSEM_INITIALIZER(name.rw_sem), \
2626 .writer = __RCUWAIT_INITIALIZER(name.writer), \
2727 }
28+#define DEFINE_PERCPU_RWSEM(name) \
29+ __DEFINE_PERCPU_RWSEM(name, /* not static */)
30+#define DEFINE_STATIC_PERCPU_RWSEM(name) \
31+ __DEFINE_PERCPU_RWSEM(name, static)
2832
2933 extern int __percpu_down_read(struct percpu_rw_semaphore *, int);
3034 extern void __percpu_up_read(struct percpu_rw_semaphore *);
kernel/cgroup/cgroup.c+1−2
@@ -101,7 +101,7 @@ static DEFINE_SPINLOCK(cgroup_idr_lock); · 100 unmodified lines
101101 */
102102 static DEFINE_SPINLOCK(cgroup_file_kn_lock);
103103
104−struct percpu_rw_semaphore cgroup_threadgroup_rwsem;
104+DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem);
105105
106106 #define cgroup_assert_mutex_or_rcu_locked() \
107107 RCU_LOCKDEP_WARN(!rcu_read_lock_held() && \
@@ -5616,7 +5616,6 @@ int __init cgroup_init(void) · 5508 unmodified lines
56165616 int ssid;
56175617
56185618 BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > 16);
5619− BUG_ON(percpu_init_rwsem(&cgroup_threadgroup_rwsem));
56205619 BUG_ON(cgroup_init_cftypes(NULL, cgroup_base_files));
56215620 BUG_ON(cgroup_init_cftypes(NULL, cgroup1_base_files));
56225621

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t