From: Michal Hocko <mhocko@suse.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Christian Brauner <brauner@kernel.org>,
akpm@linux-foundation.org, david@kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, surenb@google.com,
timmurray@google.com
Subject: Re: [RFC 3/3] mm: process_mrelease: introduce PROCESS_MRELEASE_REAP_KILL flag
Date: Thu, 23 Apr 2026 09:17:39 +0200 [thread overview]
Message-ID: <aenHk3E-1ZIRI2YU@tiehlicka> (raw)
In-Reply-To: <aeae2Cl4ybcx0fHA@google.com>
On Mon 20-04-26 14:47:04, Minchan Kim wrote:
> On Fri, Apr 17, 2026 at 09:04:31AM +0200, Michal Hocko wrote:
> > On Thu 16-04-26 23:30:09, Minchan Kim wrote:
> > > If I send the SIGKILL first to satisfy the process_mrelease() requirement,
> > > we immediately run into the scheduling race condition where the victim can
> > > enter the exit path before the reaper can set the flag.
> >
> > Why don't you just grab the mm before you send the signal and then continue
> > with reaping? You just want to avoid a race where the victim manages to
> > process fatal signal, start its exit path and mrelease path losing that
> > race so you rely on the exit path, right?
>
> The problem is that process_mrelease() operates on a task obtained from a pidfd.
>
> Once the victim process receives the SIGKILL and enters the exit path (exit_mm),
> the kernel sets task->mm to NULL.
>
> Even if we could somehow hold a reference to the mm_struct beforehand,
> process_mrelease() would still fail because mm_struct via task returns NULL
> after exit_mm() has been called.
>
> Therefore, we cannot simply "grab the mm" before sending the signal and expect
> process_mrelease() to work after the victim starts exiting.
I do not follow. Why cannot you simply do this
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 5c6c95c169ee..b80a96f5460a 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -1241,9 +1241,14 @@ SYSCALL_DEFINE2(process_mrelease, int, pidfd, unsigned int, flags)
if (task_will_free_mem(p))
reap = true;
else {
+ if (flags & PROCESS_MRELEASE_REAP_KILL) {
+ } else {
+ /* send SIGKILL */
+ reap = true;
/* Error only if the work has not been done already */
- if (!mm_flags_test(MMF_OOM_SKIP, mm))
- ret = -EINVAL;
+ if (!mm_flags_test(MMF_OOM_SKIP, mm))
+ ret = -EINVAL;
+ }
}
task_unlock(p);
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2026-04-23 7:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 22:39 [RFC 0/3] mm: process_mrelease: expedited reclaim and auto-kill support Minchan Kim
2026-04-13 22:39 ` [RFC 1/3] mm: process_mrelease: expedite clean file folio reclaim via mmu_gather Minchan Kim
2026-04-14 7:45 ` David Hildenbrand (Arm)
2026-04-14 20:21 ` Minchan Kim
2026-04-13 22:39 ` [RFC 2/3] mm: process_mrelease: skip LRU movement for exclusive file folios Minchan Kim
2026-04-14 7:20 ` David Hildenbrand (Arm)
2026-04-14 20:22 ` Minchan Kim
2026-04-13 22:39 ` [RFC 3/3] mm: process_mrelease: introduce PROCESS_MRELEASE_REAP_KILL flag Minchan Kim
2026-04-16 9:13 ` Christian Brauner
2026-04-17 6:30 ` Minchan Kim
2026-04-17 7:04 ` Michal Hocko
2026-04-20 21:47 ` Minchan Kim
2026-04-23 7:17 ` Michal Hocko [this message]
2026-04-14 6:57 ` [RFC 0/3] mm: process_mrelease: expedited reclaim and auto-kill support Michal Hocko
2026-04-14 20:00 ` Minchan Kim
2026-04-15 7:38 ` Michal Hocko
2026-04-15 23:26 ` Minchan Kim
2026-04-16 6:54 ` Michal Hocko
2026-04-17 6:20 ` Minchan Kim
2026-04-17 7:11 ` Michal Hocko
2026-04-20 21:53 ` Minchan Kim
2026-04-23 7:50 ` Michal Hocko
2026-04-23 9:49 ` David Hildenbrand (Arm)
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=aenHk3E-1ZIRI2YU@tiehlicka \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=surenb@google.com \
--cc=timmurray@google.com \
/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