return NOTIFY_BAD in cpu down call back to stop offlining the cpu
RFC PATCH 1/1 return NOTIFY_BAD in cpu down call back to stop offlining the cpu
In tick_nohz_cpu_down_callback() if the cpu is the one handling timekeeping , it seems that we should return something that could stop notify CPU_DOWN_PREPARE, and then start notify CPU_DOWN_FAILED on the already called notifier call backs.
-EINVAL will be converted to 0 by notifier_to_errno(), then the cpu would be taken down with part of the DOWN_PREPARE notifier callbacks called, and something bad could happen after that.
--- kernel/time/tick-sched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/time/tick-sched.c +1 -1
@@ -306,7 +306,7 @@ static int __cpuinit tick_nohz_cpu_down_callback(struct notifier_block *nfb,* we can't safely shutdown that CPU. */ if (have_nohz_full_mask && tick_do_timer_cpu == cpu) -return -EINVAL ; +return NOTIFY_BAD ;break ; }return NOTIFY_OK ;
Signature · 1 line
1.7.1
Quoted 6 lines · Li Zhong
In
tick_nohz_cpu_down_callback()if the cpu is the one handling timekeeping , it seems that we should return something that could stop notifyCPU_DOWN_PREPARE, and then start notifyCPU_DOWN_FAILEDon the already called notifier call backs.
-EINVALwill be converted to 0 bynotifier_to_errno(),
This above line is not relevant here, because notifier_call_chain() doesn't use notifier_to/from_errno(). It simply uses a straight-forward check like this:
if ((ret & NOTIFY_STOP_MASK) == NOTIFY_STOP_MASK)
break;
Quoted 6 lines
then the cpu
would be taken down with part of theDOWN_PREPAREnotifier callbacks called, and something bad could happen after that.Signed-off-by Li Zhong <[email protected]>---
Quoted 9 lines
kernel/time/tick-sched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)kernel/time/tick-sched.c +0
-0
kernel/time/tick-sched.c static int __cpuinit tick_nohz_cpu_down_callback(struct notifier_block *nfb, · line 312
Quoted 8 lines
kernel/time/tick-sched.c +1
-1@@ -306,7 +306,7 @@ static int __cpuinit tick_nohz_cpu_down_callback(struct notifier_block *nfb,* we can't safely shutdown that CPU. */ if (have_nohz_full_mask && tick_do_timer_cpu == cpu) -return -EINVAL ; +return NOTIFY_BAD ;break ; }return NOTIFY_OK ;
Regards,
Srivatsa S. Bhat
Frederic Weisbecker
Applied2013/5/20 Srivatsa S. Bhat <[email protected]>:
Quoted 15 lines · Li Zhong
Quoted 6 lines
In
tick_nohz_cpu_down_callback()if the cpu is the one handling timekeeping , it seems that we should return something that could stop notifyCPU_DOWN_PREPARE, and then start notifyCPU_DOWN_FAILEDon the already called notifier call backs.
-EINVALwill be converted to 0 bynotifier_to_errno(),This above line is not relevant here, because
notifier_call_chain()doesn't use notifier_to/from_errno(). It simply uses a straight-forward check like this:if ((ret &
NOTIFY_STOP_MASK) ==NOTIFY_STOP_MASK)break;
Quoted 8 lines
Quoted 6 lines
then the cpu
would be taken down with part of theDOWN_PREPAREnotifier callbacks called, and something bad could happen after that.Signed-off-by Li Zhong <[email protected]>---
Reviewed-by Srivatsa S. Bhat <[email protected]>
I applied the patch and will send to Ingo, thanks guys!
Quoted 22 lines
Quoted 10 lines
kernel/time/tick-sched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)kernel/time/tick-sched.c +0
-0kernel/time/tick-sched.c static int __cpuinit tick_nohz_cpu_down_callback(struct notifier_block *nfb, · line 312
Quoted 8 lines
kernel/time/tick-sched.c +1
-1@@ -306,7 +306,7 @@ static int __cpuinit tick_nohz_cpu_down_callback(struct notifier_block *nfb,* we can't safely shutdown that CPU. */ if (have_nohz_full_mask && tick_do_timer_cpu == cpu) -return -EINVAL ; +return NOTIFY_BAD ;break ; }return NOTIFY_OK ;Regards,
Srivatsa S. Bhat