From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796205298; b=QuSvgeWVlxgBd9acjnx7AUwIjx5wUrX/KVdeRiuHrkoMcB6Qzs9FeFxSiCenDkLE5vjC +s3i4fD38GQOnubDwe9TcSZGxrgd7WJSa032Tm7sNUs9RXBsTEB9TMqnX0xGKn3aTxIgZ mm4BKGGD8e/DGKkBZGinYcQ6zKi3UYElkY3CSfG6EWfAQrGHGTYPrqDd9lFt5QpuQ5Swb ZrfBSBYg7I2p4iBpAUZLnkiftUwpSz3KsCYkNtPg0XWEKbh54aTrIeM80YyJzXPF/YH8E 5kPfFbE8vVbKw+i3vVOaAU/ffNhpEtXXy5OYb2LulUM05FxesXSeV2f4gsDTK1EjYYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796205298; h=DMARC-Filter:Received:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=HbwxwJS/OhFckX8VE4varxoB0R3xwl7gtyeXNuQVefU=; b=orOVqVnzLNEFIV38/Jkn3wRQWHjCZU9OmmbiCSL9u+GLQ0nBXe86cXxp0gV5WuxkxfD6 ITYJ63nJKMK0kFNqDpXoJlcAU5vfjfCGbWOkCTpfqU8aJV5AZHROSLmKhs4h+kBOiKPpK 8Cbzl8kpYJ0kRypd1ERrnTLa4gcl7k7IDxl6iPPV+jCsCaephZuqcIIl/MWOft3gQ4ax7 KYWRODFnZCARtaI+/o/BlesxW7A6BA5YI3LS3sYQ5yFc9nc3rUVwllTihNWfNfk0gss3J uDlXn62RXF0SY0HoCmkoke/Nf5AtwsG68ysctJWcY1IjSW/KbLe/72l/MFTu22ulb5w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.remote-ip=209.85.128.44 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60079606A335 for ; Wed, 2 Dec 2026 09:54:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 60079606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4bba60271d7so66669915e9.2 for ; Wed, 02 Dec 2026 01:54:58 -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=Q7YpZsU4Ih4M1/2FVB0yptjO6FeU/6TLc7HveTnHJswzLU3ovJGETY9nHRRayk1c1M HMly8E71Q6ISnDzMkklhJN3ACPtGeViay4BDdMyOB0CZiYg8p+4JD5QUhnb1AP6AC0aS Z3Srwr/VGWewICkZ2H6aAKTCgxY/4YSoV8l9NPTuLDp2/fQ0LhCbllERIeaxX6LNudV3 h4YOIL44AzMzO8H0HlRICCg3rTFj9Hbi4LAkRYTRFP9U1IJkpb8LkZhA053tqiFpz/GS 7N4kquE+enk6Z5me/mKEwQltltGcNP6HD85mTVIM3gmwj9DsBeOXYcGXXiXOPDji4MmD KIIA== X-Forwarded-Encrypted: i=1; AL+hErEzzYvlrlW9K5jYKN4O/HpjStQ5DjJptD8UYsdmSlLQupz7MFZr5XXI5ingby47s/8XWJXbJOrW6JThcSw=@vger.kernel.org X-Gm-Message-State: APuU4Z/pCs/cC6oi+dVcRYgMYvTu/Hu5tynlZyZbMaFIPo1KQiBMs2Wf fuePyr7oLeRN91oa3mtPedxff3lQ0sGdl+LyZnf2te034jtgoQlrdV5o X-Gm-Gg: AZFdTZdTn531bX/134kCa1LUrkctF0am0DsITBKbnTHaV9bt4efPqVMI0NJoG9j1DwN 21HoH9H9HRH/XriiyTLWc5vbQpHGP5SNPVaxezebEStZG4gg6eAc3TH2/nLyyBQ/ttvh1fuIZUZ 4f4g5hAktDMGt5tXzeMFZs876adpDNhAclThAfZRgU2IK1d4Ofkvgz+zsSSAhIBBAeDnMLbcATA GzExu1+8UxywWsVOc+BG8ynfsalgAtqm9VU7WsfToP+LpchPJzNJJ2WnMhef6Y0XGwJN1IuQgjZ oVd4N3Z5K/pZZuE2h+hGphZF1xRUYbEubY2nIkhe3KfzAgOjVkBGkJLl9c28WOfGIc0+4ad6nUD G4dy4zUjB0h4LC7eeFG+aiMAWSOtT0KzhxV3wJs6iIUXYa4ASYLCOI66UJ2T1lyE4R1WFtYbOum gO5SSh+BlJdtphFaqZJOXENwB/R7bodoCcxE2VWJUfjg9A7fK8XesdsAM4gHvBWRIPOFIltEc9h tv3Ftjd7CuZWrUyDIEj2wnPFrQqrukc2OypJOdkTdAqTC0LzsLo/XaQZy8nTT6cizNUgQNQzNQu dreU147TvfZaYh39SMtGNnjeXR+x0yunvZyJUTBh X-Received: by 2002:a05:600d:a:b0:4bb:aa4f:c01d with SMTP id 5b1f17b1804b1-4bbaa4fc151mr397945775e9.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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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