From nobody Sat Jun 13 13:41:46 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 7F7773EAC7F; Thu, 7 May 2026 10:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778150028; cv=none; b=kT2pwVDNkDWyztCGBzgjMck0f8cIeOpWYGKMDcxdM5vuX/kYNd7uGycAVF46n62oa8jopSSYUFQGYGoeriNPyrJETl11eakvv5fH2AI1fy435E7BAlL0jvplDGGC64tKIclMRJn2hQOHqLwXlb1JGpobph3dBvmDmODFoeTdzTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778150028; c=relaxed/simple; bh=ndiEryJF5dr5yvqHEXyiGLSxHDdoz5PI8alJ2XM4J3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=go6UJAlif8otzWLAMV3qE2cPvTvTGL/hnvyljkQGHGJlLQlKy5ATYBEtaTxS83EdZUAD1nuFiBIsyVD/ZXPcfgN5xAeIbNmXuGWeuudTy5MDiJ/WQYEfTb8orU59E9hroIiOPXIRpAej/paDCvXDBrXrg34KNz3MFBz6hk5KxIU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 36e4e6984a0011f1aa26b74ffac11d73-20260507 X-CTIC-Tags: HR_CC_COUNT, HR_CC_DOMAIN_COUNT, HR_CC_NAME, HR_CC_NO_NAME, HR_CHARSET HR_CHARSET_NUM, HR_CTE_8B, HR_CTT_MISS, HR_DATE_H, HR_DATE_WKD HR_DATE_ZONE, HR_FROM_NAME, HR_SJ_DIGIT_LEN, HR_SJ_LANG, HR_SJ_LEN HR_SJ_LETTER, HR_SJ_NOR_SYM, HR_SJ_PHRASE, HR_SJ_PHRASE_LEN, HR_SJ_WS HR_TO_CHARSET, HR_TO_CHARSET_NUM, HR_TO_COUNT, HR_TO_DOMAIN_COUNT, HR_TO_NAME IP_TRUSTED, SRC_TRUSTED, DN_TRUSTED, SA_TRUSTED, SA_EXISTED SN_TRUSTED, SN_EXISTED, SPF_NOPASS, DKIM_NOPASS, DMARC_NOPASS CIE_GOOD, CIE_GOOD_SPF, GTI_FG_BS, GTI_RG_INFO, GTI_C_BU AMN_GOOD, ABX_MISS_RDNS X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:67c84829-f2f0-46b7-99ff-2eab38ed5cdc,IP:10, URL:0,TC:0,Content:0,EDM:-25,RT:0,SF:-5,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:-20 X-CID-INFO: VERSION:1.3.12,REQID:67c84829-f2f0-46b7-99ff-2eab38ed5cdc,IP:10,UR L:0,TC:0,Content:0,EDM:-25,RT:0,SF:-5,FILE:0,BULK:0,RULE:NOTI_GNA5D1EA,ACT ION:release,TS:-20 X-CID-META: VersionHash:e7bac3a,CLOUDID:043c4f255d97e4cbabd971c6bab067c9,BulkI D:260507183342ED2WP7B0,BulkQuantity:0,Recheck:0,SF:17|19|38|66|78|81|82|10 2|127|898,TC:nil,Content:0|15|50,EDM:2,IP:-2,URL:0,File:nil,RT:nil,Bulk:ni l,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE :0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 36e4e6984a0011f1aa26b74ffac11d73-20260507 X-User: zhangguopeng@kylinos.cn Received: from yan.. [(223.70.159.239)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1601359917; Thu, 07 May 2026 18:33:40 +0800 From: Guopeng Zhang To: Waiman Long , Tejun Heo , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Ingo Molnar , Peter Zijlstra , Juri Lelli Cc: Chen Ridong , Johannes Weiner , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Gabriele Monaco , Will Deacon , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Guopeng Zhang Subject: [PATCH v2 1/2] cgroup/cpuset: reset DL migration state on can_attach() failure Date: Thu, 7 May 2026 18:33:09 +0800 Message-ID: <20260507103310.35849-2-zhangguopeng@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507103310.35849-1-zhangguopeng@kylinos.cn> References: <20260507103310.35849-1-zhangguopeng@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 before returning from those per-task failure paths. Fixes: 2ef269ef1ac0 ("cgroup/cpuset: Free DL BW in case can_attach() fails") Signed-off-by: Guopeng Zhang --- kernel/cgroup/cpuset.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index e3a081a07c6d..ae41736399a1 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3029,12 +3029,12 @@ static int cpuset_can_attach(struct cgroup_taskset = *tset) cgroup_taskset_for_each(task, css, tset) { ret =3D task_can_attach(task); if (ret) - goto out_unlock; + goto out_reset_dl_data; =20 if (setsched_check) { ret =3D security_task_setscheduler(task); if (ret) - goto out_unlock; + goto out_reset_dl_data; } =20 if (dl_task(task)) { @@ -3070,6 +3070,10 @@ static int cpuset_can_attach(struct cgroup_taskset *= tset) * changes which zero cpus/mems_allowed. */ cs->attach_in_progress++; + goto out_unlock; + +out_reset_dl_data: + reset_migrate_dl_data(cs); out_unlock: mutex_unlock(&cpuset_mutex); return ret; --=20 2.43.0 From nobody Sat Jun 13 13:41:46 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 178853DCD8F; Thu, 7 May 2026 10:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778150032; cv=none; b=Tqx7NPT7uUoq9JMHdIktJqySQkaLVcEbHX6/HQEtHPR1XewGuK+Tp/izuZJZ1pDBQUDZ9K4vp1sSiBIs/xJkVsBUjaT2uAcASgyFaRT4PrzmNU6SViEZEbtHZStyikaGvDdm+fHU0eXLN82x9wggZHGTMbAWHgt3vJf7HFfRB8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778150032; c=relaxed/simple; bh=L7crFI2zyS6MxDSIiAIkP1ykGXokQTs/tyAqvbXIfq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cb5Sk0GMUhfe6CplLEKXFBU3/+uS8Bmcdg7nma/NbxP0IqcHkJD1vIwUEUVrgOGo27pEX7QO9x62v3TLRxPGBt0OW7XXcVVvzSsrTDJ5fxTYY+y3kPvFESAzAouHKMQ7Gdi5WGAsObxKoTmEdF1xedeX9JUVQe/y7oWvxiSPCNE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 388e48864a0011f1aa26b74ffac11d73-20260507 X-CTIC-Tags: HR_CC_COUNT, HR_CC_DOMAIN_COUNT, HR_CC_NAME, HR_CC_NO_NAME, HR_CHARSET HR_CHARSET_NUM, HR_CTE_8B, HR_CTT_MISS, HR_DATE_H, HR_DATE_WKD HR_DATE_ZONE, HR_FROM_NAME, HR_SJ_DIGIT_LEN, HR_SJ_LANG, HR_SJ_LEN HR_SJ_LETTER, HR_SJ_NOR_SYM, HR_SJ_PHRASE, HR_SJ_PHRASE_LEN, HR_SJ_WS HR_TO_CHARSET, HR_TO_CHARSET_NUM, HR_TO_COUNT, HR_TO_DOMAIN_COUNT, HR_TO_NAME IP_TRUSTED, SRC_TRUSTED, DN_TRUSTED, SA_TRUSTED, SA_EXISTED SN_TRUSTED, SN_EXISTED, SPF_NOPASS, DKIM_NOPASS, DMARC_NOPASS CIE_GOOD, CIE_GOOD_SPF, GTI_FG_BS, GTI_RG_INFO, GTI_C_BU AMN_GOOD, ABX_MISS_RDNS X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:9e4a426b-a61c-400a-b065-7af60dacdca2,IP:10, URL:0,TC:0,Content:-25,EDM:-25,RT:0,SF:-5,FILE:0,BULK:0,RULE:Release_Ham,A CTION:release,TS:-45 X-CID-INFO: VERSION:1.3.12,REQID:9e4a426b-a61c-400a-b065-7af60dacdca2,IP:10,UR L:0,TC:0,Content:-25,EDM:-25,RT:0,SF:-5,FILE:0,BULK:0,RULE:NOTI_GNA5D1EA,A CTION:release,TS:-45 X-CID-META: VersionHash:e7bac3a,CLOUDID:fa1bf34dace54d100d63fe38e7e6cf9f,BulkI D:260507183345LG2WC2XW,BulkQuantity:0,Recheck:0,SF:17|19|38|66|78|81|82|10 2|127|898,TC:nil,Content:0|15|50,EDM:2,IP:-2,URL:0,File:nil,RT:nil,Bulk:ni l,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE :0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 388e48864a0011f1aa26b74ffac11d73-20260507 X-User: zhangguopeng@kylinos.cn Received: from yan.. [(223.70.159.239)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 2082339759; Thu, 07 May 2026 18:33:43 +0800 From: Guopeng Zhang To: Waiman Long , Tejun Heo , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Ingo Molnar , Peter Zijlstra , Juri Lelli Cc: Chen Ridong , Johannes Weiner , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Gabriele Monaco , Will Deacon , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Guopeng Zhang Subject: [PATCH v2 2/2] cgroup/cpuset: align DL bandwidth reservation with attach target mask Date: Thu, 7 May 2026 18:33:10 +0800 Message-ID: <20260507103310.35849-3-zhangguopeng@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507103310.35849-1-zhangguopeng@kylinos.cn> References: <20260507103310.35849-1-zhangguopeng@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" cpuset_can_attach() preallocates destination SCHED_DEADLINE bandwidth before the attach commit point, while set_cpus_allowed_dl() later subtracts bandwidth from the source root domain when the task affinity is actually updated. Those two decisions must be made with the same CPU mask. cpuset_can_attach() used the destination cpuset effective mask directly, but cpuset_attach_task() first builds a per-task target mask which is constrained by task_cpu_possible_mask() and, if needed, by walking up the cpuset hierarchy. On asymmetric systems, the actual target mask can therefore be a strict subset of cs->effective_cpus. If the source root domain intersects cs->effective_cpus only on CPUs outside the task's possible mask, can_attach() can skip the destination reservation even though set_cpus_allowed_dl() later sees a real root-domain move and subtracts from the source domain. Extract the root-domain bandwidth-move test used by set_cpus_allowed_dl() into dl_task_needs_bw_move(), and make cpuset_can_attach() compute the same per-task target mask that cpuset_attach_task() applies. Keep nr_migrate_dl_tasks counting all migrating deadline tasks for cpuset DL task accounting. Restrict sum_migrate_dl_bw to the subset of tasks that need destination root-domain bandwidth reservation, because a deadline task can move between cpusets without moving bandwidth between root domains. This keeps the existing per-attach aggregate reservation model; it only changes the per-task mask used to decide which tasks contribute to that aggregate. The broader can_attach()/attach() transaction window is left unchanged. Fixes: 431c69fac05b ("cpuset: Honour task_cpu_possible_mask() in guarantee_= online_cpus()") Fixes: 2ef269ef1ac0 ("cgroup/cpuset: Free DL BW in case can_attach() fails") Signed-off-by: Guopeng Zhang --- include/linux/sched/deadline.h | 9 +++ kernel/cgroup/cpuset-internal.h | 1 + kernel/cgroup/cpuset.c | 97 ++++++++++++++++++++++----------- kernel/sched/deadline.c | 13 ++++- 4 files changed, 86 insertions(+), 34 deletions(-) diff --git a/include/linux/sched/deadline.h b/include/linux/sched/deadline.h index 1198138cb839..ddfd5216f3fc 100644 --- a/include/linux/sched/deadline.h +++ b/include/linux/sched/deadline.h @@ -33,6 +33,15 @@ struct root_domain; extern void dl_add_task_root_domain(struct task_struct *p); extern void dl_clear_root_domain(struct root_domain *rd); extern void dl_clear_root_domain_cpu(int cpu); +/* + * Return whether moving DL task @p to @new_mask requires moving DL + * bandwidth accounting between root domains. This helper is specific to + * DL bandwidth move accounting semantics and is shared by + * cpuset_can_attach() and set_cpus_allowed_dl() so both paths use the + * same source root-domain test. + */ +bool dl_task_needs_bw_move(struct task_struct *p, + const struct cpumask *new_mask); =20 extern u64 dl_cookie; extern bool dl_bw_visited(int cpu, u64 cookie); diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-interna= l.h index bb4e692bea30..f7aaf01f7cd5 100644 --- a/kernel/cgroup/cpuset-internal.h +++ b/kernel/cgroup/cpuset-internal.h @@ -167,6 +167,7 @@ struct cpuset { */ int nr_deadline_tasks; int nr_migrate_dl_tasks; + /* DL bandwidth that needs destination reservation for this attach. */ u64 sum_migrate_dl_bw; /* * CPU used for temporary DL bandwidth allocation during attach; diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index ae41736399a1..78c1a4071cc3 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -485,6 +485,30 @@ static void guarantee_active_cpus(struct task_struct *= tsk, rcu_read_unlock(); } =20 +/* Compute the effective CPU mask cpuset_attach_task() will apply to @tsk.= */ +static void cpuset_attach_task_cpus(struct cpuset *cs, struct task_struct = *tsk, + struct cpumask *pmask) +{ + const struct cpumask *possible_mask =3D task_cpu_possible_mask(tsk); + + lockdep_assert_cpuset_lock_held(); + + if (cs =3D=3D &top_cpuset) { + cpumask_andnot(pmask, possible_mask, subpartitions_cpus); + return; + } + + if (WARN_ON(!cpumask_and(pmask, possible_mask, cpu_active_mask))) + cpumask_copy(pmask, cpu_active_mask); + + rcu_read_lock(); + while (!cpumask_intersects(cs->effective_cpus, pmask)) + cs =3D parent_cs(cs); + + cpumask_and(pmask, pmask, cs->effective_cpus); + rcu_read_unlock(); +} + /* * Return in *pmask the portion of a cpusets's mems_allowed that * are online, with memory. If none are online with memory, walk @@ -2986,6 +3010,14 @@ static void reset_migrate_dl_data(struct cpuset *cs) cs->dl_bw_cpu =3D -1; } =20 +/* + * Protected by cpuset_mutex. cpus_attach is used by the can_attach/attach + * paths but we can't allocate it dynamically there. Define it global and + * allocate from cpuset_init(). + */ +static cpumask_var_t cpus_attach; +static nodemask_t cpuset_attach_nodemask_to; + /* Called by cgroups to determine if a cpuset is usable; cpuset_mutex held= */ static int cpuset_can_attach(struct cgroup_taskset *tset) { @@ -2993,7 +3025,7 @@ static int cpuset_can_attach(struct cgroup_taskset *t= set) struct cpuset *cs, *oldcs; struct task_struct *task; bool setsched_check; - int ret; + int cpu =3D nr_cpu_ids, ret; =20 /* used later by cpuset_attach() */ cpuset_attach_old_cs =3D task_cs(cgroup_taskset_first(tset, &css)); @@ -3038,32 +3070,47 @@ static int cpuset_can_attach(struct cgroup_taskset = *tset) } =20 if (dl_task(task)) { + /* + * Count all migrating DL tasks for cpuset task accounting. + * Only tasks that need a root-domain bandwidth move + * contribute to sum_migrate_dl_bw. + */ cs->nr_migrate_dl_tasks++; - cs->sum_migrate_dl_bw +=3D task->dl.dl_bw; + cpuset_attach_task_cpus(cs, task, cpus_attach); + + if (dl_task_needs_bw_move(task, cpus_attach)) { + /* + * Keep the existing aggregate reservation model. + * Tasks in one attach enter the same destination + * cpuset, so the first CPU found for a task needing + * DL bandwidth reservation identifies the destination + * root domain. + */ + if (cpu >=3D nr_cpu_ids) + cpu =3D cpumask_any_and(cpu_active_mask, + cpus_attach); + cs->sum_migrate_dl_bw +=3D task->dl.dl_bw; + } } } =20 - if (!cs->nr_migrate_dl_tasks) + if (!cs->sum_migrate_dl_bw) goto out_success; =20 - if (!cpumask_intersects(oldcs->effective_cpus, cs->effective_cpus)) { - int cpu =3D cpumask_any_and(cpu_active_mask, cs->effective_cpus); - - if (unlikely(cpu >=3D nr_cpu_ids)) { - reset_migrate_dl_data(cs); - ret =3D -EINVAL; - goto out_unlock; - } - - ret =3D dl_bw_alloc(cpu, cs->sum_migrate_dl_bw); - if (ret) { - reset_migrate_dl_data(cs); - goto out_unlock; - } + if (unlikely(cpu >=3D nr_cpu_ids)) { + reset_migrate_dl_data(cs); + ret =3D -EINVAL; + goto out_unlock; + } =20 - cs->dl_bw_cpu =3D cpu; + ret =3D dl_bw_alloc(cpu, cs->sum_migrate_dl_bw); + if (ret) { + reset_migrate_dl_data(cs); + goto out_unlock; } =20 + cs->dl_bw_cpu =3D cpu; + out_success: /* * Mark attach is in progress. This makes validate_change() fail @@ -3099,23 +3146,11 @@ static void cpuset_cancel_attach(struct cgroup_task= set *tset) mutex_unlock(&cpuset_mutex); } =20 -/* - * Protected by cpuset_mutex. cpus_attach is used only by cpuset_attach_ta= sk() - * but we can't allocate it dynamically there. Define it global and - * allocate from cpuset_init(). - */ -static cpumask_var_t cpus_attach; -static nodemask_t cpuset_attach_nodemask_to; - static void cpuset_attach_task(struct cpuset *cs, struct task_struct *task) { lockdep_assert_cpuset_lock_held(); =20 - if (cs !=3D &top_cpuset) - guarantee_active_cpus(task, cpus_attach); - else - cpumask_andnot(cpus_attach, task_cpu_possible_mask(task), - subpartitions_cpus); + cpuset_attach_task_cpus(cs, task, cpus_attach); /* * can_attach beforehand should guarantee that this doesn't * fail. TODO: have a better way to handle failure here diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index edca7849b165..7db4c87df83b 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -3107,20 +3107,18 @@ static void task_woken_dl(struct rq *rq, struct tas= k_struct *p) static void set_cpus_allowed_dl(struct task_struct *p, struct affinity_context *ctx) { - struct root_domain *src_rd; struct rq *rq; =20 WARN_ON_ONCE(!dl_task(p)); =20 rq =3D task_rq(p); - src_rd =3D rq->rd; /* * Migrating a SCHED_DEADLINE task between exclusive * cpusets (different root_domains) entails a bandwidth * update. We already made space for us in the destination * domain (see cpuset_can_attach()). */ - if (!cpumask_intersects(src_rd->span, ctx->new_mask)) { + if (dl_task_needs_bw_move(p, ctx->new_mask)) { struct dl_bw *src_dl_b; =20 src_dl_b =3D dl_bw_of(cpu_of(rq)); @@ -3137,6 +3135,15 @@ static void set_cpus_allowed_dl(struct task_struct *= p, set_cpus_allowed_common(p, ctx); } =20 +bool dl_task_needs_bw_move(struct task_struct *p, + const struct cpumask *new_mask) +{ + if (!dl_task(p)) + return false; + + return !cpumask_intersects(task_rq(p)->rd->span, new_mask); +} + /* Assumes rq->lock is held */ static void rq_online_dl(struct rq *rq) { --=20 2.43.0