From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.212 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795494818; b=luh7hzDmmiD8E23kIYk2C44ag1AongaGreohnAppg55CbyAWnMY+PC0vplr5L/++z3x5 MA2A7mD1E6FdMUmLfwqPzNZ88bd4SRAWU08UZtlm+3zngvFmrI6QzwC9SSFAC/T5UyD3l JBAc+sD5zn4trFy7X6BKkyuvpLKSgHJFnGiy0XjjTIVZ3PevE1Lj8AM6AnOerVF8cTeEm QyFcrQYiI7lN2Z1PsE/go3C/oAF8a+OnlweYfe0rmCjdgj7e/KVN+bgM8+OrYb8XVrGC7 bYEgI0xwIg044a86uFc6QdrfxoWEXFnRfhBOTKDwRbbSVwYJsxw/CVnnWB5G9KGkVyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795494818; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=qeS+Wqldyca7IlFeTqWB+yHVGIRNOofJMih/xkJzWH0=; b=H6GYfbF2V++Dr7iESjishyujDFVwMeJgPIN5UQQaJqhnAHpDj/D01hjbbAw8C3Vi/iJ4 Mkbe0If1grwZwe5z4h328ROCTTi5eOjztaKBBSpLRk9etnPUA+20AuGzh4nlbm7ccrsI+ H1SgZyMk/zFrrhRh0RV0d7pjlnZjqIKiX/zIjshBMkfw7mWuNnses4DLovtKogEirYMP/ 6M6On9Wb4vp9z/FRj8bFj4hpYo05SueNWgWQdOTajhtmGwToshAlYhN18ChPWnTy3Gk7O jHgVlsDJBO30QmJH8jjvWFyzSw1b4AasGj430JDN7Zj+W5WAW/QQP80O+xK8HWO+8gQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=EChO5xkU; arc=none smtp.remote-ip=91.218.175.212 Received: from mta0.migadu.com (out-212.mta0.migadu.com [91.218.175.212]) (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 7A78A606A322 for ; Tue, 24 Nov 2026 04:33:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7A78A606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=EChO5xkU X-Envelope-To: stable@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=XrJqniAxtYnOjs6qtgcphsG7K6LdaIDb/mHKEP/nTBc=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795494815; v=1; x=1796099615; b=EChO5xkUCstUOXGGiv9FCZ+/EkSHyKCcChaKP++g+zGEeyhOUnEGUMZvsDHJpcs2y2dHouLE b0RxfeAV6fIkbBQc0izTiZA/u8hLON+4WUir1N5L37zz0r5EwLjvahELnjzlOaM76zpU9suNOdu JLzoHdnuzLhmAShdbG7m3ZKE= X-Envelope-To: stable@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 40e2dd995e1bde24; Tue, 24 Nov 2026 04:33:34 +0000 X-Mizu-Trace-ID: 40e2dd995e1bde24 X-Migadu-Flow: FLOW_OUT Date: Mon, 23 Nov 2026 20:33:33 -0800 From: Shakeel Butt To: Muchun Song Cc: Andrew Morton , Tejun Heo , Johannes Weiner , Michal Koutny , Michal Hocko , Roman Gushchin , Meta kernel team , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] memcg: free the private ID of a memcg that never comes online Message-ID: References: <20261124000439.967403-1-shakeel.butt@linux.dev> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Nov 24, 2026 at 10:50:00AM +0800, Muchun Song wrote: > > > > On Nov 24, 2026, at 08:04, Shakeel Butt wrote: > > [...] > > The leak analysis and the fix look correct to me. However, using > CSS_RELEASED here makes the private ID cleanup depend on a generic CSS > teardown state, and adds an accessor solely for this failure path. > > The private ID is not needed until mem_cgroup_css_online(), so could we > instead reserve it at the beginning of that callback? Failures in > css_create() before ->css_online() would then never own a private ID, > while failures after the reservation would continue to use the existing > mem_cgroup_private_id_remove() cleanup. > > This would also make the private ID lifecycle more explicit: reserve and > publish it during online, then drop the initial reference during offline. > It would avoid both the new css_is_released() helper and special handling > in mem_cgroup_css_free(). Thanks Muchun. Nothing needs the private ID before ->css_online(), so reserving it there would work. But it moves the out-of-IDs failure from ->css_alloc() to ->css_online(). By then css_create() has linked the css into the parent's children list and css_idr, so mem_cgroup_iter() can css_tryget() it and cache it in iter->position. A css that fails online is freed without ->css_released(), so invalidate_reclaim_iterators() never runs, and the free does not wait for those references. Today memcg's ->css_online() fails only when a small allocation fails. With the move, every mkdir on a system that is out of IDs would take that path. I would rather keep failing in ->css_alloc(), before anything is visible. To drop the CSS_RELEASED dependency, I can test the ID's own state: !memcg->private_id_objcg means the ID was never published and the memcg still owns the reservation. Let me know if that works for you.