Skip to contentSkip to conversation

oom, oom_reaper: Do not enqueue task if it is on the oom_reaper_list head

PATCH In review Michal Hocko 2 participants 2 messages Mar 29, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oom, oom_reaper: Do not enqueue task if it is on the oom_reaper_list head

From: Michal Hocko <[email protected]>

bb29902a7515 ("oom, oom_reaper: protect oom_reaper_list using simpler way") has simplified the check for tasks already enqueued for the oom reaper by checking tsk->oom_reaper_list != NULL. This check is not sufficient because the tsk might be the head of the queue without any other tasks queued and then we would simply lockup looping on the same task. Fix the condition by checking for the head as well.

Fixes bb29902a7515 ("oom, oom_reaper: protect oom_reaper_list using simpler way")

---
Hi,
I have just noticed this after I started consolidating other oom_reaper related changes I have here locally. I should have caught this during the review already and I really feel ashamed I haven't because this is really a trivial bug that should be obvious see...

 mm/oom_kill.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
mm/oom_kill.c +5 -1
index b34d279a7ee6..86349586eacb 100644
@@ -547,7 +547,11 @@ static int oom_reaper(void *unused)
 
 static void wake_oom_reaper(struct task_struct *tsk)
 {
-	if (!oom_reaper_th || tsk->oom_reaper_list)
+	if (!oom_reaper_th)
+		return;
+
+	/* tsk is already queued? */
+	if (tsk == oom_reaper_list || tsk->oom_reaper_list)
 		return;
 
 	get_task_struct(tsk);
Signature · 7 lines
2.7.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Michal Hocko

From: Michal Hocko <[email protected]>

bb29902a7515 ("oom, oom_reaper: protect oom_reaper_list using simpler way") has simplified the check for tasks already enqueued for the oom reaper by checking tsk->oom_reaper_list != NULL. This check is not sufficient because the tsk might be the head of the queue without any other tasks queued and then we would simply lockup looping on the same task. Fix the condition by checking for the head as well.

Indeed, oom_reaper_list is initially NULL.

Quoted 3 lines
Fixes bb29902a7515 ("oom, oom_reaper: protect oom_reaper_list using simpler way")
Quoted 6 lines

---
Hi,
I have just noticed this after I started consolidating other oom_reaper related changes I have here locally. I should have caught this during the review already and I really feel ashamed I haven't because this is really a trivial bug that should be obvious see...

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>