From mboxrd@z Thu Jan 1 00:00:00 1970 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 3EBB43CC310 for ; Fri, 22 May 2026 13:30:49 +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=1779456650; cv=none; b=UmFK0vA0uI7huGfcGGVa81h51UoM4PymrjvUVAlT6kNpFJe9Uq30qYt32DfFwJjmqi/7Nu+WuRtbcQ3ax5Z0vl8DwxxM8f3LuGxeyBEL8h2suEF3JrMAswE6nA3P5xTfexDMrOg1G8RTK7k+paSAYp26mehm92iu7+7rTMXdgy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779456650; c=relaxed/simple; bh=e/9d6B9sqMVKNk227oR0wde7OnrGfpu62Ho5/z5t4qs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WuLuufxpPMJN/vTOjH51Q2ztcydFHpgYJ40m8CO16rkSdTIeoBphesAIW6Z1kWc/oy1T03+KN3tLkVRqi3/EQ0mNX/qi+FQZCBSec4ry4KiuVe7d8S1i30kj3VP6Ovf6/YCOF3otR10bxiBiAQSBro6xPwckvpC8QN+VyomfHWM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jFf0HNSO; 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="jFf0HNSO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38CA71F000E9; Fri, 22 May 2026 13:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779456648; bh=7HT8pYU9JoU8cjz+ZQthA4Q8b/fIfqinY6UcYZSUP0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jFf0HNSOvZqU4KSeWFbrJrR/8tRPDj9pnZCEdGre/CfdeTJGc+n2HIPvl82UkJBml 3Cds8E1p+RFq1qgttQaWf388R/nu0eYQ+/bIHT0cCp4R2rVsJRh/6V8sga/b30Eccr /jPFbTDhd1420BCTwNY8HiOuAv3EgJzidZWEftDaXXEwTqbBkv6/NtYMxSl21LogA9 XCJtOhGVh5P/82qc6mOMB8gBzKJ8IYoXxDcIUtiCnl9qc2g6r0Pk+ok+MB1Nyii7bw G+CzvuLUfM0LdD1JKDm78TG2c4/PJXT5Zxrg+5ityILBi3U+qmwN2ZYsm9pG1w3scg o/Tb/WLKExRNg== From: Sasha Levin To: stable@vger.kernel.org Cc: Guopeng Zhang , Tejun Heo , Chen Ridong , Waiman Long , Sasha Levin Subject: [PATCH 6.6.y] cgroup/cpuset: Reset DL migration state on can_attach() failure Date: Fri, 22 May 2026 09:30:46 -0400 Message-ID: <20260522133046.3882842-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026051951-scheming-poking-d3a2@gregkh> References: <2026051951-scheming-poking-d3a2@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 3c466e7427516..633a91709eb54 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -2609,16 +2609,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: @@ -3458,7 +3455,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