From: Michal Hocko <mhocko@kernel.org>
To: David Hildenbrand <david@kernel.org>
Cc: David Rientjes <rientjes@google.com>,
Ben Gardon <bgardon@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
mhocko@suse.com, Andrew Morton <akpm@linux-foundation.org>,
<linux-mm@kvack.org>, LKML <linux-kernel@vger.kernel.org>,
Chris Mason <mason@kernel.org>
Subject: [PATCH 04/10] mm/oom_kill: ratelimit memcg OOM reports with no victim
Date: Wed, 2 Dec 2026 10:53:57 +0100 [thread overview]
Message-ID: <20261202095450.296675-5-mhocko@kernel.org> (raw)
In-Reply-To: <20261202095450.296675-1-mhocko@kernel.org>
From: Chris Mason <mason@kernel.org>
A memory cgroup that is at its limit and has no killable task can flood
the kernel log with OOM reports, and delay the OOM killer for the rest
of the system.
When a memcg OOM finds no victim, out_of_memory() prints the whole OOM
report and returns false. Nothing was freed, so the next charge that
invokes the OOM killer, or the next write that sets memory.max below the
usage, prints the same report again. Each report is printed with
oom_lock held, which every other OOM in the system needs as well.
The fix used here is to rate limit the report of a memcg OOM with no
victim. All memory cgroups share that rate limit, so a cgroup
that keeps running into such an OOM can suppress the report of another
cgroup. If that turns out to be too limiting we can make this per memcg
but there doesn't seem to be a strong reason to go that way for now
Fixes: 3100dab2aa09 ("mm: memcontrol: print proper OOM header when no eligible victim left")
Signed-off-by: Chris Mason <mason@kernel.org>
[mhocko@suse.com: reworked the original patch]
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
mm/oom_kill.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 660ab39e1df5..7c97f788501d 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -1164,8 +1164,20 @@ bool out_of_memory(struct oom_control *oc)
select_bad_process(oc);
/* Found nothing?!?! */
if (!oc->chosen) {
- dump_header(oc);
- pr_warn("Out of memory and no killable processes...\n");
+ static DEFINE_RATELIMIT_STATE(memcg_rs, DEFAULT_RATELIMIT_INTERVAL,
+ DEFAULT_RATELIMIT_BURST);
+
+ /*
+ * A memcg oom does not panic, and its caller goes on. A memcg
+ * memcg with no killable task gets here with each charge that
+ * calls the oom killer, and with each write to memory.max, so do
+ * not dump each time.
+ */
+ if (!is_memcg_oom(oc) || __ratelimit(&memcg_rs)) {
+ dump_header(oc);
+ pr_warn("Out of memory and no killable processes...\n");
+ }
+
/*
* If we got here due to an actual allocation at the
* system level without any constrains, we cannot survive this
--
2.56.1
next prev parent reply other threads:[~2026-12-02 9:55 UTC|newest]
Thread overview: 11+ 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 ` Michal Hocko [this message]
2026-12-02 9:53 ` [PATCH 05/10] mm, oom: thaw tasks sharing the mm with the oom victim Michal Hocko
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 9:54 ` [PATCH 08/10] mm, " Michal Hocko
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 9:54 ` [PATCH 10/10] memcg: wake v1 OOM lock contenders on unlock 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=20261202095450.296675-5-mhocko@kernel.org \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bgardon@google.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mason@kernel.org \
--cc=mhocko@suse.com \
--cc=rientjes@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