rcu: declare rcu_data variables in the section they are defined in
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
@@ -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
Quoted 10 lines · Nicolas Iooss
Commit
11bbb235c26f("rcu: UseDEFINE_PER_CPU_SHARED_ALIGNEDforrcu_data") replacedDEFINE_PER_CPUbyDEFINE_PER_CPU_SHARED_ALIGNEDin the definition ofrcu_schedandrcu_bhwithout updatingkernel/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.
Signed-off-by Nicolas Iooss <[email protected]>
Good catch.
Quoted 24 lines
--- kernel/rcu/tree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/rcu/tree.h +2
-2@@ -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
Quoted 6 lines · Josh Triplett
Quoted 5 lines · Nicolas Iooss
Commit
11bbb235c26f("rcu: UseDEFINE_PER_CPU_SHARED_ALIGNEDforrcu_data") replacedDEFINE_PER_CPUbyDEFINE_PER_CPU_SHARED_ALIGNEDin the definition ofrcu_schedandrcu_bhwithout updatingkernel/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.
Signed-off-by Nicolas Iooss <[email protected]>Good catch.
Reviewed-by Josh Triplett <[email protected]>
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
@@ -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);
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Josh Triplett
Quoted 9 lines · Nicolas Iooss
Commit
11bbb235c26f("rcu: UseDEFINE_PER_CPU_SHARED_ALIGNEDforrcu_data") replacedDEFINE_PER_CPUbyDEFINE_PER_CPU_SHARED_ALIGNEDin the definition ofrcu_schedandrcu_bhwithout updatingkernel/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
Signed-off-by Nicolas Iooss <[email protected]>Good catch.
Reviewed-by Josh Triplett <[email protected]>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.cnow 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
Quoted 27 lines · Nicolas Iooss
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Josh Triplett
Quoted 9 lines · Nicolas Iooss
Commit
11bbb235c26f("rcu: UseDEFINE_PER_CPU_SHARED_ALIGNEDforrcu_data") replacedDEFINE_PER_CPUbyDEFINE_PER_CPU_SHARED_ALIGNEDin the definition ofrcu_schedandrcu_bhwithout updatingkernel/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
Signed-off-by Nicolas Iooss <[email protected]>Good catch.
Reviewed-by Josh Triplett <[email protected]>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 selectsCONFIG_PREEMPT_NONEinstead).Quoted 3 lines
Also, given that
tree_trace.cnow 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, becausekernel/rcu/tree_trace.cusesrcu_preempt_state(in v4.1-rc2). I've successfully built an allmodconfig+CONFIG_PREEMPT kernel forx86_64with 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
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
@@ -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
Signature · 1 line
2.3.6
Re: [PATCH] rcu: make rcu_*_data variables static
Quoted 10 lines · Nicolas Iooss
rcu_bh_data,rcu_sched_dataandrcu_preempt_dataare never used outsidekernel/rcu/tree.cand 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: UseDEFINE_PER_CPU_SHARED_ALIGNEDforrcu_data").Signed-off-by Nicolas Iooss <[email protected]>
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@@ -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 Signature · 1 line
2.3.6
Paul E. McKenney
AppliedRe: [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_dataandrcu_preempt_dataare never used outsidekernel/rcu/tree.cand 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: UseDEFINE_PER_CPU_SHARED_ALIGNEDforrcu_data").
Quoted 3 lines
Quoted 1 line
Signed-off-by Nicolas Iooss <[email protected]>Reviewed-by Josh Triplett <[email protected]>
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@@ -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 Signature · 1 line
2.3.6