From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796205300; b=G5FlbGN642jfzbHlFPoZJOz+RijQLxXzrY7RTc8KfisJunpMYyaCO+85lM17u5wXj068 4GM0KBdDe814VabujblkqS40CQiv0kz11OQjkfxtWM2vQPgFQp9HJDWpYnMF+e4HsyncP 70qC+CVuSUomN53gSI4DNX+rnRI8zL/myNHSXufy72LAmofCJzP4o99Dyw4GXEOWCi7cS yyIbe5oA2ZDbJ43A2Kcb75WRIp9zOlnIT60bdE5ruKrb7ltfIai7rd4kjR6LfGCj9vM1s eXESgFRGSOx45xAbKfubZ9ibL4PHF47AesBeuJCCo6nB/lBeAHe/GlKnvPdnkQrUQUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796205300; 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=pyqTKmm5XBbMYJkB5SH5ritgMPU91C00gU303z4QyAE=; b=M7tvef+uc8TSkV+8d1g32b1yfmQilw9Z9k4khc2pmV6/RWIoLaF/ZvtyvMQgHM6+GYpe EExdRI8QIsR/fVEZrtdyAPm+aL59G/+fIJcKyBqc+bpERnBjwsO2tE7+HB3n4VtpJobk9 +eSiTvxW9b1oBoTEXniqVckFUbSzA7/XNtQriobc5n1oXaXVA4tBxCokGsUT4WfJVEghb M4GPfDhUzLf+3lxI2uEXwz2Nkr2qHTOP57YyDOERl99EjeS+wvW+iho4zIIBFfSWv5WuJ 609SLpBOFybcORM1Nrjxvn7AbXMIZQBi+t/451LJXdV6rtSaooWy4MJpdqUl+kMJ4Vg== 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.43 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 5EE71606A68F for ; Wed, 2 Dec 2026 09:54:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5EE71606A68F 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-f43.google.com with SMTP id 5b1f17b1804b1-4b467581b98so118996195e9.0 for ; Wed, 02 Dec 2026 01:54:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796205298; x=1796810098; 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=pyqTKmm5XBbMYJkB5SH5ritgMPU91C00gU303z4QyAE=; b=vrjeVrfd+nsTimZVzNuZyHyHEFjO6Uk6jpnHLOPCULwy/Fs2dm1X+qZ6K4EX/dZ8HX CMxLIH9u0NgNyHUQtQyANri3B2+Ng6Tya/aIupn70icIX96NoQczZ3pW8GipMzWfibXL gmwiaK9rhsfikT2t30sV2PIWI1wE7wd+HTOO8GNygT9bSwWUW51JbeBpgD0UvOz7vNTH FTTKo2IaP9ZK0h48Mf+ygDbv0AaQ/rxG/hG+KefIyS06Cjhrb8L/Yc+zJAKDy260iUmw i67rr735jexcnm8SWBgbUCv02LQYKgZwwWf6xrRKNE6FT1S2gtb14wDPKNkJEUtDrR0o nyLw== X-Forwarded-Encrypted: i=1; AL+hErFuZXPQRqBrcojZ0Z7z33csInmbyrPbY2k8yybIVhYz7uVxeUaL6IeJFEtyY/at/xSg6ix6h93Ze6emPO0=@vger.kernel.org X-Gm-Message-State: APuU4Z+8QSNG5IAlyJYgeLBPmkVXPgRFMM2zN0Pj0Dhz++czTb106ghd vonGUS4iTM7XbWq4bkcnCg87PccJbJtmXviz8NHVJ4qoE48UgUCO+031 X-Gm-Gg: AZFdTZeE3Fg4SYpxegbPlNd1bURgETw+FEFeJhk5+oz+kuiqwpIZcGGJUztW7XyLmXm tV/UFgCnXk+WuXohA2LntwVQIoE6W3TkcA9aZDPTLSHaJKLxFAeCWva4dRGKMYAWxiAWGKc9YGc vZxjgdOumjBMCQsGQnejfmTIfkxBbyR3EgmJ3477kp3noR54LmjuvlkTTqfvHJZfcrLYIghVOg8 NQxxmoIY8+ct8n2q0E0eHfETbJpDlli8STmM+9KKrduVespysptkmfqQBMj+HCJ+pJxHlLC9Pzo YCPWKp2tZFfRSCY/lPKLRDAS3q+j3TF1RFu7fUqpwt1amDKE5MOWAm+sVDeGvuEDprWVFlIDHVR RjEV9atyDJVKEpih8GzMDMCZCnHbcsK4pJgoFs6G1dzUlO5ratKLErAo8aFhyyJnllRenAY7pBW tQB/NMyZogCDG6YlvjkXhKO+vRWEFDCw4ugdnFTUCmiIgSGaj1QTODmLw1Rm4Czb9OCzMuikdmJ KpTWrMnt+kSR9fUz5jKG3p5oZHvuBsk4l12AkJFxwjXWSYKC1EQ5CkkQGNE9K6UFLpolJp6HzIm jsmxmfMXZkHTEhDCjsjFQCYhCi3I0ubgSwV0iNwG X-Received: by 2002:a05:600c:b90:b0:4a7:76fa:87e9 with SMTP id 5b1f17b1804b1-4bb8892cb02mr771654075e9.21.1796205298349; Wed, 02 Dec 2026 01:54:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 01:54:58 -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 04/10] mm/oom_kill: ratelimit memcg OOM reports with no victim Date: Wed, 2 Dec 2026 10:53:57 +0100 Message-ID: <20261202095450.296675-5-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 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 [mhocko@suse.com: reworked the original patch] Signed-off-by: Michal Hocko --- 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