Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.68 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796073673; b=PkvZtMGLFmoWCVCGcaBa6Tk5prwkcFFjD7mlFULCMX5VE169g4WC+ik2vdQy7eaoGez9 fawG/37IaE/iZu82fr10HabH6Eagam30A+37SU6Wre2VLrVEnE15OVpwlYKZ9KjlufH06 T4NPSLYU0JkaII/2zL7MBshoTv7+of3Ft6w3n9BdjJ9NLhtwURV8hzkAIb84K2JDMQfZc g4A9FNEul/hOO3v/jaWPQS94nmNgv1b76iE7Kw+Vf+mZ59Vr35gyrdWvArFLRnwRHHnSY I2Fa1obZSb+wIlJAnBf3mcE5bqBZPpQ/Ff6wx19PIsFIqRbo8RissgdcZgGci6FItFw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796073673; 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=zvX2XaqDj+OzqL/7VhVoeuON7ye9RW3RArnB5rmWagg=; b=qQq2hC64olPtzvtwmkURmXP/6+GdnCp5rhXtGTeqA9YRxTw6+h3t73zr0YOeXqoICF1j tx5i5zU0Wp86ECWAwwd2GiylU6gs40xWMgFcVeNeea/BFHY1pWSC6YkDXXW2hzuro3yMl ZpSCObiWQby2CwaCtaTsNGtNYwseGeOV6ct37pvFqIlhwCPrV6/izDW4jAgBQ8hxaz9Jh Gy4ldQMTOo4gV9F/gfxE9ZbEJ4vwsDI7YeNC8xIlMkvIVPWfjGnpyQ+XgO4tAdAlbzbJ1 UWX59TDJyoGTdzwSVj1/91DWEoVQgW9tY01tzMWtTrqiH8Kif6j0S+XbbP5LLWk3FYw== 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=OLjQJABR; arc=none smtp.remote-ip=91.218.175.68 Received: from mta0.migadu.com (out-68.mta0.migadu.com [91.218.175.68]) (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 02F8E606A31A for ; Mon, 30 Nov 2026 21:21:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02F8E606A31A 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=OLjQJABR X-Envelope-To: sashiko-reviews@lists.linux.dev DKIM-Signature: a=rsa-sha256; bh=Fe1EQ0ys6EfbBo6b4hJ/qucjYuDsiGele/zxQIny1kQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796073669; v=1; x=1796678469; b=OLjQJABR9H1d1lBSILSTVfBeb0ajSHSgRLkBMtjYh/P3GEbCcxdOXS4f5G34DfX6LLMAPWd6 de4tyJsgUTxLy3tIwdDeKF6SxFA+ivD7yQZhWZLOJLXOBuSVUal0/XEtg3xpN3E+eEwkzsMxsGt s8SJ2eS9zG4YFZqr8PolBDUc= X-Envelope-To: sashiko-reviews@lists.linux.dev Received: by smtp.migadu.com with ESMTPS id 8aa683d52de08d13; Mon, 30 Nov 2026 21:21:09 +0000 X-Mizu-Trace-ID: 8aa683d52de08d13 X-Migadu-Flow: FLOW_OUT Date: Mon, 30 Nov 2026 13:21:04 -0800 From: Shakeel Butt To: sashiko-reviews@lists.linux.dev Cc: Tejun Heo , Andrew Morton , Johannes Weiner , Michal Koutny , Michal Hocko , Roman Gushchin , Christian Brauner , Oleg Nesterov , Sebastian Andrzej Siewior , Suren Baghdasaryan , "T . J . Mercier" , Usama Arif , Meta kernel team , linux-mm@kvack.org Subject: Re: [PATCH 8/9] cgroup: don't hold cgroup_mutex for cgroup.kill Message-ID: References: <20261129183524.1052436-1-shakeel.butt@linux.dev> <20261129183524.1052436-9-shakeel.butt@linux.dev> X-Mailing-List: sashiko-reviews@lists.linux.dev 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 Mon, Nov 30, 2026 at 06:36:20PM +0000, sashiko-bot@kernel.org wrote: [...] > Can a task in a subtree being killed escape SIGKILL if its migration > fails before this commit point? > Yes, Tejun reported the same issue. The bug is in css_task_iter and has been there since commit 5ee01f1a7343 ("cgroup: fix race between task migration and iteration"), so v2 fixes it in a separate patch. [...] > Does checking only cgrp->nr_subtree_kills miss kills running on an > ancestor or a descendant of cgrp? > > cgroup_kill() increments nr_subtree_kills only on the top cgroup of the > kill. If an ancestor of cgrp is being killed, cgrp->nr_subtree_kills is > 0, so cgroup_enable_threaded(cgrp) succeeds instead of returning -EBUSY > while the ancestor's kill walks cgrp. > This case is fine. cgrp joins the domain of its parent, which is inside the ancestor's tree, so any thread that can join cgrp belongs to a process that is entirely inside the tree being killed. This needs the ancestor to be a valid domain, which v2 makes sure of (see below). > Conversely, in a hierarchy root -> A -> B -> C where B is a thread root > (B->dom_cgrp == B, CGRP_THREADED clear) and C is threaded (C->dom_cgrp > == B), a kill on B sets B->nr_subtree_kills = 1 while > A->nr_subtree_kills is 0. If A, B, and C are empty, > cgroup_enable_threaded(A) passes this check and updates dsct->dom_cgrp > for all threaded descendants of A, moving C->dom_cgrp from B to root. A > thread of a process in root can then join C via cgroup.threads and have > its whole outside process killed by the ongoing kill of B. Yes, this one is real and reproducable. v2 went out before this review and still has it. In v3, a switch to threaded will fail with EBUSY while the cgroup, or any cgroup below it, is being killed. It also showed a related bug in mainline. After A switches, B is "domain invalid", but C can still take threads of outside processes, and cgroup.kill of B kills those processes. v3 will add a separate fix that refuses cgroup.kill below a threaded cgroup. I will wait for sashiko review for v2 before sending out the v3 (and maybe couple of days).