Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46CB83624D7 for ; Fri, 22 May 2026 20:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779483081; cv=none; b=iiFS81gdjvgh61USAqOn2pbNcnLLy12afGFz8fWvmkcNm7Wdvwr2w1fSnKVlsT3OiMbCk2Ik3rFKb2QrdqRn5p0EaiZs8Nk870s9bMInfk4HW5EM91YGls/hUGwn6tFizCnCpbpxxxdGTRTlNtU4BHe8EZJh0TSdrlbytq3rmTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779483081; c=relaxed/simple; bh=OVmhk5pLP7LMkx7s+EKVqZDLM8GTJjw/mRwqJJKA9B4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AAcjfMTxgqZleHCeb/nyrjUx5+ej2nLEEX1Aq3gcfzm4bOUl5ieOudU5Z26RLRGCIi8kbKz3fFbyXez0pny9YeBNj86g2CodkOKMaQU8CltF5UWNm+duXW82Xg6oKX4G+XKOItreQyuyeMvEzMULMRYLIpzFHfZ+vyzVl2ZOBc4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FVne7wMr; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FVne7wMr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77FFA1F000E9; Fri, 22 May 2026 20:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779483080; bh=67jdM6V+7WUFZtSDCoYSYPHfbRGuzmbWBpNsvjrn6Xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FVne7wMrpTfF+g5O1P09O1MJU3vNldpkE1KkfiOT/ZIQkeM45VH0EIoa/Rl/qttj1 7uyHHaIMY0lnAPm4HLNeZCiUeoyjgMP01/8O9MyldlBVLlKqtr5iIGBNpKdEefYLNl JxQnFL/SkBgx1/NAH21F+SeL1hev/GnND8vBR+0ZIcSjW3pZ050J8FzXUdEeQ40Kiq RcfuW16i4ij/le3ew5MYczS/vrj0JVkSe11TRyX2eF+Hq7l1eBhpNDgm8P9F9h0QB8 KOX9dSg6zV0Q6ZIrNPc3ikfnecWghFwNbeWjNK45n2cKnaEgvATYkT2m5wGZCjLiy/ pXr2GmaWCJHEQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Guopeng Zhang , Tejun Heo , Chen Ridong , Waiman Long , Sasha Levin Subject: [PATCH 6.1.y] cgroup/cpuset: Reset DL migration state on can_attach() failure Date: Fri, 22 May 2026 16:51:17 -0400 Message-ID: <20260522205117.4065831-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026051952-bunkbed-preschool-73aa@gregkh> References: <2026051952-bunkbed-preschool-73aa@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Guopeng Zhang [ Upstream commit 4a39eda5fdd867fc39f3c039714dd432cee00268 ] cpuset_can_attach() accumulates temporary SCHED_DEADLINE migration state in the destination cpuset while walking the taskset. If a later task_can_attach() or security_task_setscheduler() check fails, cgroup_migrate_execute() treats cpuset as the failing subsystem and does not call cpuset_cancel_attach() for it. The partially accumulated state is then left behind and can be consumed by a later attach, corrupting cpuset DL task accounting and pending DL bandwidth accounting. Reset the pending DL migration state from the common error exit when ret is non-zero. Successful can_attach() keeps the state for cpuset_attach() or cpuset_cancel_attach(). Fixes: 2ef269ef1ac0 ("cgroup/cpuset: Free DL BW in case can_attach() fails") Cc: stable@vger.kernel.org # v6.10+ Signed-off-by: Guopeng Zhang Signed-off-by: Tejun Heo Reviewed-by: Chen Ridong Reviewed-by: Waiman Long [ omitted upstream context line `cs->dl_bw_cpu = cpu;` ] Signed-off-by: Sasha Levin --- kernel/cgroup/cpuset.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index ecc5ebbcf9917..7e294d59bd1a3 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2579,16 +2579,13 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) int cpu = cpumask_any_and(cpu_active_mask, cs->effective_cpus); if (unlikely(cpu >= nr_cpu_ids)) { - reset_migrate_dl_data(cs); ret = -EINVAL; goto out_unlock; } ret = dl_bw_alloc(cpu, cs->sum_migrate_dl_bw); - if (ret) { - reset_migrate_dl_data(cs); + if (ret) goto out_unlock; - } } out_success: @@ -3401,7 +3398,10 @@ static int cpuset_can_fork(struct task_struct *task, struct css_set *cset) * changes which zero cpus/mems_allowed. */ cs->attach_in_progress++; + out_unlock: + if (ret) + reset_migrate_dl_data(cs); mutex_unlock(&cpuset_mutex); return ret; } -- 2.53.0