rcutorture: Traverse possible cpu to set maxcpu in rcu_nocb_toggle()
Subsystems (2)
PATCH 1/1 rcutorture: Traverse possible cpu to set maxcpu in rcu_nocb_toggle()
Currently, the maxcpu is set by traversing online CPUs, however, if the rcutorture.onoff_holdoff is set zero and onoff_interval is set non-zero, and the some CPUs with larger cpuid has been offline before setting maxcpu, for these CPUs, even if they are online again, also cannot be offload or deoffload.
This commit therefore use for_each_possible_cpu() instead of for_each_online_cpu() in rcu_nocb_toggle().
--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcutorture.c +1 -1
@@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg)VERBOSE_TOROUT_STRING ("rcu_nocb_toggle task started" );while (!rcu_inkernel_boot_has_ended ())schedule_timeout_interruptible (HZ /10 ); -for_each_online_cpu (cpu) +for_each_possible_cpu (cpu) maxcpu = cpu;WARN_ON (maxcpu <0 );if (toggle_interval >ULONG_MAX )
Signature · 1 line
2.17.1
Sorry for the repeat sending.
Quoted 31 lines
Currently, the maxcpu is set by traversing online CPUs, however, if the rcutorture.onoff_holdoff is set zero and
onoff_intervalis set non-zero, and the some CPUs with larger cpuid has been offline before setting maxcpu, for these CPUs, even if they are online again, also cannot be offload or deoffload.This commit therefore use
for_each_possible_cpu()instead offor_each_online_cpu()inrcu_nocb_toggle().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcutorture.c +1
-2@@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg)VERBOSE_TOROUT_STRING ("rcu_nocb_toggle task started" );while (!rcu_inkernel_boot_has_ended ())schedule_timeout_interruptible (HZ /10 ); -for_each_online_cpu (cpu) +for_each_possible_cpu (cpu) maxcpu = cpu;WARN_ON (maxcpu <0 );if (toggle_interval >ULONG_MAX ) --2.17.1
Paul E. McKenney
maintainerQuoted 19 lines · Zqiang
Currently, the maxcpu is set by traversing online CPUs, however, if the rcutorture.onoff_holdoff is set zero and
onoff_intervalis set non-zero, and the some CPUs with larger cpuid has been offline before setting maxcpu, for these CPUs, even if they are online again, also cannot be offload or deoffload.This commit therefore use
for_each_possible_cpu()instead offor_each_online_cpu()inrcu_nocb_toggle().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcutorture.c +0
-0
kernel/rcu/rcutorture.c static int rcu_nocb_toggle(void *arg) · line 2134
Quoted 5 lines
kernel/rcu/rcutorture.c +1
-1@@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg)VERBOSE_TOROUT_STRING ("rcu_nocb_toggle task started" );while (!rcu_inkernel_boot_has_ended ())schedule_timeout_interruptible (HZ /10 ); -for_each_online_cpu (cpu) +for_each_possible_cpu (cpu)
Last I checked, bad things could happen if the code attempted to nocb_toggle a CPU that had not yet come online. Has that changed?
Thanx, Paul
Quoted 6 lines
kernel/rcu/rcutorture.c +0
-0maxcpu = cpu;WARN_ON (maxcpu <0 );if (toggle_interval >ULONG_MAX )Signature · 1 line
2.17.1
Quoted 16 lines · Zqiang
Quoted 14 lines
Currently, the maxcpu is set by traversing online CPUs, however, if the rcutorture.onoff_holdoff is set zero and
onoff_intervalis set non-zero, and the some CPUs with larger cpuid has been offline before setting maxcpu, for these CPUs, even if they are online again, also cannot be offload or deoffload.This commit therefore use
for_each_possible_cpu()instead offor_each_online_cpu()inrcu_nocb_toggle().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
kernel/rcu/rcutorture.c static int rcu_nocb_toggle(void *arg) · line 2134
Quoted 10 lines
kernel/rcu/rcutorture.c +1
-1@@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg)VERBOSE_TOROUT_STRING ("rcu_nocb_toggle task started" );while (!rcu_inkernel_boot_has_ended ())schedule_timeout_interruptible (HZ /10 ); -for_each_online_cpu (cpu) +for_each_possible_cpu (cpu)Last I checked, bad things could happen if the code attempted to
nocb_togglea CPU that had not yet come online. Has that changed?
For example, there are 8 online CPUs in the system, before we traversing online CPUs and set maxcpu, CPU7 has been offline, this causes us to miss nocb_toggle for CPU7(maxcpu=6)
Even though we still use for_each_online_cpu(), the things described above also happen. before we toggle the CPU, this CPU has been offline.
Thanks
Zqiang
Quoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/rcutorture.c +0
-1maxcpu = cpu;WARN_ON (maxcpu <0 );if (toggle_interval >ULONG_MAX ) --2.17.1
Paul E. McKenney
maintainerQuoted 30 lines · Z qiang
Quoted 16 lines · Zqiang
Quoted 14 lines
Currently, the maxcpu is set by traversing online CPUs, however, if the rcutorture.onoff_holdoff is set zero and
onoff_intervalis set non-zero, and the some CPUs with larger cpuid has been offline before setting maxcpu, for these CPUs, even if they are online again, also cannot be offload or deoffload.This commit therefore use
for_each_possible_cpu()instead offor_each_online_cpu()inrcu_nocb_toggle().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
kernel/rcu/rcutorture.c static int rcu_nocb_toggle(void *arg) · line 2134
Quoted 10 lines
kernel/rcu/rcutorture.c +1
-1@@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg)VERBOSE_TOROUT_STRING ("rcu_nocb_toggle task started" );while (!rcu_inkernel_boot_has_ended ())schedule_timeout_interruptible (HZ /10 ); -for_each_online_cpu (cpu) +for_each_possible_cpu (cpu)Last I checked, bad things could happen if the code attempted to
nocb_togglea CPU that had not yet come online. Has that changed?
Quoted 6 lines
For example, there are 8 online CPUs in the system, before we traversing online CPUs and set maxcpu, CPU7 has been offline, this causes us to miss
nocb_togglefor CPU7(maxcpu=6)Even though we still use
for_each_online_cpu(), the things described above also happen. before we toggle the CPU, this CPU has been offline.
Suppose we have a system whose possible CPUs are 0, 1, 2, and 3. However, only 0 and 1 are present in this system, and until some manual action is taken, only 0 and 1 will ever be online. (Yes, this really can happen!) In that state, won't toggling CPU 2 and 3 result in failures?
Thanx, Paul
Quoted 13 lines
Thanks
ZqiangQuoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/rcutorture.c +0
-1maxcpu = cpu;WARN_ON (maxcpu <0 );if (toggle_interval >ULONG_MAX ) --2.17.1
Quoted 36 lines · Z qiang
Quoted 34 lines
Quoted 16 lines · Zqiang
Quoted 14 lines
Currently, the maxcpu is set by traversing online CPUs, however, if the rcutorture.onoff_holdoff is set zero and
onoff_intervalis set non-zero, and the some CPUs with larger cpuid has been offline before setting maxcpu, for these CPUs, even if they are online again, also cannot be offload or deoffload.This commit therefore use
for_each_possible_cpu()instead offor_each_online_cpu()inrcu_nocb_toggle().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
kernel/rcu/rcutorture.c static int rcu_nocb_toggle(void *arg) · line 2134
Quoted 10 lines
kernel/rcu/rcutorture.c +1
-1@@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg)VERBOSE_TOROUT_STRING ("rcu_nocb_toggle task started" );while (!rcu_inkernel_boot_has_ended ())schedule_timeout_interruptible (HZ /10 ); -for_each_online_cpu (cpu) +for_each_possible_cpu (cpu)Last I checked, bad things could happen if the code attempted to
nocb_togglea CPU that had not yet come online. Has that changed?For example, there are 8 online CPUs in the system, before we traversing online CPUs and set maxcpu, CPU7 has been offline, this causes us to miss
nocb_togglefor CPU7(maxcpu=6)
Quoted 8 lines
Quoted 2 lines
Even though we still use
for_each_online_cpu(), the things described above also happen. before we toggle the CPU, this CPU has been offline.Suppose we have a system whose possible CPUs are 0, 1, 2, and 3. However, only 0 and 1 are present in this system, and until some manual action is taken, only 0 and 1 will ever be online. (Yes, this really can happen!) In that state, won't toggling CPU 2 and 3 result in failures?
Agree.
As long as we enabled rcutorture.onoff_interval, regardless of whether we use online CPUs or possible CPUs to set maxcpu, It is all possible to toggling the CPUs failure
and print "NOCB: Cannot CB-offload offline CPU" log. but the failures due to CPU offline are acceptable.
but at least the toggling operation on CPU7 will not be missed. when CPU7 comes online again.
Would it be better to use for_each_present_cpu() ?
Thanks
Zqiang
Quoted 16 lines
Thanx, Paul
Quoted 13 lines
Thanks
ZqiangQuoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/rcutorture.c +0
-1maxcpu = cpu;WARN_ON (maxcpu <0 );if (toggle_interval >ULONG_MAX ) --2.17.1
Paul E. McKenney
maintainerQuoted 52 lines · Z qiang
Quoted 36 lines · Z qiang
Quoted 34 lines
Quoted 16 lines · Zqiang
Quoted 14 lines
Currently, the maxcpu is set by traversing online CPUs, however, if the rcutorture.onoff_holdoff is set zero and
onoff_intervalis set non-zero, and the some CPUs with larger cpuid has been offline before setting maxcpu, for these CPUs, even if they are online again, also cannot be offload or deoffload.This commit therefore use
for_each_possible_cpu()instead offor_each_online_cpu()inrcu_nocb_toggle().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
kernel/rcu/rcutorture.c static int rcu_nocb_toggle(void *arg) · line 2134
Quoted 10 lines
kernel/rcu/rcutorture.c +1
-1@@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg)VERBOSE_TOROUT_STRING ("rcu_nocb_toggle task started" );while (!rcu_inkernel_boot_has_ended ())schedule_timeout_interruptible (HZ /10 ); -for_each_online_cpu (cpu) +for_each_possible_cpu (cpu)Last I checked, bad things could happen if the code attempted to
nocb_togglea CPU that had not yet come online. Has that changed?For example, there are 8 online CPUs in the system, before we traversing online CPUs and set maxcpu, CPU7 has been offline, this causes us to miss
nocb_togglefor CPU7(maxcpu=6)Quoted 8 lines
Quoted 2 lines
Even though we still use
for_each_online_cpu(), the things described above also happen. before we toggle the CPU, this CPU has been offline.Suppose we have a system whose possible CPUs are 0, 1, 2, and 3. However, only 0 and 1 are present in this system, and until some manual action is taken, only 0 and 1 will ever be online. (Yes, this really can happen!) In that state, won't toggling CPU 2 and 3 result in failures?
Agree.
As long as we enabled rcutorture.onoff_interval, regardless of whether we use online CPUs or possible CPUs to set maxcpu, It is all possible to toggling the CPUs failure
and print "NOCB: Cannot CB-offload offline CPU" log. but the failures due to CPU offline are acceptable.
Quoted 4 lines
but at least the toggling operation on CPU7 will not be missed. when CPU7 comes online again.
Would it be better to use
for_each_present_cpu()?
The problem we face is that RCU and rcutorture have no reasonable way of knowing when the boot-time CPU bringup has completed. If there was a way of knowing that, then my approach would be to make rcutorture react to a holdoff of zero by waiting for all the CPUs to come online.
Failing that, for_each_present_cpu() with a holdoff of zero will likely get us transient failures between the time rcutorture starts and the last CPU has come online.
Or is there now a way for in-kernel code know when boot-time CPU onlining has completed?
Thanx, Paul
Quoted 19 lines
Thanks
ZqiangQuoted 16 lines
Thanx, Paul
Quoted 13 lines
Thanks
ZqiangQuoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/rcutorture.c +0
-1maxcpu = cpu;WARN_ON (maxcpu <0 );if (toggle_interval >ULONG_MAX ) --2.17.1
Frederic Weisbecker
maintainerQuoted 63 lines · Paul E. McKenney
Quoted 52 lines · Z qiang
Quoted 36 lines · Z qiang
Quoted 34 lines
Quoted 16 lines · Zqiang
Quoted 14 lines
Currently, the maxcpu is set by traversing online CPUs, however, if the rcutorture.onoff_holdoff is set zero and
onoff_intervalis set non-zero, and the some CPUs with larger cpuid has been offline before setting maxcpu, for these CPUs, even if they are online again, also cannot be offload or deoffload.This commit therefore use
for_each_possible_cpu()instead offor_each_online_cpu()inrcu_nocb_toggle().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
kernel/rcu/rcutorture.c static int rcu_nocb_toggle(void *arg) · line 2134
Quoted 10 lines
kernel/rcu/rcutorture.c +1
-1@@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg)VERBOSE_TOROUT_STRING ("rcu_nocb_toggle task started" );while (!rcu_inkernel_boot_has_ended ())schedule_timeout_interruptible (HZ /10 ); -for_each_online_cpu (cpu) +for_each_possible_cpu (cpu)Last I checked, bad things could happen if the code attempted to
nocb_togglea CPU that had not yet come online. Has that changed?For example, there are 8 online CPUs in the system, before we traversing online CPUs and set maxcpu, CPU7 has been offline, this causes us to miss
nocb_togglefor CPU7(maxcpu=6)Quoted 8 lines
Quoted 2 lines
Even though we still use
for_each_online_cpu(), the things described above also happen. before we toggle the CPU, this CPU has been offline.Suppose we have a system whose possible CPUs are 0, 1, 2, and 3. However, only 0 and 1 are present in this system, and until some manual action is taken, only 0 and 1 will ever be online. (Yes, this really can happen!) In that state, won't toggling CPU 2 and 3 result in failures?
Agree.
As long as we enabled rcutorture.onoff_interval, regardless of whether we use online CPUs or possible CPUs to set maxcpu, It is all possible to toggling the CPUs failure
and print "NOCB: Cannot CB-offload offline CPU" log. but the failures due to CPU offline are acceptable.Quoted 4 lines
but at least the toggling operation on CPU7 will not be missed. when CPU7 comes online again.
Would it be better to use
for_each_present_cpu()?The problem we face is that RCU and rcutorture have no reasonable way of knowing when the boot-time CPU bringup has completed. If there was a way of knowing that, then my approach would be to make rcutorture react to a holdoff of zero by waiting for all the CPUs to come online.
Quoted 6 lines
Failing that,
for_each_present_cpu()with a holdoff of zero will likely get us transient failures between the time rcutorture starts and the last CPU has come online.Or is there now a way for in-kernel code know when boot-time CPU onlining has completed?
We don't need to wait for all CPUs to be online though. Toggling already handles well failures due to offline CPUs and since toggling happens concurrently with offlining in rcutorture, we already see lots of failures reported in the logs.
Thanks.
Quoted 72 lines · Frederic Weisbecker
Quoted 67 lines · Paul E. McKenney
Quoted 52 lines · Z qiang
Quoted 36 lines · Z qiang
Quoted 34 lines
Quoted 34 lines
Quoted 16 lines · Zqiang
Quoted 14 lines
Currently, the maxcpu is set by traversing online CPUs, however, if the rcutorture.onoff_holdoff is set zero and
onoff_intervalis set non-zero, and the some CPUs with larger cpuid has been offline before setting maxcpu, for these CPUs, even if they are online again, also cannot be offload or deoffload.This commit therefore use
for_each_possible_cpu()instead offor_each_online_cpu()inrcu_nocb_toggle().Signed-off-by Zqiang <[email protected]>---
kernel/rcu/rcutorture.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
kernel/rcu/rcutorture.c static int rcu_nocb_toggle(void *arg) · line 2134
Quoted 10 lines
kernel/rcu/rcutorture.c +1
-1@@ -2131,7 +2131,7 @@ static int rcu_nocb_toggle(void *arg)VERBOSE_TOROUT_STRING ("rcu_nocb_toggle task started" );while (!rcu_inkernel_boot_has_ended ())schedule_timeout_interruptible (HZ /10 ); -for_each_online_cpu (cpu) +for_each_possible_cpu (cpu)Last I checked, bad things could happen if the code attempted to
nocb_togglea CPU that had not yet come online. Has that changed?For example, there are 8 online CPUs in the system, before we traversing online CPUs and set maxcpu, CPU7 has been offline, this causes us to miss
nocb_togglefor CPU7(maxcpu=6)Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Even though we still use
for_each_online_cpu(), the things described above also happen. before we toggle the CPU, this CPU has been offline.Suppose we have a system whose possible CPUs are 0, 1, 2, and 3. However, only 0 and 1 are present in this system, and until some manual action is taken, only 0 and 1 will ever be online. (Yes, this really can happen!) In that state, won't toggling CPU 2 and 3 result in failures?
Agree.
As long as we enabled rcutorture.onoff_interval, regardless of whether we use online CPUs or possible CPUs to set maxcpu, It is all possible to toggling the CPUs failure
and print "NOCB: Cannot CB-offload offline CPU" log. but the failures due to CPU offline are acceptable.Quoted 4 lines
but at least the toggling operation on CPU7 will not be missed. when CPU7 comes online again.
Would it be better to use
for_each_present_cpu()?The problem we face is that RCU and rcutorture have no reasonable way of knowing when the boot-time CPU bringup has completed. If there was a way of knowing that, then my approach would be to make rcutorture react to a holdoff of zero by waiting for all the CPUs to come online.
Failing that,
for_each_present_cpu()with a holdoff of zero will likely get us transient failures between the time rcutorture starts and the last CPU has come online.
Quoted 7 lines
Quoted 2 lines
Or is there now a way for in-kernel code know when boot-time CPU onlining has completed?
We don't need to wait for all CPUs to be online though. Toggling already handles well failures due to offline CPUs and since toggling happens concurrently with offlining in rcutorture, we already see lots of failures reported in the logs.
I think the issue is the loop later in the function does not try to toggle cpus that came online too late.
So it does not test offloading on all CPUs just because max got updated too late.
One fix could be to periodically check in the loop if a new cpu at maxcpu + 1 ever got onlined. If it did, update the maxcpu.
Thanks.
Quoted 2 lines
Thanks.
Frederic Weisbecker
maintainerQuoted 5 lines · Joel Fernandes
I think the issue is the loop later in the function does not try to toggle cpus that came online too late.
So it does not test offloading on all CPUs just because max got updated too late.
Right, and therefore for_each_possible_cpu() or for_each_present_cpu() should be fine to iterate since it's ok to try to toggle an offline CPU.
Quoted 3 lines
One fix could be to periodically check in the loop if a new cpu at maxcpu + 1 ever got onlined. If it did, update the maxcpu.
Is it worth the complication though?
Thanks.
Quoted 6 lines
Thanks.
Quoted 2 lines
Thanks.
Quoted 13 lines · Frederic Weisbecker
Quoted 5 lines · Joel Fernandes
I think the issue is the loop later in the function does not try to toggle cpus that came online too late.
So it does not test offloading on all CPUs just because max got updated too late.
Right, and therefore
for_each_possible_cpu()orfor_each_present_cpu()should be fine to iterate since it's ok to try to toggle an offline CPU.
Ah I see what you mean, sounds good.
Quoted 6 lines
Quoted 4 lines
One fix could be to periodically check in the loop if a new cpu at maxcpu + 1 ever got onlined. If it did, update the maxcpu.
Is it worth the complication though?
Probably not and so your suggestion sounds fine.
Thanks!
- Joel
Quoted 9 lines
Thanks.
Quoted 6 lines
Thanks.
Quoted 2 lines
Thanks.
Paul E. McKenney
maintainerQuoted 9 lines · Frederic Weisbecker
Quoted 5 lines · Joel Fernandes
I think the issue is the loop later in the function does not try to toggle cpus that came online too late.
So it does not test offloading on all CPUs just because max got updated too late.
Right, and therefore
for_each_possible_cpu()orfor_each_present_cpu()should be fine to iterate since it's ok to try to toggle an offline CPU.
OK, so I will accept the original patch which did just that.
Thank you!
I recently got burned by lack of workqueues on a not-yet-onlined CPU, hence my questions here. ;-)
Thanx, Paul
Quoted 13 lines
Quoted 2 lines
One fix could be to periodically check in the loop if a new cpu at maxcpu + 1 ever got onlined. If it did, update the maxcpu.
Is it worth the complication though?
Thanks.
Quoted 6 lines
Thanks.
Quoted 2 lines
Thanks.
Paul E. McKenney
maintainerQuoted 5 lines · Paul E. McKenney
Quoted 4 lines · Frederic Weisbecker
Quoted 3 lines · Joel Fernandes
I think the issue is the loop later in the function does not try to toggle cpus that came online too late.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
So it does not test offloading on all CPUs just because max got updated too late.
Right, and therefore
for_each_possible_cpu()orfor_each_present_cpu()should be fine to iterate since it's ok to try to toggle an offline CPU.OK, so I will accept the original patch which did just that.
Which I finally did. I took the liberty of adding Frederic's Reviewed-by, but please let me know if this is in any way inappropriate.
Thanx, Paul
Quoted 20 lines
Thank you!
I recently got burned by lack of workqueues on a not-yet-onlined CPU, hence my questions here. ;-)
Thanx, Paul
Quoted 13 lines
Quoted 2 lines
One fix could be to periodically check in the loop if a new cpu at maxcpu + 1 ever got onlined. If it did, update the maxcpu.
Is it worth the complication though?
Thanks.
Quoted 6 lines
Thanks.
Quoted 2 lines
Thanks.