diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2016-01-08 10:43:50 -0500 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2016-02-23 22:59:55 -0500 |
commit | 9de630c4f264dec48e61edd871cb98b8e1b58250 (patch) | |
tree | e11bfe739aeb1e90d2a0fb31df4339bf39d2ced2 | |
parent | 9fc9204ef9fdbe550fd81a554abce2b210e63e49 (diff) |
rcu: Document unique-name limitation for DEFINE_STATIC_SRCU()
SRCU uses per-CPU variables, and DEFINE_STATIC_SRCU() uses a static
per-CPU variable. However, per-CPU variables have significant
restrictions, for example, names of per-CPU variables must be globally
unique, even if declared static. These restrictions carry over to
DEFINE_STATIC_SRCU(), and this commit therefore documents these
restrictions.
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Suggested-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | include/linux/srcu.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/include/linux/srcu.h b/include/linux/srcu.h index f5f80c5643ac..dc8eb63c6568 100644 --- a/include/linux/srcu.h +++ b/include/linux/srcu.h | |||
@@ -99,8 +99,23 @@ void process_srcu(struct work_struct *work); | |||
99 | } | 99 | } |
100 | 100 | ||
101 | /* | 101 | /* |
102 | * define and init a srcu struct at build time. | 102 | * Define and initialize a srcu struct at build time. |
103 | * dont't call init_srcu_struct() nor cleanup_srcu_struct() on it. | 103 | * Do -not- call init_srcu_struct() nor cleanup_srcu_struct() on it. |
104 | * | ||
105 | * Note that although DEFINE_STATIC_SRCU() hides the name from other | ||
106 | * files, the per-CPU variable rules nevertheless require that the | ||
107 | * chosen name be globally unique. These rules also prohibit use of | ||
108 | * DEFINE_STATIC_SRCU() within a function. If these rules are too | ||
109 | * restrictive, declare the srcu_struct manually. For example, in | ||
110 | * each file: | ||
111 | * | ||
112 | * static struct srcu_struct my_srcu; | ||
113 | * | ||
114 | * Then, before the first use of each my_srcu, manually initialize it: | ||
115 | * | ||
116 | * init_srcu_struct(&my_srcu); | ||
117 | * | ||
118 | * See include/linux/percpu-defs.h for the rules on per-CPU variables. | ||
104 | */ | 119 | */ |
105 | #define __DEFINE_SRCU(name, is_static) \ | 120 | #define __DEFINE_SRCU(name, is_static) \ |
106 | static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\ | 121 | static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\ |