Commit cf2592f59c0e8ed4308adbdb2e0a88655379d579
Committed by
Ingo Molnar
1 parent
17406b82d6
Exists in
master
and in
39 other branches
softlockup: ensure the task has been switched out once
When we check if a task has been switched out since the last scan, we might have a race condition on the following scenario: - the task is freshly created and scheduled - it puts its state to TASK_UNINTERRUPTIBLE and is not yet switched out - check_hung_task() scans this task and will report a false positive because t->nvcsw + t->nivcsw == t->last_switch_count == 0 Add a check for such cases. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Mandeep Singh Baines <msb@google.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 1 changed file with 7 additions and 1 deletions Side-by-side Diff
kernel/hung_task.c
... | ... | @@ -72,7 +72,13 @@ |
72 | 72 | { |
73 | 73 | unsigned long switch_count = t->nvcsw + t->nivcsw; |
74 | 74 | |
75 | - if (t->flags & PF_FROZEN) | |
75 | + /* | |
76 | + * Ensure the task is not frozen. | |
77 | + * Also, when a freshly created task is scheduled once, changes | |
78 | + * its state to TASK_UNINTERRUPTIBLE without having ever been | |
79 | + * switched out once, it musn't be checked. | |
80 | + */ | |
81 | + if (unlikely(t->flags & PF_FROZEN || !switch_count)) | |
76 | 82 | return; |
77 | 83 | |
78 | 84 | if (switch_count != t->last_switch_count) { |