Skip to contentSkip to conversation

rcu: declare rcu_data variables in the section they are defined in

PATCH In review Nicolas Iooss 3 participants 8 messages May 3, 2015 – May 6, 2015 RCU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu: declare rcu_data variables in the section they are defined in

Commit 11bbb235c26f ("rcu: Use DEFINE_PER_CPU_SHARED_ALIGNED for rcu_data") replaced DEFINE_PER_CPU by DEFINE_PER_CPU_SHARED_ALIGNED in the definition of rcu_sched and rcu_bh without updating kernel/rcu/tree.h.

This makes clang report a section mismatch (-Wsection warning) when building LLVMLinux because the variables are declared in .data..percpu but defined in .data..percpu..shared_aligned.

---
 kernel/rcu/tree.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree.h +2 -2
index a69d3dab2ec4..c5e85b27a79f 100644
@@ -519,10 +519,10 @@ extern struct list_head rcu_struct_flavors;
  * RCU implementation internal declarations:
  */
 extern struct rcu_state rcu_sched_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_sched_data);
+DECLARE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_sched_data);
 
 extern struct rcu_state rcu_bh_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
+DECLARE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_bh_data);
 
 #ifdef CONFIG_PREEMPT_RCU
 extern struct rcu_state rcu_preempt_state;
Signature · 1 line
2.3.6
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Nicolas Iooss

Commit 11bbb235c26f ("rcu: Use DEFINE_PER_CPU_SHARED_ALIGNED for rcu_data") replaced DEFINE_PER_CPU by DEFINE_PER_CPU_SHARED_ALIGNED in the definition of rcu_sched and rcu_bh without updating kernel/rcu/tree.h.

This makes clang report a section mismatch (-Wsection warning) when building LLVMLinux because the variables are declared in .data..percpu but defined in .data..percpu..shared_aligned.

Good catch.

Quoted 24 lines
---
 kernel/rcu/tree.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree.h +2 -2
index a69d3dab2ec4..c5e85b27a79f 100644
@@ -519,10 +519,10 @@ extern struct list_head rcu_struct_flavors;
  * RCU implementation internal declarations:
  */
 extern struct rcu_state rcu_sched_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_sched_data);
+DECLARE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_sched_data);
 
 extern struct rcu_state rcu_bh_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
+DECLARE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_bh_data);
 
 #ifdef CONFIG_PREEMPT_RCU
 extern struct rcu_state rcu_preempt_state;
Signature · 1 line
2.3.6
#2 lore raw
Quoted 6 lines · Josh Triplett
Quoted 5 lines · Nicolas Iooss

Commit 11bbb235c26f ("rcu: Use DEFINE_PER_CPU_SHARED_ALIGNED for rcu_data") replaced DEFINE_PER_CPU by DEFINE_PER_CPU_SHARED_ALIGNED in the definition of rcu_sched and rcu_bh without updating kernel/rcu/tree.h.

Quoted 8 lines
Quoted 5 lines

This makes clang report a section mismatch (-Wsection warning) when building LLVMLinux because the variables are declared in .data..percpu but defined in .data..percpu..shared_aligned.

Good catch.

Agreed, good catch! But don't we also need to worry about rcu_preempt_data? Also, given that tree_trace.c now uses iterators rather than direct access via the per-CPU variables, wouldn't the following be more appropriate? (-Very- lightly tested.)

Thanx, Paul

------------------------------------------------------------------------

kernel/rcu/tree.h +0 -11
index da9f6adb5ff9..ee86870b1825 100644
@@ -537,17 +537,6 @@ extern struct list_head rcu_struct_flavors;
 /*
  * RCU implementation internal declarations:
  */
-extern struct rcu_state rcu_sched_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_sched_data);
-
-extern struct rcu_state rcu_bh_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
-
-#ifdef CONFIG_PREEMPT_RCU
-extern struct rcu_state rcu_preempt_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data);
-#endif /* #ifdef CONFIG_PREEMPT_RCU */
-
 #ifdef CONFIG_RCU_BOOST
 DECLARE_PER_CPU(unsigned int, rcu_cpu_kthread_status);
 DECLARE_PER_CPU(int, rcu_cpu_kthread_cpu);
#3 lore raw
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Josh Triplett
Quoted 9 lines · Nicolas Iooss

Commit 11bbb235c26f ("rcu: Use DEFINE_PER_CPU_SHARED_ALIGNED for rcu_data") replaced DEFINE_PER_CPU by DEFINE_PER_CPU_SHARED_ALIGNED in the definition of rcu_sched and rcu_bh without updating kernel/rcu/tree.h.

This makes clang report a section mismatch (-Wsection warning) when building LLVMLinux because the variables are declared in .data..percpu but defined in .data..percpu..shared_aligned.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Good catch.

Agreed, good catch! But don't we also need to worry about rcu_preempt_data?

Yes, I missed it because I didn't know that allyesconfig/allmodconfig does not select CONFIG_PREEMPT (it selects CONFIG_PREEMPT_NONE instead).

Quoted 3 lines

Also, given that tree_trace.c now uses iterators
rather than direct access via the per-CPU variables, wouldn't the following be more appropriate? (-Very- lightly tested.)

This doesn't work with CONFIG_TREE_RCU_TRACE, because kernel/rcu/tree_trace.c uses rcu_preempt_state (in v4.1-rc2). I've successfully built an allmodconfig+CONFIG_PREEMPT kernel for x86_64 with the following patch (I have not tested the result).

Anyway, thanks for your quick replies.

Nicolas

kernel/rcu/tree.c +0 -0
@@ -91,7 +91,7 @@ static const char *tp_##sname##_varname __used

__tracepoint_string = sname##_var

#define RCU_STATE_INITIALIZER(sname, sabbr, cr) \
DEFINE_RCU_TPS(sname) \
-DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
+static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
struct rcu_state sname##_state = { \
.level = { &sname##_state.node[0] }, \
.rda = &sname##_data, \

kernel/rcu/tree.h +0 -3
@@ -519,14 +519,11 @@ extern struct list_head rcu_struct_flavors;
  * RCU implementation internal declarations:
  */
 extern struct rcu_state rcu_sched_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_sched_data);
 
 extern struct rcu_state rcu_bh_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
 
 #ifdef CONFIG_PREEMPT_RCU
 extern struct rcu_state rcu_preempt_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data);
 #endif /* #ifdef CONFIG_PREEMPT_RCU */
 
 #ifdef CONFIG_RCU_BOOST
#4 lore raw
Quoted 27 lines · Nicolas Iooss
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Josh Triplett
Quoted 9 lines · Nicolas Iooss

Commit 11bbb235c26f ("rcu: Use DEFINE_PER_CPU_SHARED_ALIGNED for rcu_data") replaced DEFINE_PER_CPU by DEFINE_PER_CPU_SHARED_ALIGNED in the definition of rcu_sched and rcu_bh without updating kernel/rcu/tree.h.

This makes clang report a section mismatch (-Wsection warning) when building LLVMLinux because the variables are declared in .data..percpu but defined in .data..percpu..shared_aligned.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Good catch.

Agreed, good catch! But don't we also need to worry about rcu_preempt_data?

Yes, I missed it because I didn't know that allyesconfig/allmodconfig does not select CONFIG_PREEMPT (it selects CONFIG_PREEMPT_NONE instead).

Quoted 3 lines

Also, given that tree_trace.c now uses iterators
rather than direct access via the per-CPU variables, wouldn't the following be more appropriate? (-Very- lightly tested.)

Quoted 6 lines

This doesn't work with CONFIG_TREE_RCU_TRACE, because kernel/rcu/tree_trace.c uses rcu_preempt_state (in v4.1-rc2). I've successfully built an allmodconfig+CONFIG_PREEMPT kernel for x86_64 with the following patch (I have not tested the result).

Anyway, thanks for your quick replies.

Good point, and your patch does look better.

If you resend with proper changelog and Signed-off-by, and if Josh is good with the change, I will queue it.

Thanx, Paul

Quoted 32 lines

Nicolas

kernel/rcu/tree.c +0 -0
@@ -91,7 +91,7 @@ static const char *tp_##sname##_varname __used

__tracepoint_string = sname##_var

#define RCU_STATE_INITIALIZER(sname, sabbr, cr) \
DEFINE_RCU_TPS(sname) \

kernel/rcu/tree.c +1 -1
-DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
+static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
 struct rcu_state sname##_state = { \
 	.level = { &sname##_state.node[0] }, \
 	.rda = &sname##_data, \
kernel/rcu/tree.h +0 -3
@@ -519,14 +519,11 @@ extern struct list_head rcu_struct_flavors;
  * RCU implementation internal declarations:
  */
 extern struct rcu_state rcu_sched_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_sched_data);
 
 extern struct rcu_state rcu_bh_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
 
 #ifdef CONFIG_PREEMPT_RCU
 extern struct rcu_state rcu_preempt_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data);
 #endif /* #ifdef CONFIG_PREEMPT_RCU */
 
 #ifdef CONFIG_RCU_BOOST
#5 lore raw

PATCH 1/1 rcu: make rcu_*_data variables static

rcu_bh_data, rcu_sched_data and rcu_preempt_data are never used outside kernel/rcu/tree.c and thus can be made static.

Doing so fixes a section mismatch warning reported by clang when building LLVMLinux with -Wsection, because these variables were declared in .data..percpu and defined in .data..percpu..shared_aligned since commit 11bbb235c26f ("rcu: Use DEFINE_PER_CPU_SHARED_ALIGNED for rcu_data").

---
 kernel/rcu/tree.c | 2 +-
 kernel/rcu/tree.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
kernel/rcu/tree.c +1 -1
index 233165da782f..e4a607fc5ad0 100644
@@ -91,7 +91,7 @@ static const char *tp_##sname##_varname __used __tracepoint_string = sname##_var
 
 #define RCU_STATE_INITIALIZER(sname, sabbr, cr) \
 DEFINE_RCU_TPS(sname) \
-DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
+static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
 struct rcu_state sname##_state = { \
 	.level = { &sname##_state.node[0] }, \
 	.rda = &sname##_data, \
kernel/rcu/tree.h +0 -3
index a69d3dab2ec4..0c32f730d033 100644
@@ -519,14 +519,11 @@ extern struct list_head rcu_struct_flavors;
  * RCU implementation internal declarations:
  */
 extern struct rcu_state rcu_sched_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_sched_data);
 
 extern struct rcu_state rcu_bh_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
 
 #ifdef CONFIG_PREEMPT_RCU
 extern struct rcu_state rcu_preempt_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data);
 #endif /* #ifdef CONFIG_PREEMPT_RCU */
 
 #ifdef CONFIG_RCU_BOOST
Signature · 1 line
2.3.6
maintainer Reviewed-by on v1 1/1
#6 lore raw

Re: [PATCH] rcu: make rcu_*_data variables static

Quoted 10 lines · Nicolas Iooss

rcu_bh_data, rcu_sched_data and rcu_preempt_data are never used outside kernel/rcu/tree.c and thus can be made static.

Doing so fixes a section mismatch warning reported by clang when building LLVMLinux with -Wsection, because these variables were declared in .data..percpu and defined in .data..percpu..shared_aligned since commit 11bbb235c26f ("rcu: Use DEFINE_PER_CPU_SHARED_ALIGNED for rcu_data").

Nice improvement.

Minor nit: since these are only one line each now, they don't really need a blank line between them, but *shrug*.

Quoted 40 lines
---
 kernel/rcu/tree.c | 2 +-
 kernel/rcu/tree.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
kernel/rcu/tree.c +1 -1
index 233165da782f..e4a607fc5ad0 100644
@@ -91,7 +91,7 @@ static const char *tp_##sname##_varname __used __tracepoint_string = sname##_var
 
 #define RCU_STATE_INITIALIZER(sname, sabbr, cr) \
 DEFINE_RCU_TPS(sname) \
-DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
+static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
 struct rcu_state sname##_state = { \
 	.level = { &sname##_state.node[0] }, \
 	.rda = &sname##_data, \
kernel/rcu/tree.h +0 -3
index a69d3dab2ec4..0c32f730d033 100644
@@ -519,14 +519,11 @@ extern struct list_head rcu_struct_flavors;
  * RCU implementation internal declarations:
  */
 extern struct rcu_state rcu_sched_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_sched_data);
 
 extern struct rcu_state rcu_bh_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
 
 #ifdef CONFIG_PREEMPT_RCU
 extern struct rcu_state rcu_preempt_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data);
 #endif /* #ifdef CONFIG_PREEMPT_RCU */
 
 #ifdef CONFIG_RCU_BOOST
Signature · 1 line
2.3.6
#7 lore raw

Re: [PATCH] rcu: make rcu_*_data variables static

Quoted 10 lines · On Tue, May 05, 2015 at 04:25:58PM -0700, [email protected] wrote:
Quoted 9 lines · Nicolas Iooss

rcu_bh_data, rcu_sched_data and rcu_preempt_data are never used outside kernel/rcu/tree.c and thus can be made static.

Doing so fixes a section mismatch warning reported by clang when building LLVMLinux with -Wsection, because these variables were declared in .data..percpu and defined in .data..percpu..shared_aligned since commit 11bbb235c26f ("rcu: Use DEFINE_PER_CPU_SHARED_ALIGNED for rcu_data").

Quoted 3 lines
Quoted 1 line

Applied, thank you both!

Quoted 4 lines

Nice improvement.

Minor nit: since these are only one line each now, they don't really need a blank line between them, but *shrug*.

I don't mind the grouping implied by the blank lines, but I agree that it is close to the edge.

Thanx, Paul

Quoted 41 lines
Quoted 40 lines
---
 kernel/rcu/tree.c | 2 +-
 kernel/rcu/tree.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
kernel/rcu/tree.c +1 -1
index 233165da782f..e4a607fc5ad0 100644
@@ -91,7 +91,7 @@ static const char *tp_##sname##_varname __used __tracepoint_string = sname##_var
 
 #define RCU_STATE_INITIALIZER(sname, sabbr, cr) \
 DEFINE_RCU_TPS(sname) \
-DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
+static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, sname##_data); \
 struct rcu_state sname##_state = { \
 	.level = { &sname##_state.node[0] }, \
 	.rda = &sname##_data, \
kernel/rcu/tree.h +0 -3
index a69d3dab2ec4..0c32f730d033 100644
@@ -519,14 +519,11 @@ extern struct list_head rcu_struct_flavors;
  * RCU implementation internal declarations:
  */
 extern struct rcu_state rcu_sched_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_sched_data);
 
 extern struct rcu_state rcu_bh_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
 
 #ifdef CONFIG_PREEMPT_RCU
 extern struct rcu_state rcu_preempt_state;
-DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data);
 #endif /* #ifdef CONFIG_PREEMPT_RCU */
 
 #ifdef CONFIG_RCU_BOOST
Signature · 1 line
2.3.6