From: Michal Hocko <mhocko@suse.com>
To: Jinjiang Tu <tujinjiang@huawei.com>
Cc: rientjes@google.com, shakeel.butt@linux.dev,
akpm@linux-foundation.org, david@redhat.com, ziy@nvidia.com,
matthew.brost@intel.com, joshua.hahnjy@gmail.com,
rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net,
ying.huang@linux.alibaba.com, apopple@nvidia.com,
linux-mm@kvack.org, wangkefeng.wang@huawei.com
Subject: Re: [PATCH] mm/oom_kill: kill current in OOM when binding to cpu-less nodes
Date: Thu, 4 Sep 2025 16:25:50 +0200 [thread overview]
Message-ID: <aLmhbjtF0Sp75XXE@tiehlicka> (raw)
In-Reply-To: <20250904134431.1637701-1-tujinjiang@huawei.com>
On Thu 04-09-25 21:44:31, Jinjiang Tu wrote:
> out_of_memory() selects tasks without considering mempolicy. Assuming a
> cpu-less NUMA Node, ordinary process that don't set mempolicy don't
> allocate memory from this cpu-less Node, unless other NUMA Nodes are below
> low watermark. If a task binds to this cpu-less Node and triggers OOM, many
> tasks may be killed wrongly that don't occupy memory from this Node.
I can see how a miconfigured task that binds _only_ to memoryless nodes
should be killed but this is not what the patch does, right? Could you
tell us more about the specific situation?
> To fix it, only kill current if oc->nodemask are all nodes without any cpu.
>
> Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com>
> ---
> mm/oom_kill.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 25923cfec9c6..8ae4b2ecfe12 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -1100,6 +1100,20 @@ int unregister_oom_notifier(struct notifier_block *nb)
> }
> EXPORT_SYMBOL_GPL(unregister_oom_notifier);
>
> +static bool should_oom_kill_allocating_task(struct oom_control *oc)
> +{
> + if (sysctl_oom_kill_allocating_task)
> + return true;
> +
> + if (!oc->nodemask)
> + return false;
> +
> + if (nodes_intersects(*oc->nodemask, node_states[N_CPU]))
> + return false;
> +
> + return true;
> +}
> +
> /**
> * out_of_memory - kill the "best" process when we run out of memory
> * @oc: pointer to struct oom_control
> @@ -1151,7 +1165,7 @@ bool out_of_memory(struct oom_control *oc)
> oc->nodemask = NULL;
> check_panic_on_oom(oc);
>
> - if (!is_memcg_oom(oc) && sysctl_oom_kill_allocating_task &&
> + if (!is_memcg_oom(oc) && should_oom_kill_allocating_task(oc) &&
> current->mm && !oom_unkillable_task(current) &&
> oom_cpuset_eligible(current, oc) &&
> current->signal->oom_score_adj != OOM_SCORE_ADJ_MIN) {
> --
> 2.43.0
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2025-09-04 14:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 13:44 [PATCH] mm/oom_kill: kill current in OOM when binding to cpu-less nodes Jinjiang Tu
2025-09-04 14:25 ` Michal Hocko [this message]
2025-09-05 1:56 ` Jinjiang Tu
2025-09-05 8:08 ` Michal Hocko
2025-09-05 8:18 ` Jinjiang Tu
2025-09-05 9:10 ` Michal Hocko
2025-09-05 9:25 ` Jinjiang Tu
2025-09-05 9:42 ` Michal Hocko
2025-09-06 1:56 ` Jinjiang Tu
2025-09-08 7:46 ` Michal Hocko
2025-09-08 8:16 ` Jinjiang Tu
2025-09-08 9:11 ` Michal Hocko
2025-09-08 11:07 ` Jinjiang Tu
2025-09-08 11:13 ` Jinjiang Tu
2025-09-08 11:26 ` Michal Hocko
2025-09-05 9:13 ` Michal Hocko
2025-09-04 14:26 ` Joshua Hahn
2025-09-04 14:36 ` Michal Hocko
2025-09-04 14:43 ` Joshua Hahn
2025-09-05 2:05 ` Jinjiang Tu
2025-09-08 17:50 ` Gregory Price
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=aLmhbjtF0Sp75XXE@tiehlicka \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--cc=david@redhat.com \
--cc=gourry@gourry.net \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-mm@kvack.org \
--cc=matthew.brost@intel.com \
--cc=rakie.kim@sk.com \
--cc=rientjes@google.com \
--cc=shakeel.butt@linux.dev \
--cc=tujinjiang@huawei.com \
--cc=wangkefeng.wang@huawei.com \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.