From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796183271; b=UNJUDBGJZVb5MYkg2vA2bBMMfxVIq7PIfOlZhaimY0TmC0DJl5meSsufOMpOSekU1/bR +I0M7QrzOovjrJLsA6amsGa1HdIAPx1nhQMBVP5Rz4QSxHmf3fO3v/YTEgI0jGtldbfI5 /1G8ppNbxJM/I8TOezis5tnsR6+Cv9Iy8PB9jNWn+fSJubhkd/QMOTcCWmqm59ldnl3OJ andQJOfr5ST6cOTw1onUEy511wKgxvGFt3XP5frIFNXS8pXw9y5ilKRWC0Pc/ln4wSMRP 3SxLUtnM44ixW1v7q5KoOU5daxQuueBllpUGUIcmeDoRoCWC5hv7UuOzkWSOHC1OjMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796183271; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=3VkANBXVEDZznIM8ObwHBJG20aZvyQeP+ept75tvyNo=; b=m+K+fGPMQeCZGGLIjZs127Tp10G3hN25CFbW7oOKKYwg6LR+r1Zkn3khAoYLF4jJ5icn EfnJGMBMyxTouLt1LLT4UhaTLs/Vak7R7WVA4F1EX0nv3hXbDZ/wfT4iNh8PN/7xvTdL6 8lswvzlkCV+/Zl+U3YIgT+aPkzy13yWugt2j6Lx3EplF+RqSKxqCBpKM/eUAk6fz1+RaB ZvCQv8EsICkHZO/gDk1hAsb2enDfi7jg8HY/JzOl53v32Ajjg3myV5OCW33wVuquEn/kb IIV9+FXNTJyp1B67DMom9C3qmMny4o9rWKqyBO9YN/Y6tW1tddo45f/pX0DrK9Eu5GQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=fxk5faPg; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AF25606A31A; Wed, 2 Dec 2026 03:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=fxk5faPg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 863351F00897; Wed, 2 Dec 2026 03:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796183270; bh=3VkANBXVEDZznIM8ObwHBJG20aZvyQeP+ept75tvyNo=; h=Date:To:From:In-Reply-To:References:Subject; b=fxk5faPgSn2o6M0XzBcYVxknRh4/gNNX3+o/QAmqegJ/r73eQVWNm+yK1VpgVDV+1 U1ENQixgd4t+tL0LVmJePXiWJjunmUWeE7Uamtic4Ls0gueZpTNCSlNX4RDUR4g2Xc GWdXYIIskvv5jWO5IPrlbarCJpGQ6Vlfev5r+cMs= Date: Tue, 01 Dec 2026 19:47:50 -0800 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 From: Andrew Morton In-Reply-To: <20261124000439.967403-1-shakeel.butt@linux.dev> References: <20261124000439.967403-1-shakeel.butt@linux.dev> Subject: [merged mm-hotfixes-stable] memcg-free-the-private-id-of-a-memcg-that-never-comes-online.patch removed from -mm tree Message-Id: <20261202034750.863351F00897@smtp.kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 Signed-off-by: Andrew Morton Acked-by: Muchun Song (ByteDance) Acked-by: Michal Hocko Cc: Tejun Heo Cc: Johannes Weiner Cc: Michal Koutný Cc: Michal Hocko Cc: Roman Gushchin Cc: 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