rcu/tree: Fix self wakeups for grace period kthread
PATCH 1/1 rcu/tree: Fix self wakeups for grace period kthread
Update the code to match the comment that self wakeup of grace period kthread is allowed from interrupt handler, and softirq handler, running in the grace period kthread's context. Present code allows self wakeups from all interrupt contexts - nmi, softirq and hardirq contexts.
--- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
@@ -1585,7 +1585,7 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp)static void rcu_gp_kthread_wake (void ) {if ((current == rcu_state.gp_kthread && - !in_interrupt () && !in_serving_softirq ()) || + !in_irq () && !in_serving_softirq ()) || !READ_ONCE (rcu_state.gp_flags) || !rcu_state.gp_kthread)return ;
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
Steven Rostedt
reviewerQuoted 5 lines · On Fri, 8 Mar 2019 15:16:18 +0530 Neeraj Upadhyay <[email protected]>…
Update the code to match the comment that self wakeup of grace period kthread is allowed from interrupt handler, and softirq handler, running in the grace period kthread's context. Present code allows self wakeups from all interrupt contexts - nmi, softirq and hardirq contexts.
That's not actually the issue. But it appears that we return if we simply have BH disabled, which I don't think we want, and we don't care about NMI as NMI should never call this code.
I think your patch is correct, but the change log is not.
-- Steve
Quoted 19 lines
Signed-off-by Neeraj Upadhyay <[email protected]>--- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tree.c +1
-1@@ -1585,7 +1585,7 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp)static void rcu_gp_kthread_wake (void ) {if ((current == rcu_state.gp_kthread && - !in_interrupt () && !in_serving_softirq ()) || + !in_irq () && !in_serving_softirq ()) || !READ_ONCE (rcu_state.gp_flags) || !rcu_state.gp_kthread)return ;
Quoted 9 lines · Steven Rostedt
Quoted 5 lines · On Fri, 8 Mar 2019 15:16:18 +0530 Neeraj Upadhyay <[email protected]>…
Update the code to match the comment that self wakeup of grace period kthread is allowed from interrupt handler, and softirq handler, running in the grace period kthread's context. Present code allows self wakeups from all interrupt contexts - nmi, softirq and hardirq contexts.
Quoted 8 lines
That's not actually the issue. But it appears that we return if we simply have BH disabled, which I don't think we want, and we don't care about NMI as NMI should never call this code.
I think your patch is correct, but the change log is not.
-- Steve
Hi Steve, sorry, I don't understand fully, why we want to not return in BH disabled case. From the commit logs and lkml discussion, there is a case where GP kthread is interrupted in the wait event path and rcu_gp_kthread_wake() is called in softirq handler (I am not sure about interrupt handler case; how rcu_gp_kthread_wake() is called from that path).
https://github.com/torvalds/linux/commit/1d1f898df6586c5ea9aeaf349f13089c6fa37903
Thanks
Neeraj
Quoted 21 lines
Quoted 20 lines
Signed-off-by Neeraj Upadhyay <[email protected]>--- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tree.c +1
-1@@ -1585,7 +1585,7 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp)static void rcu_gp_kthread_wake (void ) {if ((current == rcu_state.gp_kthread && - !in_interrupt () && !in_serving_softirq ()) || + !in_irq () && !in_serving_softirq ()) || !READ_ONCE (rcu_state.gp_flags) || !rcu_state.gp_kthread)return ;
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
Quoted 10 lines · Neeraj Upadhyay
Quoted 9 lines · Steven Rostedt
Quoted 5 lines · On Fri, 8 Mar 2019 15:16:18 +0530 Neeraj Upadhyay <[email protected]>…
Update the code to match the comment that self wakeup of grace period kthread is allowed from interrupt handler, and softirq handler, running in the grace period kthread's context. Present code allows self wakeups from all interrupt contexts - nmi, softirq and hardirq contexts.
Quoted 5 lines
Quoted 5 lines
That's not actually the issue. But it appears that we return if we simply have BH disabled, which I don't think we want, and we don't care about NMI as NMI should never call this code.
I think your patch is correct, but the change log is not.
How about this?
The current rcu_gp_kthread_wake() function uses in_interrupt() and thus does a self-wakeup from all interrupt contexts, including the pointless case where the GP kthread happens to be running with bottom halves disabled, along with the impossible case where the GP kthread is running within an NMI handler (you are not supposed to invoke rcu_gp_kthread_wake() from within an NMI handler. This commit therefore replaces the in_interrupt() with in_irq(), so that the self-wakeups happen only from handlers for hardware interrupts and softirqs. This also makes the code match the comment.
Thanx, Paul
Quoted 40 lines
Quoted 2 lines
-- Steve
Hi Steve, sorry, I don't understand fully, why we want to not return in BH disabled case. From the commit logs and lkml discussion, there is a case where GP kthread is interrupted in the wait event path and
rcu_gp_kthread_wake()is called in softirq handler (I am not sure about interrupt handler case; howrcu_gp_kthread_wake()is called from that path).https://github.com/torvalds/linux/commit/1d1f898df6586c5ea9aeaf349f13089c6fa37903
Thanks
NeerajQuoted 21 lines
Quoted 20 lines
Signed-off-by Neeraj Upadhyay <[email protected]>--- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tree.c +1
-1@@ -1585,7 +1585,7 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp)static void rcu_gp_kthread_wake (void ) {if ((current == rcu_state.gp_kthread && - !in_interrupt () && !in_serving_softirq ()) || + !in_irq () && !in_serving_softirq ()) || !READ_ONCE (rcu_state.gp_flags) || !rcu_state.gp_kthread)return ;Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
Quoted 19 lines · On Tue, 12 Mar 2019 07:09:23 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 10 lines · Neeraj Upadhyay
Quoted 9 lines · Steven Rostedt
Quoted 5 lines · On Fri, 8 Mar 2019 15:16:18 +0530 Neeraj Upadhyay <[email protected]>…
Update the code to match the comment that self wakeup of grace period kthread is allowed from interrupt handler, and softirq handler, running in the grace period kthread's context. Present code allows self wakeups from all interrupt contexts - nmi, softirq and hardirq contexts.
Quoted 5 lines
Quoted 5 lines
That's not actually the issue. But it appears that we return if we simply have BH disabled, which I don't think we want, and we don't care about NMI as NMI should never call this code.
I think your patch is correct, but the change log is not.
How about this?
Quoted 10 lines
The current
rcu_gp_kthread_wake()function usesin_interrupt()and thus does a self-wakeup from all interrupt contexts, including the pointless case where the GP kthread happens to be running with bottom halves disabled, along with the impossible case where the GP kthread is running within an NMI handler (you are not supposed to invokercu_gp_kthread_wake()from within an NMI handler. This commit therefore replaces thein_interrupt()within_irq(), so that the self-wakeups happen only from handlers for hardware interrupts and softirqs. This also makes the code match the comment.
Quoted 12 lines
Thanx, Paul
Quoted 9 lines
Quoted 2 lines
-- Steve
Hi Steve, sorry, I don't understand fully, why we want to not return in BH disabled case. From the commit logs and lkml discussion, there is a case where GP kthread is interrupted in the wait event path and
rcu_gp_kthread_wake()is called in softirq handler (I am not sure about interrupt handler case; howrcu_gp_kthread_wake()is called from that path).
BH disabled case isn't a case where the kthread is preempted. It's just that the kthread disabled BH, and thus we want to return.
-- Steve
Paul E. McKenney
AppliedQuoted 33 lines · Steven Rostedt
Quoted 19 lines · On Tue, 12 Mar 2019 07:09:23 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 10 lines · Neeraj Upadhyay
Quoted 9 lines · Steven Rostedt
Quoted 5 lines · On Fri, 8 Mar 2019 15:16:18 +0530 Neeraj Upadhyay <[email protected]>…
Update the code to match the comment that self wakeup of grace period kthread is allowed from interrupt handler, and softirq handler, running in the grace period kthread's context. Present code allows self wakeups from all interrupt contexts - nmi, softirq and hardirq contexts.
Quoted 5 lines
Quoted 5 lines
That's not actually the issue. But it appears that we return if we simply have BH disabled, which I don't think we want, and we don't care about NMI as NMI should never call this code.
I think your patch is correct, but the change log is not.
How about this?
Quoted 10 lines
The current
rcu_gp_kthread_wake()function usesin_interrupt()and thus does a self-wakeup from all interrupt contexts, including the pointless case where the GP kthread happens to be running with bottom halves disabled, along with the impossible case where the GP kthread is running within an NMI handler (you are not supposed to invokercu_gp_kthread_wake()from within an NMI handler. This commit therefore replaces thein_interrupt()within_irq(), so that the self-wakeups happen only from handlers for hardware interrupts and softirqs. This also makes the code match the comment.
Quoted 1 line
Applied, thank you!
Thanx, Paul
Quoted 15 lines
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
-- Steve
Hi Steve, sorry, I don't understand fully, why we want to not return in BH disabled case. From the commit logs and lkml discussion, there is a case where GP kthread is interrupted in the wait event path and
rcu_gp_kthread_wake()is called in softirq handler (I am not sure about interrupt handler case; howrcu_gp_kthread_wake()is called from that path).BH disabled case isn't a case where the kthread is preempted. It's just that the kthread disabled BH, and thus we want to return.
-- Steve