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=1796134513; b=auyf1v39QBYoxRAmBXd1YQvO0OfiMMypmRlAVoDl/f00JjctIEyuWrWf+Laz5AUalJLs eKAMWauz/phl49T8PAtBdgL5QMmdS9PJZ/BUx+9qx41AqSeOzbyA2jgpXPwRk/tPS3paO 3mjnnFuTHvFYO2bT4P1rnBh9QqtJcOn/lx+Ag5sk66MwMd78Wi60bNvAzhM2bFNkFfJ4v RxwzS5TPWHAWHwGlkDA9SHcjkFeTwHjbJKxx4ip91xqMGmrP45RNRNbtrJ4hxVQ7Uf4H+ 6tHKmJ26J64jOut8v73K57hV/FLm1aoBoZQJMvZBqSsr1H5XMUkvrBnTCgmABMy4+KA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796134513; h=Received:DKIM-Signature:Date:Message-ID:From:To:Cc:Subject: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=LmrlpQR+GkV6fGbhzlJ0yD8Cu2uyMURFut1dSLcpI4o=; b=WxCreS96PbQIVbyBrvFiZ5YQ4XZfOMGHA6XdudyYRcFQ/P5YBJGxVxGqFbd4jgVTEo20 ocVPAt8GkxXV2G6Dac06sTHnx6mzpb61Jjqi4Vwmb56BfY5G5dhb3zb+qB33MsA2KWm2H TS93ztf67qOg5r67V91WOEqtfZN/rC448yLUnPv751JV3iLqhnl+eK2LyBdIZjswDJxre vAublszHpOtHq9JZwOb03x9nVNiDmTugzR5zDyCY+I2Y6/s1ftZOq0EzcfFV9XOfP1rQ3 4bJD2LroJIVW+Yhr4hJKf9zReeSmJhBJCoi+gwSSPp210dVR+JYlpDrG5V+lFPNxyVw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WvLeTOB6; 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 76FCA606A32D; Tue, 1 Dec 2026 14:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WvLeTOB6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E57841F00893; Tue, 1 Dec 2026 14:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796134513; bh=LmrlpQR+GkV6fGbhzlJ0yD8Cu2uyMURFut1dSLcpI4o=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=WvLeTOB63p6VL3PMB0ClF/M9yshdxJ1an+Hbm1Du4QQKi1VBOlfvZtODeD+d4KqGf U8K9lFp5XQP45+nt6LLg/LpnyeIg6xOFYOOqHuuxMczy4ClR/PLzF8UmKJ53PWbq2J BXJcdHCooIq3Yxju93gjWYBWusNW6O3eVbN8dsLycVIFdlOJpXgnw1C+u2NBMZRI2G SBQdTwB0miBKEPjVATdDULDfHy+bAxJ6rnUgzKB0JhUpar64UiKmrP8rFmX4K5ucwe mIX5uzSrstzYfCCLUg7rVfFSHV4uQXljuxl17wg6J/ZXdcqXf9qbucZbyOvUkpWjRS D6HemB66Yh1Fw== Date: Tue, 01 Dec 2026 04:15:12 -1000 Message-ID: From: Tejun Heo To: Hu Xinyao Cc: Johannes Weiner , Michal Koutny , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cgroup: Publish css ID after online_css() succeeds in css_create() In-Reply-To: <25ABE1D5225B64B1+1796116222.35099.6566-huxinyao@kylinsec.com.cn> References: <25ABE1D5225B64B1+1796116222.35099.6566-huxinyao@kylinsec.com.cn> 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-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello, Xinyao. On Tue, Dec 01, 2026 at 06:10:22PM +0900, Hu Xinyao wrote: > None of the subsystem ->css_online() callbacks look up the new css via > ss->css_idr, and css->id itself is already assigned by > cgroup_idr_alloc(). Move cgroup_idr_replace(&ss->css_idr, css, css->id) > to after online_css(css) succeeds so a failed css_create() keeps the > IDR slot as NULL until css_free_rwork_fn() removes the ID reservation. The ordering is intentional. A css should become visible to iteration and ID lookups before it goes online and stay visible while it's online. With this change, a css which is already online can't be found by its ID for a while. This means that both iteration and ID lookups can yield a css which isn't online, and the users need to be able to handle that. AFAICS, the problem here is that the failure path of css_create() frees the css without honoring its refcnt. Maybe the failure path should honor the refcnt like the regular destruction path does? Thanks. -- tejun