rcu/torture replace wait_event with wait_event_idle
Subsystems (2)
PATCH v2 1/1 rcu/torture replace wait_event with wait_event_idle
From: Zhouyi Zhou <[email protected]>
In kfree_rcu_test, kfree_scale_shutdown will be detected as hung task if kfree_loops is too big. Replace wait_event with wait_event_idle to avoid false positive.
Tested in the PPC VM of Open Source Lab of Oregon State University.
--- kernel/rcu/rcuscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcuscale.c +1 -1
@@ -771,7 +771,7 @@ kfree_scale_cleanup(void)static int kfree_scale_shutdown (void *arg) { -wait_event (shutdown_wq, +wait_event_idle (shutdown_wq,atomic_read (&n_kfree_scale_thread_ended) >= kfree_nrealthreads);smp_mb ();/* Wake before output. */
Signature · 1 line
2.34.1
Paul E. McKenney
maintainerQuoted 10 lines · On Tue, May 02, 2023 at 08:01:41AM +0800, [email protected] wrote:
From: Zhouyi Zhou <[email protected]>
In
kfree_rcu_test,kfree_scale_shutdownwill be detected as hung task ifkfree_loopsis too big. Replacewait_eventwithwait_event_idleto avoid false positive.Tested in the PPC VM of Open Source Lab of Oregon State University.
Suggested-by Paul E. McKenney <[email protected]>Signed-off-by Zhouyi Zhou <[email protected]>
Good catch, thank you!
However, this commit beat you to it:
ef1ef3d47677 ("rcuscale: Move shutdown from wait_event() to wait_event_idle()")
Thanx, Paul
Quoted 20 lines
--- kernel/rcu/rcuscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcuscale.c +1
-1@@ -771,7 +771,7 @@ kfree_scale_cleanup(void)static int kfree_scale_shutdown (void *arg) { -wait_event (shutdown_wq, +wait_event_idle (shutdown_wq,atomic_read (&n_kfree_scale_thread_ended) >= kfree_nrealthreads);smp_mb ();/* Wake before output. */ Signature · 1 line
2.34.1
Quoted 10 lines · Paul E. McKenney
Quoted 8 lines · On Tue, May 02, 2023 at 08:01:41AM +0800, [email protected] wrote:
From: Zhouyi Zhou <[email protected]>
In
kfree_rcu_test,kfree_scale_shutdownwill be detected as hung task ifkfree_loopsis too big. Replacewait_eventwithwait_event_idleto avoid false positive.Tested in the PPC VM of Open Source Lab of Oregon State University.
Quoted 8 lines
Quoted 2 lines
Suggested-by Paul E. McKenney <[email protected]>Signed-off-by Zhouyi Zhou <[email protected]>Good catch, thank you!
However, this commit beat you to it:
ef1ef3d47677("rcuscale: Move shutdown fromwait_event()towait_event_idle()")
You are very welcome ;-) Still, this is a very fruitful learning process for me ;-)
Cheers
Zhouyi
Quoted 23 lines
Thanx, Paul
Quoted 20 lines
--- kernel/rcu/rcuscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcuscale.c +1
-2@@ -771,7 +771,7 @@ kfree_scale_cleanup(void)static int kfree_scale_shutdown (void *arg) { -wait_event (shutdown_wq, +wait_event_idle (shutdown_wq,atomic_read (&n_kfree_scale_thread_ended) >= kfree_nrealthreads);smp_mb ();/* Wake before output. */ --2.34.1
Quoted 18 lines · Zhouyi Zhou
Quoted 13 lines · Paul E. McKenney
Quoted 12 lines · On Tue, May 02, 2023 at 08:01:41AM +0800, [email protected] wrote:
From: Zhouyi Zhou <[email protected]>
In
kfree_rcu_test,kfree_scale_shutdownwill be detected as hung task ifkfree_loopsis too big. Replacewait_eventwithwait_event_idleto avoid false positive.Tested in the PPC VM of Open Source Lab of Oregon State University.
Suggested-by Paul E. McKenney <[email protected]>Signed-off-by Zhouyi Zhou <[email protected]>
Quoted 7 lines
Quoted 5 lines
Good catch, thank you!
However, this commit beat you to it:
ef1ef3d47677("rcuscale: Move shutdown fromwait_event()towait_event_idle()")You are very welcome ;-) Still, this is a very fruitful learning process for me ;-)
Speaking of learning, can you explain why it fixes the issue? ;-)
Your change log lacked the real reason but that is Ok since change logs can only tell you so much. I admit I myself did not know the reason till I read some code.
Quiz: why exactly does this all work out in the end even though the hung task detector saw it hung?
Thanks,
- Joel
Quoted 26 lines
Cheers
ZhouyiQuoted 23 lines
Thanx, Paul
Quoted 20 lines
---
kernel/rcu/rcuscale.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcuscale.c +0
-0@@ -771,7 +771,7 @@ kfree_scale_cleanup(void)static int
kfree_scale_shutdown(void *arg)
{kernel/rcu/rcuscale.c +1
-2-wait_event (shutdown_wq, +wait_event_idle (shutdown_wq,atomic_read (&n_kfree_scale_thread_ended) >= kfree_nrealthreads);smp_mb ();/* Wake before output. */ --2.34.1
Thank Joel for your guidance ;-)
Quoted 23 lines · Joel Fernandes
Quoted 23 lines · Zhouyi Zhou
Quoted 17 lines · Paul E. McKenney
Quoted 12 lines · On Tue, May 02, 2023 at 08:01:41AM +0800, [email protected] wrote:
From: Zhouyi Zhou <[email protected]>
In
kfree_rcu_test,kfree_scale_shutdownwill be detected as hung task ifkfree_loopsis too big. Replacewait_eventwithwait_event_idleto avoid false positive.Tested in the PPC VM of Open Source Lab of Oregon State University.
Suggested-by Paul E. McKenney <[email protected]>Signed-off-by Zhouyi Zhou <[email protected]>Good catch, thank you!
However, this commit beat you to it:
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
ef1ef3d47677("rcuscale: Move shutdown fromwait_event()towait_event_idle()")You are very welcome ;-) Still, this is a very fruitful learning process for me ;-)
Speaking of learning, can you explain why it fixes the issue? ;-)
Your change log lacked the real reason but that is Ok since change logs can only tell you so much. I admit I myself did not know the reason till I read some code.
When I found "blocked for more than" report in console.log, I did a grep in kernel source tree, and found check_hung_task will only be invoked
from check_hung_uninterruptible_tasks when (state & TASK_UNINTERRUPTIBLE) and !(state & TASK_WAKEKILL) and !(state & TASK_NOLOAD), so I send my first patch [1], and Paul tell me wait_event_idle is the right answer, then I do a grep for recursively expansion of macro wait_event_idle, which finally set current->state to TASK_IDLE ((TASK_UNINTERRUPTIBLE | TASK_NOLOAD)), then I conclude that check_hung_task will not be called. Yes, _interruptible() variant indicates that wakeups due to things like POSIX signals are permitted, which are not our case.
I should investigate more on what wait_event_idle really means, instead of merely grep and debug what wait_event_idle does.
I should write my change log more clearly and explain why wait_event_idle works.
I discovered [1] during the testing of the patch, this is also a very fruitful learning process.
I will write my change log more indicative next time, and do better work to our RCU community (and thanks for remove linux-kernel from CC list ;-))
Thanks
Zhouyi
[1] Link: https://lore.kernel.org/lkml/CAABZP2yS5=ZUwEZQ7iHkV0wDm_HgO8K-TeAhyJrZhavzKDa44Q@mail.gmail.com/T/
Quoted 23 lines · Joel Fernandes
Quoted 23 lines · Zhouyi Zhou
Quoted 17 lines · Paul E. McKenney
Quoted 12 lines · On Tue, May 02, 2023 at 08:01:41AM +0800, [email protected] wrote:
From: Zhouyi Zhou <[email protected]>
In
kfree_rcu_test,kfree_scale_shutdownwill be detected as hung task ifkfree_loopsis too big. Replacewait_eventwithwait_event_idleto avoid false positive.Tested in the PPC VM of Open Source Lab of Oregon State University.
Suggested-by Paul E. McKenney <[email protected]>Signed-off-by Zhouyi Zhou <[email protected]>Good catch, thank you!
However, this commit beat you to it:
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
ef1ef3d47677("rcuscale: Move shutdown fromwait_event()towait_event_idle()")You are very welcome ;-) Still, this is a very fruitful learning process for me ;-)
Speaking of learning, can you explain why it fixes the issue? ;-)
Your change log lacked the real reason but that is Ok since change logs can only tell you so much. I admit I myself did not know the reason till I read some code.
When I found "task xxx blocked for more than" report in console.log, I did a grep in kernel source tree, and found check_hung_task will only be invoked
from check_hung_uninterruptible_tasks when (state & TASK_UNINTERRUPTIBLE) and !(state & TASK_NOLOAD), so I send my first patch [1], and Paul tell me wait_event_idle is the right answer, then I do a grep for recursively expansion of macro wait_event_idle, which finally set current->state to TASK_IDLE ((TASK_UNINTERRUPTIBLE | TASK_NOLOAD)), then
I conclude that
[1] https://lore.kernel.org/lkml/[email protected]/T/
Quoted 30 lines
Quiz: why exactly does this all work out in the end even though the hung task detector saw it hung?
Thanks,
- Joel
Quoted 22 lines
Cheers
ZhouyiQuoted 19 lines
Thanx, Paul
Quoted 16 lines
---
kernel/rcu/rcuscale.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcuscale.c +0
-0@@ -771,7 +771,7 @@ kfree_scale_cleanup(void)static int
kfree_scale_shutdown(void *arg)
{kernel/rcu/rcuscale.c +1
-1-wait_event (shutdown_wq, +wait_event_idle (shutdown_wq,atomic_read (&n_kfree_scale_thread_ended) >= kfree_nrealthreads);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
smp_mb(); /* Wake before output. */--
2.34.1
[1] https://lore.kernel.org/lkml/[email protected]/T/
Quoted 34 lines
Quiz: why exactly does this all work out in the end even though the hung task detector saw it hung?
Thanks,
- Joel
Quoted 26 lines
Cheers
ZhouyiQuoted 23 lines
Thanx, Paul
Quoted 20 lines
---
kernel/rcu/rcuscale.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcuscale.c +0
-0@@ -771,7 +771,7 @@ kfree_scale_cleanup(void)static int
kfree_scale_shutdown(void *arg)
{kernel/rcu/rcuscale.c +1
-2-wait_event (shutdown_wq, +wait_event_idle (shutdown_wq,atomic_read (&n_kfree_scale_thread_ended) >= kfree_nrealthreads);smp_mb ();/* Wake before output. */ --2.34.1
Sorry for the bad format of my previous email, there is always something wrong when I press Ctrl+C and Ctrl+V in my browser. Sorry for the inconvenience that I bring.
Quoted 24 lines · Joel Fernandes
Quoted 24 lines · Zhouyi Zhou
Quoted 18 lines · Paul E. McKenney
Quoted 12 lines · On Tue, May 02, 2023 at 08:01:41AM +0800, [email protected] wrote:
From: Zhouyi Zhou <[email protected]>
In
kfree_rcu_test,kfree_scale_shutdownwill be detected as hung task ifkfree_loopsis too big. Replacewait_eventwithwait_event_idleto avoid false positive.Tested in the PPC VM of Open Source Lab of Oregon State University.
Suggested-by Paul E. McKenney <[email protected]>Signed-off-by Zhouyi Zhou <[email protected]>Good catch, thank you!
However, this commit beat you to it:
ef1ef3d47677("rcuscale: Move shutdown fromwait_event()towait_event_idle()")
Quoted 8 lines
Quoted 2 lines
You are very welcome ;-) Still, this is a very fruitful learning process for me ;-)
Speaking of learning, can you explain why it fixes the issue? ;-)
Your change log lacked the real reason but that is Ok since change logs can only tell you so much. I admit I myself did not know the reason till I read some code.
Quiz: why exactly does this all work out in the end even though the hung task detector saw it hung?
When I found "blocked for more than" report in console.log, I did a grep in kernel source tree, and found check_hung_task will only be invoked
from check_hung_uninterruptible_tas
ks when (state & TASK_UNINTERRUPTIBLE) and !(state & TASK_WAKEKILL) and !(state &TASK_NOLOAD), so I send my first patch [1], and Paul tell me wait_event_idle is the right answer, then I do a grep for recursively expansion of macro wait_event_idle, which finally set current->state to TASK_IDLE ((TASK_UNINTERRUPTIBLE | TASK_NOLOAD)), then I conclude that check_hung_task will not be called. Yes, _interruptible() variant indicates that wakeups due to things like POSIX signals are permitted, which are not our case.
I should investigate more on what wait_event_idle really means, instead of merely grep and debug what wait_event_idle does.
I should write my change log more clearly and explain why wait_event_idle works.
I discovered [2] during the testing of the patch, this is also a very fruitful learning process.
I will write my change log more indicative next time, and do better work to our RCU community (and thanks for remove linux-kernel from CC list ;-))
Thanks
Zhouyi
[1] https://lore.kernel.org/lkml/[email protected]/T/
[2] https://lore.kernel.org/lkml/CAABZP2yS5=ZUwEZQ7iHkV0wDm_HgO8K-TeAhyJrZhavzKDa44Q@mail.gmail.com/T/
Quoted 31 lines
Thanks,
- Joel
Quoted 26 lines
Cheers
ZhouyiQuoted 23 lines
Thanx, Paul
Quoted 20 lines
---
kernel/rcu/rcuscale.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcuscale.c +0
-0@@ -771,7 +771,7 @@ kfree_scale_cleanup(void)static int
kfree_scale_shutdown(void *arg)
{kernel/rcu/rcuscale.c +1
-2-wait_event (shutdown_wq, +wait_event_idle (shutdown_wq,atomic_read (&n_kfree_scale_thread_ended) >= kfree_nrealthreads);smp_mb ();/* Wake before output. */ --2.34.1
Quoted 38 lines · Zhouyi Zhou
Sorry for the bad format of my previous email, there is always something wrong when I press Ctrl+C and Ctrl+V in my browser. Sorry for the inconvenience that I bring.
Quoted 24 lines · Joel Fernandes
Quoted 24 lines · Zhouyi Zhou
Quoted 18 lines · Paul E. McKenney
Quoted 12 lines · On Tue, May 02, 2023 at 08:01:41AM +0800, [email protected] wrote:
From: Zhouyi Zhou <[email protected]>
In
kfree_rcu_test,kfree_scale_shutdownwill be detected as hung task ifkfree_loopsis too big. Replacewait_eventwithwait_event_idleto avoid false positive.Tested in the PPC VM of Open Source Lab of Oregon State University.
Suggested-by Paul E. McKenney <[email protected]>Signed-off-by Zhouyi Zhou <[email protected]>Good catch, thank you!
However, this commit beat you to it:
ef1ef3d47677("rcuscale: Move shutdown fromwait_event()towait_event_idle()")Quoted 8 lines
Quoted 2 lines
You are very welcome ;-) Still, this is a very fruitful learning process for me ;-)
Speaking of learning, can you explain why it fixes the issue? ;-)
Your change log lacked the real reason but that is Ok since change logs can only tell you so much. I admit I myself did not know the reason till I read some code.
Quiz: why exactly does this all work out in the end even though the hung task detector saw it hung?
Quoted 13 lines
When I found "blocked for more than" report in console.log, I did a grep in kernel source tree, and found
check_hung_taskwill only be invoked
fromcheck_hung_uninterruptible_tas
ks when (state &TASK_UNINTERRUPTIBLE) and !(state &TASK_WAKEKILL) and !(state &TASK_NOLOAD), so I send my first patch [1], and Paul tell mewait_event_idleis the right answer, then I do a grep for recursively expansion of macrowait_event_idle, which finally setcurrent->statetoTASK_IDLE((TASK_UNINTERRUPTIBLE|TASK_NOLOAD)), then I conclude thatcheck_hung_taskwill not be called. Yes,_interruptible()variant indicates that wakeups due to things like POSIX signals are permitted, which are not our case.
That sounds right!
Quoted 3 lines
I should investigate more on what
wait_event_idlereally means, instead of merely grep and debug whatwait_event_idledoes.
I should write my change log more clearly and explain whywait_event_idleworks.
Sounds good, the header comments around those APIs should also help.
Quoted 7 lines
I discovered [2] during the testing of the patch, this is also a very fruitful learning process.
I will write my change log more indicative next time, and do better work to our RCU community (and thanks for remove linux-kernel from CC list ;-))
Sounds good, have fun! :)
- Joel