From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,tj@kernel.org,stable@vger.kernel.org,
roman.gushchin@linux.dev,muchun.song@linux.dev,mkoutny@suse.com,
mhocko@suse.com,mhocko@kernel.org,hannes@cmpxchg.org,shakeel.butt@linux.dev,
akpm@linux-foundation.org
Subject: [merged mm-hotfixes-stable] memcg-free-the-private-id-of-a-memcg-that-never-comes-online.patch removed from -mm tree
Date: Tue, 01 Dec 2026 19:47:50 -0800 [thread overview]
Message-ID: <20261202034750.863351F00897@smtp.kernel.org> (raw)
In-Reply-To: <20261124000439.967403-1-shakeel.butt@linux.dev>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3754 bytes --]
The quilt patch titled
Subject: memcg: free the private ID of a memcg that never comes online
has been removed from the -mm tree. Its filename was
memcg-free-the-private-id-of-a-memcg-that-never-comes-online.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Shakeel Butt <shakeel.butt@linux.dev>
Subject: memcg: free the private ID of a memcg that never comes online
Date: Mon, 23 Nov 2026 16:04:39 -0800
mem_cgroup_alloc() reserves the private ID of a memcg when its css is
allocated. The ID is erased when the last reference to it is put, and
that reference is first taken in mem_cgroup_css_online(). The failure
paths of mem_cgroup_alloc() and mem_cgroup_css_online() erase the ID
themselves.
But css_create() can also fail after css_alloc() and before online_css():
in percpu_ref_init(), cgroup_idr_alloc() or css_rstat_init(). The memcg
is then freed through mem_cgroup_css_free() without ever coming online,
and nothing erases its ID. The reserved entry stays in
mem_cgroup_private_ids for good, and each such failure takes one of the
65,535 IDs away. With failslab failing radix tree node allocations during
mkdir, 1,500 mkdirs leaked 6 IDs this way.
Erase the ID in mem_cgroup_css_free() if the memcg never came online,
which is when (memcg->css.flags & CSS_RELEASED) will be false: it is only
set when an fully onlined memcg is released.
private_id_objcg was introduced in 7.4, so to backport the fix to
previous stable kernels, we will still need to use CSS_RELEASED or
something else there.
Link: https://patch.msgid.link/20261124000439.967403-1-shakeel.butt@linux.dev
Fixes: 73f576c04b94 ("mm: memcontrol: fix cgroup creation failure after many small jobs")
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song (ByteDance) <muchun.song@linux.dev>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: <stable@vger.kernel.org>
include/linux/cgroup.h | 5 +++++
mm/memcontrol.c | 7 +++++++
2 files changed, 12 insertions(+)
--- a/include/linux/cgroup.h~memcg-free-the-private-id-of-a-memcg-that-never-comes-online
+++ a/include/linux/cgroup.h
@@ -449,6 +449,11 @@ static inline bool css_is_online(struct
return css->flags & CSS_ONLINE;
}
+static inline bool css_is_released(struct cgroup_subsys_state *css)
+{
+ return css->flags & CSS_RELEASED;
+}
+
static inline bool css_is_self(struct cgroup_subsys_state *css)
{
if (css == &css->cgroup->self) {
--- a/mm/memcontrol.c~memcg-free-the-private-id-of-a-memcg-that-never-comes-online
+++ a/mm/memcontrol.c
@@ -4525,6 +4525,13 @@ static void mem_cgroup_css_free(struct c
irq_work_sync(&memcg->high_irq_work);
cancel_work_sync(&memcg->high_work);
free_shrinker_info(memcg);
+
+ /*
+ * The css_create() error path bypasses normal CSS release, leaving
+ * CSS_RELEASED clear. Drop any private ID that is still reserved.
+ */
+ if (!css_is_released(css))
+ mem_cgroup_private_id_remove(memcg);
mem_cgroup_free(memcg);
}
_
Patches currently in -mm which might be from shakeel.butt@linux.dev are
memcg-move-memoryhigh-enforcement-out-of-try_charge_memcg.patch
memcg-force-charges-from-reclaim-before-trying-the-limits.patch
memcg-use-high_work-for-kernel-threads.patch
memcg-use-high_work-for-remote-charges.patch
memcg-simplify-high-limit-handling-after-a-charge.patch
memcg-warn-when-memory-cgroup-ids-run-out.patch
prev parent reply other threads:[~2026-12-02 3:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 0:04 [PATCH] memcg: free the private ID of a memcg that never comes online Shakeel Butt
2026-11-24 0:54 ` Andrew Morton
2026-11-24 1:09 ` Shakeel Butt
2026-11-24 0:55 ` + memcg-free-the-private-id-of-a-memcg-that-never-comes-online.patch added to mm-hotfixes-unstable branch Andrew Morton
2026-11-24 2:50 ` [PATCH] memcg: free the private ID of a memcg that never comes online Muchun Song
2026-11-24 4:33 ` Shakeel Butt
2026-11-24 4:52 ` Muchun Song
2026-11-24 5:24 ` Shakeel Butt
2026-11-24 6:34 ` Muchun Song
2026-11-24 9:02 ` Michal Hocko
2026-11-24 17:54 ` Shakeel Butt
2026-12-02 3:47 ` Andrew Morton [this message]
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=20261202034750.863351F00897@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=mkoutny@suse.com \
--cc=mm-commits@vger.kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=stable@vger.kernel.org \
--cc=tj@kernel.org \
/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.