Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: sashiko-reviews@lists.linux.dev
Cc: David Hildenbrand <david@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Ben Gardon <bgardon@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, Chris Mason <mason@kernel.org>
Subject: Re: [PATCH 05/10] mm, oom: thaw tasks sharing the mm with the oom victim
Date: Wed, 2 Dec 2026 20:23:16 +0100	[thread overview]
Message-ID: <axBwJJgSGlaReEgn@tiehlicka> (raw)
In-Reply-To: <sashiko-outbox-246215@kernel.org>

On Wed 02-12-26 16:30:59, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [High] mm, oom: thaw_process() fails to thaw shared-mm tasks in
>   __oom_kill_process()
> --
> 
> commit 342e5dd06461083fcf31f5a288fe32e31c789a6e
> Author: Michal Hocko <mhocko@suse.com>
> 
> mm, oom: thaw tasks sharing the mm with the oom victim
> 
> This commit calls thaw_process() on processes in other thread groups that
> are killed because they share their mm with the OOM victim.
> 
> > diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> > index 56e65fa1b08e4..aca0e816b87a8 100644
> > --- a/mm/oom_kill.c
> > +++ b/mm/oom_kill.c
> > @@ -990,6 +990,7 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
> >  		if (unlikely(p->flags & PF_KTHREAD))
> >  			continue;
> >  		do_send_sig_info(SIGKILL, SEND_SIG_PRIV, p, PIDTYPE_TGID);
> > +		thaw_process(p);
> 
> [Severity: High]
> Can thaw_process(p) actually unfreeze p here when mark_oom_victim() was
> only called on victim?
> 
> Because this loop skips same_thread_group(p, victim), p has its own
> signal_struct where p->signal->oom_mm is still NULL, so
> tsk_is_oom_victim() returns false for p's threads:
> 
> kernel/freezer.c:freezing_slow_path() {
> 	...
> 	if (tsk_is_oom_victim(p))
> 		return false;
> 
> 	if (pm_nosig_freezing || cgroup1_freezing(p))
> 		return true;
> 	...
> }
> 
> When thaw_process(p) wakes a thread in __refrigerator() (or a thread in a
> TASK_FREEZABLE sleep that enters get_signal() -> try_to_freeze() before
> checking SIGKILL), freezing(current) still returns true if its cgroup v1
> freezer is frozen.  The thread goes right back into TASK_FROZEN without
> exiting, leaving the shared mm pinned and failing to avoid the extra OOM
> kills or panic this patch aims to prevent.

Correct. I believe the following should address the issue. I will fold
that into the patch. Thanks for pointing out. I always forget all these
details about freezer. I thought thaw_task would act merely on grounds
of pending SIGKILL. Mea culpa

diff --git a/kernel/freezer.c b/kernel/freezer.c
index a76bf957fb32..61a4c1607743 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -44,6 +44,9 @@ bool freezing_slow_path(struct task_struct *p)
 	if (tsk_is_oom_victim(p))
 		return false;
 
+	if (p->mm && mm_is_oom_victim(p->mm))
+		return false;
+
 	if (pm_nosig_freezing || cgroup1_freezing(p))
 		return true;
 
-- 
Michal Hocko
SUSE Labs


  reply	other threads:[~2026-12-02 19:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  9:53 [PATCH 0/10] assorted oom fixes Michal Hocko
2026-12-02  9:53 ` [PATCH 01/10] memcg-v1, oom: do not sleep in worker contexts Michal Hocko
2026-12-02  9:53 ` [PATCH 02/10] mm/oom_kill: keep the allocating mm eligible Michal Hocko
2026-12-02  9:53 ` [PATCH 03/10] mm, oom: do not panic on constrained OOMs Michal Hocko
2026-12-02  9:53 ` [PATCH 04/10] mm/oom_kill: ratelimit memcg OOM reports with no victim Michal Hocko
2026-12-02  9:53 ` [PATCH 05/10] mm, oom: thaw tasks sharing the mm with the oom victim Michal Hocko
2026-12-02 16:30   ` sashiko-bot
2026-12-02 19:23     ` Michal Hocko [this message]
2026-12-02  9:53 ` [PATCH 06/10] mm, oom: check oom victims prior to numa placement Michal Hocko
2026-12-02  9:54 ` [PATCH 07/10] memcg, oom: wait for rcu_call callbacks before retrying reclaim Michal Hocko
2026-12-02 16:31   ` sashiko-bot
2026-12-02 19:22   ` Harry Yoo
2026-12-02 19:33     ` Michal Hocko
2026-12-02  9:54 ` [PATCH 08/10] mm, " Michal Hocko
2026-12-02 16:31   ` sashiko-bot
2026-12-02  9:54 ` [PATCH 09/10] mm, oom: add rcu_barrier before hiding victim from the oom killer Michal Hocko
2026-12-02 16:31   ` sashiko-bot
2026-12-02  9:54 ` [PATCH 10/10] memcg: wake v1 OOM lock contenders on unlock Michal Hocko
2026-12-02 13:06 ` [PATCH 0/10] assorted oom fixes David Hildenbrand (Arm)
2026-12-02 19:01   ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axBwJJgSGlaReEgn@tiehlicka \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=bgardon@google.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=mason@kernel.org \
    --cc=rientjes@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox