From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B5F560A2618 for ; Wed, 2 Dec 2026 09:55:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A80696B0651; Wed, 2 Dec 2026 04:55:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0CA06B0652; Wed, 2 Dec 2026 04:55:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FDA56B0653; Wed, 2 Dec 2026 04:55:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 65AEB6B0651 for ; Wed, 2 Dec 2026 04:55:00 -0500 (EST) Received: from smtpin12.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F1317A0246 for ; Wed, 2 Dec 2026 09:54:59 +0000 (UTC) X-FDA: 85498584318.12.D442051 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by imf13.hostedemail.com (Postfix) with ESMTP id 134BA2000A for ; Wed, 2 Dec 2026 09:54:57 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=pass (imf13.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.128.49 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796205298; b=nLORqap5mv+4ZLepqzGUbKnoURZTUZI60UN8e3Ss3zVnVUVfVAcR+eFgRKJC6WH3rUYvmw CH656hyGGFzQPMx25IQxmKBZZtsxA1/LDJfbeFlQyYED3P4L+8cJABfnoEOAqulTvJ6S7M WgmpXvgJgWZZqYunMaArq1gmbY0vDu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796205298; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HbwxwJS/OhFckX8VE4varxoB0R3xwl7gtyeXNuQVefU=; b=2sTOiXT3Mr7ROMz77SOS3829fWeELuIWME02VmZUJISFX6jO/j1jYsV/tuov/JzffTfuar UFZqRorwo1ZHVXK9R8A4tmqn3HdpYXhCHE/+0/oczdMzMDyG7M3dKZz3NRaJJYdj6vavhM 7AgUrErWiYc0vft8VNLznIpjyuLwwBY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=pass (imf13.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.128.49 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4bb85e07aadso157047295e9.1 for ; Wed, 02 Dec 2026 01:54:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796205297; x=1796810097; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=HbwxwJS/OhFckX8VE4varxoB0R3xwl7gtyeXNuQVefU=; b=iNzT4UfEy68fC2TE5C+gq6GEOcMZ7SFx8eGMQ98aUSJQLH0mMXkKbtqldJraEPG466 ei6bgoEw1e5m/LRQ3MuTWieksWpfX5y8gJtN0UDtH/Oz3u/78DGq2B/bhN72do6DjBe6 ZkW67KCPJVbypg1CsnE1SyPyjeWxbbQqr85X6gCv0TYaDOUfrwsVNW6cWEAugLvhaZKM u2TkLtbQB8q8yniSHiTpJu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a4fc151mr397945775e9.1.1796205296607; Wed, 02 Dec 2026 01:54:56 -0800 (PST) Received: from tiehlicka (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853b216esm1148433885e9.12.2026.12.02.01.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 01:54:56 -0800 (PST) From: Michal Hocko To: David Hildenbrand Cc: David Rientjes , Ben Gardon , Johannes Weiner , mhocko@suse.com, Andrew Morton , , LKML , Chris Mason Subject: [PATCH 02/10] mm/oom_kill: keep the allocating mm eligible Date: Wed, 2 Dec 2026 10:53:55 +0100 Message-ID: <20261202095450.296675-3-mhocko@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261202095450.296675-1-mhocko@kernel.org> References: <20261202095450.296675-1-mhocko@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: ekse6k7czgaxshrxky3ke5467g833c1k X-Rspam-User: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Rspamd-Queue-Id: 134BA2000A X-Rspamd-Server: rspam07 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1796205297-817503 X-HE-Meta: U2FsdGVkX1/dPnTZeUCQrW3fHKoroH1gQ4ne6t8vuPY/3HivTge71mGTowbTV7z5pNuOjVbXKKQT4YjM7vI5+JJyvmlrLf9GceSV4+LfNWiBa2mzeA4kW2YrmLbb3NRebJLsoOaadDKmNNyOZmkxIp1yRUF4ted0wGYfze+lGU0iTw66ew2ipMHDkkysNoqciWqKKq/QFvWJWMGN1AijwT5qZjrBBy3YknU9kNz8r9NEg9DNNRB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qWLqvotGcZTRSPlWewjXW58jfp6qDO16UHiCUNduu9w1pGMj+AvjwFEZeXt496Kml2nQt6TZIgvuuMBmdybug2LT9q32F/tHXHUOVF35CdWQUiqROB8lD7cmmL6nLwR3vsiOFbTyF5aprQRpnInjHmySAbcXyo1p9gjW1dUFCwQ93diMRMITOKLZizvn7epCbmfYyAH3InZaVaRj+7teGiQfLY45/8B05Rw7wobr4HDnZUGH7ubCt+XUEfnMOLzIH3odL5Jkt0xhIZq20I9Q130= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Chris Mason On a NUMA machine, a process can exhaust nodes that its own task mempolicy or cpuset. The mempolicy can kill unrelated tasks one after the other, and then panic, while that process is never selected. The OOM killer skips a task that oom_cpuset_eligible() rejects, on the assumption that killing it frees nothing on the nodes that ran out. But each of the two tests in that function can reject the process whose mm is filling those nodes: - In a mempolicy OOM, the function checks the mempolicy of the task. But the nodemask of the allocation can come from the mempolicy of a VMA, so a task with MPOL_BIND to other nodes can still fill the exhausted nodes. - In a cpuset OOM, the function compares the mems_allowed of the task with that of current. mems_allowed is per task, so a vfork() child can allocate in a different cpuset from its parent. oom_badness() skips the child because it is in vfork(). The parent shares the mm, but it is rejected because its cpuset has other nodes. Tasks with no mempolicy, or in the root cpuset, pass these tests and are killed instead. When none is left, out_of_memory() panics. The fix used here is to treat every process that shares the mm of current as eligible, since current is allocating on the exhausted nodes. Fixes: 6f48d0ebd907 ("oom: select task from tasklist for mempolicy ooms") Signed-off-by: Chris Mason Acked-by: Michal Hocko Signed-off-by: David Hildenbrand (Arm) --- mm/oom_kill.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 9de57a23893c..30c314069d5b 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -82,7 +82,8 @@ static inline bool is_memcg_oom(struct oom_control *oc) * * Task eligibility is determined by whether or not a candidate task, @tsk, * shares the same mempolicy nodes as current if it is bound by such a policy - * and whether or not it has the same set of allowed cpuset nodes. + * and whether or not it has the same set of allowed cpuset nodes. A process + * that shares the mm of current is always eligible. * * This function is assuming oom-killer context and 'current' has triggered * the oom-killer. @@ -90,11 +91,23 @@ static inline bool is_memcg_oom(struct oom_control *oc) static bool oom_cpuset_eligible(struct task_struct *start, struct oom_control *oc) { + struct mm_struct *mm = current->mm; struct task_struct *tsk; bool ret = false; const nodemask_t *mask = oc->nodemask; rcu_read_lock(); + /* + * current allocates on the nodes of this oom, so its mm may have memory + * there. The tests below can miss that: the nodemask can come from the + * mempolicy of a vma while that of the task binds it to other nodes, and + * a process that shares the mm can be in another cpuset. + */ + if (mm && process_shares_mm(start, mm)) { + ret = true; + goto unlock; + } + for_each_thread(start, tsk) { if (mask) { /* @@ -114,6 +127,7 @@ static bool oom_cpuset_eligible(struct task_struct *start, if (ret) break; } +unlock: rcu_read_unlock(); return ret; @@ -407,8 +421,8 @@ static int dump_task(struct task_struct *p, void *arg) * @oc: pointer to struct oom_control * * Dumps the current memory state of all eligible tasks. Tasks not in the same - * memcg, not in the same cpuset, or bound to a disjoint set of mempolicy nodes - * are not shown. + * memcg are not shown. Nor are tasks not in the same cpuset or bound to a + * disjoint set of mempolicy nodes, unless they share the mm of current. * State information includes task's pid, uid, tgid, vm size, rss, * pgtables_bytes, swapents, oom_score_adj value, and name. */ -- 2.56.1