Skip to content

hung_task: improve rcu_lock_break() logic

Oleg Nesterov lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2hung_task: split for_each_process_thread() into for_each_process() + __for_each_thread()kernel/hung_task.c+14 -91 reply
2/2hung_task: improve the rcu_lock_break() logickernel/hung_task.c+20 -91 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchAaron Tomlin
1/2A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] hung_task: improve rcu_lock_break() logic
Quoted 26 lines · Oleg Nesterov
Quoted 13 lines · Aaron Tomlin
kernel/hung_task.c +1 -1
@@ -169,7 +169,7 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
 		return;
 
 	rcu_read_lock();
-	do_each_thread(g, t) {
+	for_each_process_thread(g, t) {
 		if (!max_count--)
 			goto unlock;
 		if (!--batch_count) {

kernel/hung_task.c static void check_hung_uninterruptible_tasks(unsigned long timeout) · line 183

Quoted 5 lines
kernel/hung_task.c +1 -1
@@ -180,7 +180,7 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
 		/* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
 		if (t->state == TASK_UNINTERRUPTIBLE)
 			check_hung_task(t, timeout);
-	} while_each_thread(g, t);
+	}
Quoted 6 lines

Perhaps it also makes sense to improve this rcu_lock_break a bit... For example, if 't' is dead but 'g' is alive we can continue the "for_each_process" part of this double loop. And if 't' is still alive then we can find the new leader and continue...

But I agree, lets start from this fix, then we will see.

Something like this. on top of Aaron's change.

But actually I am not sure this really makes a lot of sense. But if yes, we can do more. We can save g->start_time before rcu_lock_break(), and then "both dead" case can use for_each_process() to (try to) find the first process whis has a ge start_time.

Oleg.