rcu: Create a function for rcu_nocb_mask boot time setup
PATCH v2 1/2 rcu: Create a function for rcu_nocb_mask boot time setup
This commit creates a function rcu_bootup_announce_oddness_nocb(), which handles allocation of rcu_nocb_mask and setting it according to the kernel configuration parameters.
---
v2: don't break the print string (comment from paulmck)
kernel/rcu/tree_plugin.h | 61 +++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 26 deletions(-)
kernel/rcu/tree_plugin.h +35 -26
@@ -47,6 +47,39 @@ static char __initdata nocb_buf[NR_CPUS * 5];#endif /* #ifdef CONFIG_RCU_NOCB_CPU */ /* +* This is a helper for rcu_bootup_announce_oddness(), which takes care of +* setting up rcu_nocb_mask for nocb specific kernel configuration parameters +*/ +static void __init rcu_bootup_announce_oddness_nocb (void ) +{ +#ifndef CONFIG_RCU_NOCB_CPU_NONE +if (!have_rcu_nocb_mask) { +zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL ); + have_rcu_nocb_mask = true; + } +#ifdef CONFIG_RCU_NOCB_CPU_ZERO +pr_info ("\tOffload RCU callbacks from CPU 0\n" ); +cpumask_set_cpu (0 , rcu_nocb_mask); +#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ZERO */ +#ifdef CONFIG_RCU_NOCB_CPU_ALL +pr_info ("\tOffload RCU callbacks from all CPUs\n" ); +cpumask_copy (rcu_nocb_mask, cpu_possible_mask); +#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ALL */ +#endif /* #ifndef CONFIG_RCU_NOCB_CPU_NONE */ +if (have_rcu_nocb_mask) { +if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) { +pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); +cpumask_and (rcu_nocb_mask, cpu_possible_mask, + rcu_nocb_mask); + } +cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); +pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); +if (rcu_nocb_poll) +pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); + } +} + +/* * Check the RCU kernel configuration parameters and print informative * messages about anything out of the ordinary. If you like #ifdef, you * will love this function.
@@ -86,32 +119,8 @@ static void __init rcu_bootup_announce_oddness(void)if (nr_cpu_ids !=NR_CPUS )pr_info ("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%d.\n" ,NR_CPUS , nr_cpu_ids);#ifdef CONFIG_RCU_NOCB_CPU -#ifndef CONFIG_RCU_NOCB_CPU_NONE -if (!have_rcu_nocb_mask) { -zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL ); - have_rcu_nocb_mask = true; - } -#ifdef CONFIG_RCU_NOCB_CPU_ZERO -pr_info ("\tOffload RCU callbacks from CPU 0\n" ); -cpumask_set_cpu (0 , rcu_nocb_mask); -#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ZERO */ -#ifdef CONFIG_RCU_NOCB_CPU_ALL -pr_info ("\tOffload RCU callbacks from all CPUs\n" ); -cpumask_copy (rcu_nocb_mask, cpu_possible_mask); -#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ALL */ -#endif /* #ifndef CONFIG_RCU_NOCB_CPU_NONE */ -if (have_rcu_nocb_mask) { -if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) { -pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); -cpumask_and (rcu_nocb_mask, cpu_possible_mask, - rcu_nocb_mask); - } -cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); -pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); -if (rcu_nocb_poll) -pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); - } -#endif /* #ifdef CONFIG_RCU_NOCB_CPU */ +rcu_bootup_announce_oddness_nocb (); +#endif }#ifdef CONFIG_TREE_PREEMPT_RCU
Signature · 1 line
2.0.1
PATCH v2 2/2 rcu: Check the return value of rcu_nocb_mask cpumask allocation
This commit checks the return value of the zalloc_cpumask_var() used for allocating cpumask for rcu_nocb_mask.
---
v2: no change from v1
kernel/rcu/tree_plugin.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
kernel/rcu/tree_plugin.h +12 -11
@@ -54,7 +54,10 @@ static void __init rcu_bootup_announce_oddness_nocb(void) {#ifndef CONFIG_RCU_NOCB_CPU_NONE if (!have_rcu_nocb_mask) { -zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL ); +if (!zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL )) { +pr_info ("rcu_nocb_mask allocation failed\n" ); +return ; + } have_rcu_nocb_mask = true; }#ifdef CONFIG_RCU_NOCB_CPU_ZERO
@@ -66,17 +69,15 @@ static void __init rcu_bootup_announce_oddness_nocb(void)cpumask_copy (rcu_nocb_mask, cpu_possible_mask);#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ALL */ #endif /* #ifndef CONFIG_RCU_NOCB_CPU_NONE */ -if (have_rcu_nocb_mask) { -if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) { -pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); -cpumask_and (rcu_nocb_mask, cpu_possible_mask, - rcu_nocb_mask); - } -cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); -pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); -if (rcu_nocb_poll) -pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); +if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) { +pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); +cpumask_and (rcu_nocb_mask, cpu_possible_mask, + rcu_nocb_mask); } +cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); +pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); +if (rcu_nocb_poll) +pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); }/*
Signature · 1 line
2.0.1
Re: [PATCH v2 2/2] rcu: Check the return value of rcu_nocb_mask cpumask allocation
Quoted 4 lines · Pranith Kumar
This commit checks the return value of the
zalloc_cpumask_var()used for allocating cpumask forrcu_nocb_mask.Signed-off-by Pranith Kumar <[email protected]>
Hmmm... I saw the check in the previous patch, but didn't see removal of the later have_rcu_nocb_mask check. Please see below.
Thanx, Paul
Quoted 27 lines
---
v2: no change from v1kernel/rcu/tree_plugin.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)kernel/rcu/tree_plugin.h +4
-2@@ -54,7 +54,10 @@ static void __init rcu_bootup_announce_oddness_nocb(void) {#ifndef CONFIG_RCU_NOCB_CPU_NONE if (!have_rcu_nocb_mask) { -zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL ); +if (!zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL )) { +pr_info ("rcu_nocb_mask allocation failed\n" ); +return ; + } have_rcu_nocb_mask = true; }#ifdef CONFIG_RCU_NOCB_CPU_ZERO @@ -66,17 +69,15 @@ static void __init rcu_bootup_announce_oddness_nocb(void)cpumask_copy (rcu_nocb_mask, cpu_possible_mask);#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ALL */ #endif /* #ifndef CONFIG_RCU_NOCB_CPU_NONE */ -if (have_rcu_nocb_mask) {
kernel/rcu/tree_plugin.h static void __init rcu_bootup_announce_oddness_nocb(void) · line 72
Quoted 10 lines
kernel/rcu/tree_plugin.h +1
-9-if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) { -pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); -cpumask_and (rcu_nocb_mask, cpu_possible_mask, - rcu_nocb_mask); - } -cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); -pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); -if (rcu_nocb_poll) -pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); +if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) {
What happens if CONFIG_RCU_NOCB_CPU_NONE=y and the rcu_nocbs= boot parameter is not specified and we get here?
In order to get visible failures when testing, build with CONFIG_CPUMASK_OFFSTACK=y.
Quoted 14 lines
kernel/rcu/tree_plugin.h +7
-0+pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); +cpumask_and (rcu_nocb_mask, cpu_possible_mask, + rcu_nocb_mask); } +cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); +pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); +if (rcu_nocb_poll) +pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); }/* Signature · 1 line
2.0.1
Re: [PATCH v2 2/2] rcu: Check the return value of rcu_nocb_mask cpumask allocation
Quoted 8 lines · Paul E. McKenney
Quoted 4 lines · Pranith Kumar
This commit checks the return value of the
zalloc_cpumask_var()used for allocating cpumask forrcu_nocb_mask.Signed-off-by Pranith Kumar <[email protected]>Hmmm... I saw the check in the previous patch, but didn't see removal of the later
have_rcu_nocb_maskcheck. Please see below.
And events overtook this one. Turns out that commit b58cc46c5f6b (rcu: Don't offload callbacks unless specifically requested) was not one of my best efforts.
I will adapt your patch 2/2 in this series and apply it with your Signed-off-by. Patch 1/2 is obsoleted by the current fix for commit b58cc46c5f6b.
Thanx, Paul
Quoted 58 lines
Quoted 27 lines
---
v2: no change from v1kernel/rcu/tree_plugin.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)kernel/rcu/tree_plugin.h +4
-2@@ -54,7 +54,10 @@ static void __init rcu_bootup_announce_oddness_nocb(void) {#ifndef CONFIG_RCU_NOCB_CPU_NONE if (!have_rcu_nocb_mask) { -zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL ); +if (!zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL )) { +pr_info ("rcu_nocb_mask allocation failed\n" ); +return ; + } have_rcu_nocb_mask = true; }#ifdef CONFIG_RCU_NOCB_CPU_ZERO @@ -66,17 +69,15 @@ static void __init rcu_bootup_announce_oddness_nocb(void)cpumask_copy (rcu_nocb_mask, cpu_possible_mask);#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ALL */ #endif /* #ifndef CONFIG_RCU_NOCB_CPU_NONE */ -if (have_rcu_nocb_mask) {kernel/rcu/tree_plugin.h static void __init rcu_bootup_announce_oddness_nocb(void) · line 72
Quoted 10 lines
kernel/rcu/tree_plugin.h +1
-9-if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) { -pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); -cpumask_and (rcu_nocb_mask, cpu_possible_mask, - rcu_nocb_mask); - } -cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); -pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); -if (rcu_nocb_poll) -pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); +if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) {What happens if
CONFIG_RCU_NOCB_CPU_NONE=yand the rcu_nocbs= boot parameter is not specified and we get here?In order to get visible failures when testing, build with
CONFIG_CPUMASK_OFFSTACK=y.Quoted 14 lines
kernel/rcu/tree_plugin.h +7
-0+pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); +cpumask_and (rcu_nocb_mask, cpu_possible_mask, + rcu_nocb_mask); } +cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); +pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); +if (rcu_nocb_poll) +pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); }/* Signature · 1 line
2.0.1
Re: [PATCH v2 2/2] rcu: Check the return value of rcu_nocb_mask cpumask allocation
Quoted 10 lines · Paul E. McKenney
Quoted 8 lines · Paul E. McKenney
Quoted 4 lines · Pranith Kumar
This commit checks the return value of the
zalloc_cpumask_var()used for allocating cpumask forrcu_nocb_mask.Signed-off-by Pranith Kumar <[email protected]>Hmmm... I saw the check in the previous patch, but didn't see removal of the later
have_rcu_nocb_maskcheck. Please see below.
Quoted 8 lines
And events overtook this one. Turns out that commit
b58cc46c5f6b(rcu: Don't offload callbacks unless specifically requested) was not one of my best efforts.I will adapt your patch 2/2 in this series and apply it with your Signed-off-by. Patch 1/2 is obsoleted by the current fix for commit
b58cc46c5f6b.
OK. I am curious to see what problem you found in that commit. I look forward to see your updated patch.
Quoted 59 lines
Quoted 58 lines
Quoted 27 lines
---
v2: no change from v1kernel/rcu/tree_plugin.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)kernel/rcu/tree_plugin.h +4
-2@@ -54,7 +54,10 @@ static void __init rcu_bootup_announce_oddness_nocb(void) {#ifndef CONFIG_RCU_NOCB_CPU_NONE if (!have_rcu_nocb_mask) { -zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL ); +if (!zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL )) { +pr_info ("rcu_nocb_mask allocation failed\n" ); +return ; + } have_rcu_nocb_mask = true; }#ifdef CONFIG_RCU_NOCB_CPU_ZERO @@ -66,17 +69,15 @@ static void __init rcu_bootup_announce_oddness_nocb(void)cpumask_copy (rcu_nocb_mask, cpu_possible_mask);#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ALL */ #endif /* #ifndef CONFIG_RCU_NOCB_CPU_NONE */ -if (have_rcu_nocb_mask) {kernel/rcu/tree_plugin.h static void __init rcu_bootup_announce_oddness_nocb(void) · line 72
Quoted 10 lines
kernel/rcu/tree_plugin.h +1
-9-if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) { -pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); -cpumask_and (rcu_nocb_mask, cpu_possible_mask, - rcu_nocb_mask); - } -cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); -pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); -if (rcu_nocb_poll) -pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); +if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) {What happens if
CONFIG_RCU_NOCB_CPU_NONE=yand the rcu_nocbs= boot parameter is not specified and we get here?In order to get visible failures when testing, build with
CONFIG_CPUMASK_OFFSTACK=y.Quoted 14 lines
kernel/rcu/tree_plugin.h +7
-1+pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); +cpumask_and (rcu_nocb_mask, cpu_possible_mask, + rcu_nocb_mask); } +cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); +pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); +if (rcu_nocb_poll) +pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); }/* -- 2.0.1
Signature · 1 line
Pranith
Quoted 5 lines · Pranith Kumar
This commit creates a function
rcu_bootup_announce_oddness_nocb(), which handles allocation ofrcu_nocb_maskand setting it according to the kernel configuration parameters.Signed-off-by Pranith Kumar <[email protected]>
Much better!
One more change called out below.
Thanx, Paul
Quoted 51 lines
---
v2: don't break the print string (comment from paulmck)kernel/rcu/tree_plugin.h | 61 +++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 26 deletions(-)kernel/rcu/tree_plugin.h +33
-0@@ -47,6 +47,39 @@ static char __initdata nocb_buf[NR_CPUS * 5];#endif /* #ifdef CONFIG_RCU_NOCB_CPU */ /* +* This is a helper for rcu_bootup_announce_oddness(), which takes care of +* setting up rcu_nocb_mask for nocb specific kernel configuration parameters +*/ +static void __init rcu_bootup_announce_oddness_nocb (void ) +{ +#ifndef CONFIG_RCU_NOCB_CPU_NONE +if (!have_rcu_nocb_mask) { +zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL ); + have_rcu_nocb_mask = true; + } +#ifdef CONFIG_RCU_NOCB_CPU_ZERO +pr_info ("\tOffload RCU callbacks from CPU 0\n" ); +cpumask_set_cpu (0 , rcu_nocb_mask); +#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ZERO */ +#ifdef CONFIG_RCU_NOCB_CPU_ALL +pr_info ("\tOffload RCU callbacks from all CPUs\n" ); +cpumask_copy (rcu_nocb_mask, cpu_possible_mask); +#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ALL */ +#endif /* #ifndef CONFIG_RCU_NOCB_CPU_NONE */ +if (have_rcu_nocb_mask) { +if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) { +pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); +cpumask_and (rcu_nocb_mask, cpu_possible_mask, + rcu_nocb_mask); + } +cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); +pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); +if (rcu_nocb_poll) +pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); + } +} + +/* * Check the RCU kernel configuration parameters and print informative * messages about anything out of the ordinary. If you like #ifdef, you * will love this function.
kernel/rcu/tree_plugin.h static void __init rcu_bootup_announce_oddness(void) · line 121
Quoted 3 lines
kernel/rcu/tree_plugin.h +0
-0@@ -86,32 +119,8 @@ static void __init rcu_bootup_announce_oddness(void)if (nr_cpu_ids !=NR_CPUS )pr_info ("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%d.\n" ,NR_CPUS , nr_cpu_ids);#ifdef CONFIG_RCU_NOCB_CPU
Please also move the above #ifdef into rcu_bootup_announce_oddness_nocb(). The compiler will inline the resulting empty function, and it is cleaner to have all of the NOCB-related #ifdefs in that function.
Quoted 34 lines
kernel/rcu/tree_plugin.h +2
-26-#ifndef CONFIG_RCU_NOCB_CPU_NONE -if (!have_rcu_nocb_mask) { -zalloc_cpumask_var (&rcu_nocb_mask,GFP_KERNEL ); - have_rcu_nocb_mask = true; - } -#ifdef CONFIG_RCU_NOCB_CPU_ZERO -pr_info ("\tOffload RCU callbacks from CPU 0\n" ); -cpumask_set_cpu (0 , rcu_nocb_mask); -#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ZERO */ -#ifdef CONFIG_RCU_NOCB_CPU_ALL -pr_info ("\tOffload RCU callbacks from all CPUs\n" ); -cpumask_copy (rcu_nocb_mask, cpu_possible_mask); -#endif /* #ifdef CONFIG_RCU_NOCB_CPU_ALL */ -#endif /* #ifndef CONFIG_RCU_NOCB_CPU_NONE */ -if (have_rcu_nocb_mask) { -if (!cpumask_subset (rcu_nocb_mask, cpu_possible_mask)) { -pr_info ("\tNote: kernel parameter 'rcu_nocbs=' contains nonexistent CPUs.\n" ); -cpumask_and (rcu_nocb_mask, cpu_possible_mask, - rcu_nocb_mask); - } -cpulist_scnprintf (nocb_buf,sizeof (nocb_buf), rcu_nocb_mask); -pr_info ("\tOffload RCU callbacks from CPUs: %s.\n" , nocb_buf); -if (rcu_nocb_poll) -pr_info ("\tPoll for callbacks from no-CBs CPUs.\n" ); - } -#endif /* #ifdef CONFIG_RCU_NOCB_CPU */ +rcu_bootup_announce_oddness_nocb (); +#endif }#ifdef CONFIG_TREE_PREEMPT_RCU Signature · 1 line
2.0.1