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=1796149222; b=2tgS5JXjmNWC4upG8YU9CiMsWir28uhTx/dhteo/4YK2GG3yPa6o4+VQnGxrumLLlgCh uVQR7RTUcjnHTyy+Qif9gLC3UCsJrYOoCcZuYqVkii57l4M4LfjfwTEC4qM72jKrcHUl5 u2XlI9Ckd1jEocYCnA4fy6jd6KqjJrW9KNiUGp1tL/HRFGeyKVmmJKjQ1CvLc6e32Hp+t ESqMo12MTpMPpYu7wc/yDWpOr2Y9N5rlIEgAxZai8zbaUsFRG1/BUbC8MiUKs6a759iRW odrpe1LBphX7CBgh0u3N/HqC+bX10kJoZvmO0rfelt/nlDDDmv9i8uOse+vsiCEtztA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796149222; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=cuqsPGkCwoJ951i4Zfxq2n+1jINQPg6426Y/IevMVf8=; b=ffV+QBebJH34wSc26uMNUQvDV0uHiM7JuVp4LvRamTaoS+vJwa3dHNUYxpmfVy4PUqXF +BvXlf+YRL9Dg3UroU++QBz0dGcMvkmoVafFgub/9H2uIn6zsbjjwDBNsFHEgkpNh8Ves /bg5Gmm69wKZn1ta+0qS+ayZN5t65YR0P25JtISv7afIfuO6pvRFXdQQhFIZGpMIMNPBp xNpqq2Jd8TkjCVItNguW//TbB6TUcRAtZozQrbIqokoe1o0OtEhTp1fBzGgianG2XQ7ay GyJin7j8nqO+DSNwWFB8DxPq1tJGqgDKBcD5h1rwa55rDbjG3DuJ1j0iP/qDUmXUdxA== 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=K8mYPLb+; 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 D4F9C606A31A; Tue, 1 Dec 2026 18:20:22 +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=K8mYPLb+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA481F00893; Tue, 1 Dec 2026 18:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796149222; bh=cuqsPGkCwoJ951i4Zfxq2n+1jINQPg6426Y/IevMVf8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=K8mYPLb+BFfemlNdo4iD6t3BoK9USbQEm36SV9pM1BTRV4gDolR/AMuTMlRIm5Vrh 9NMkrJ6R7iHpovIWR7NMQIgjDzeeiZSCbUW5qyn831E+uqq7Z6W/tItbm6+9nyEewp kqTgFC7jv6GYmLG6oDfmJ0z8FFuaNXYakQbfcgvsGsm7nVbW1Kh6l36LxyIu47E1U9 mxnJaeGkdI3HSgAB5zp7YhR66flIphoYxtJJXfBWG8qFUkDvYhtpg0rzARVLS3Ypa6 jhycBhJ/VtCS+ybFGwz9FH4VP2PODUIj+iH36s/YIFEOIyG+EXouVKoGW2QSujeQRQ Rho3Bzg4ddXoQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v13 06/36] sched/deadline: Keep departing bandwidth across a root domain rebuild Reply-To: sashiko-reviews@lists.linux.dev To: "Mathieu Desnoyers" Cc: linux-rt-devel@lists.linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, linux-kernel@vger.kernel.org In-Reply-To: <6b669993ed9589032ec88900ad05418673030fc5.1796146461.git.mathieu.desnoyers@efficios.com> References: <6b669993ed9589032ec88900ad05418673030fc5.1796146461.git.mathieu.desnoyers@efficios.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 18:20:21 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] sched/deadline: departed bw misattributed in dl_clear_root_domains() - [Medium] sched/deadline: departed bw not discounted under lock in sched_dl_overflow() -- commit 61bc675abcdc6b82b59f9a092043cd6f4e528bc5 Author: Mathieu Desnoyers sched/deadline: Keep departing bandwidth across a root domain rebuild This commit tracks tasks that leave SCHED_DEADLINE or die before their 0-lag time on dl_departed_list so that root domain accounting rebuilds preserve their bandwidth until their inactive timer fires. > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index cd7f2ada8cdf3..f345216deb77b 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c [ ... ] > @@ -3744,9 +3881,51 @@ void dl_clear_root_domain(struct root_domain *rd) > dl_server_add_bw(rd, i); > } > =20 > -void dl_clear_root_domain_cpu(int cpu) > +/* > + * Clear every root domain before a rebuild of their accounting, and cou= nt > + * the rebuild in dl_bw_gen. Put back the bandwidth of their servers. Put > + * back the bandwidth of the tasks on dl_departed_list, which no cpuset > + * holds as deadline tasks. Put each in the root domain of the CPU > + * recorded for it, or drop it if that CPU is not active. > + * dl_add_task_root_domain() then adds the deadline tasks of the cpusets. > + */ > +void dl_clear_root_domains(void) > { > - dl_clear_root_domain(cpu_rq(cpu)->rd); > + struct sched_dl_entity *dl_se; > + u64 cookie =3D ++dl_cookie; > + struct dl_bw *dl_b; > + int cpu; > + > + guard(raw_spinlock_irqsave)(&dl_departed_lock); > + dl_bw_gen++; > + for_each_possible_cpu(cpu) { > + if (!dl_bw_visited(cpu, cookie)) > + dl_clear_root_domain(cpu_rq(cpu)->rd); > + } > + list_for_each_entry(dl_se, &dl_departed_list, dl_departed_node) { > + cpu =3D dl_se->dl_departed_cpu; > + /* > + * Skip bandwidth that an earlier rebuild dropped. It is not > + * counted now, and its release removes nothing > + * (dl_task_release_bw()). > + */ > + if (dl_se->dl_bw_gen !=3D dl_bw_gen - 1) > + continue; > + /* > + * Drop the bandwidth of a task whose CPU is inactive. A CPU > + * that goes offline is in the default root domain by then. > + * The root domain that counted the task cannot be found > + * from the recorded number. The release then removes > + * nothing, and no later rebuild restores it. > + */ > + if (!cpu_active(cpu)) > + continue; > + dl_b =3D dl_bw_of(cpu); > + raw_spin_lock(&dl_b->lock); > + __dl_add(dl_b, dl_se->dl_bw, dl_bw_cpus(cpu)); > + raw_spin_unlock(&dl_b->lock); > + dl_se->dl_bw_gen =3D dl_bw_gen; > + } > } [Severity: Medium] Can dl_clear_root_domains() (and the dl_departed_cpu branch in dl_add_task_root_domain()) charge departed bandwidth to the wrong root domain when dl_se->dl_departed_cpu is split into a new child cpuset partition before the 0-lag timer fires? If tasks in a multi-CPU root domain leave SCHED_DEADLINE on CPU N and a new partition root is created on CPU N before their inactive timers expire, dl_bw_of(dl_se->dl_departed_cpu) resolves to the new partition's root domain. The original root domain loses that departing bandwidth and can over-admit deadline tasks, while the new partition is charged for bandwidth that never belonged to it (rejecting admissions with -EBUSY and underflowing cpu_rq(cpu)->dl.extra_bw via __dl_add() -> __dl_update() if the departed bandwidth on CPU N exceeds the new partition's max_bw). [ ... ] > @@ -4065,8 +4261,6 @@ int sched_dl_overflow(struct task_struct *p, int po= licy, > =20 > if (dl_policy(policy) && !task_has_dl_policy(p) && > !__dl_overflow(dl_b, cap, 0, new_bw)) { > - if (hrtimer_active(&p->dl.inactive_timer)) > - __dl_sub(dl_b, p->dl.dl_bw, cpus); > __dl_add(dl_b, new_bw, cpus); > err =3D 0; > } else if (dl_policy(policy) && task_has_dl_policy(p) && > @@ -4092,6 +4286,19 @@ int sched_dl_overflow(struct task_struct *p, int p= olicy, > } > raw_spin_unlock(&dl_b->lock); > =20 > + /* > + * A task that comes back before its 0-lag time still has the > + * bandwidth it left with. The new bandwidth replaces it, so remove the > + * old one from the root domain that keeps it (dl_task_release_bw()). > + * No rebuild can run meanwhile: the caller holds cpuset_mutex. > + */ > + if (!err && dl_policy(policy) && !task_has_dl_policy(p)) { > + lockdep_assert_cpuset_lock_held(); > + if (p->dl.dl_departed_cpu >=3D 0) > + dl_task_release_bw(p, -1); > + p->dl.dl_bw_gen =3D dl_bw_gen; > + } > + > return err; > } [Severity: Medium] When a departed task returns to SCHED_DEADLINE in the same root domain before its 0-lag time, does deferring the old p->dl.dl_bw subtraction to dl_task_release_bw() after raw_spin_unlock(&dl_b->lock) double-count the task's bandwidth? __dl_overflow(dl_b, cap, 0, new_bw) checks admission with old_bw =3D 0 even though p->dl.dl_bw is still in dl_b->total_bw, so sched_setattr() fails with -EBUSY whenever dl_b->total_bw + new_bw exceeds capacity while dl_b->total_bw - p->dl.dl_bw + new_bw would fit. In addition, between raw_spin_unlock(&dl_b->lock) and dl_task_release_bw() reacquiring dl_b->lock, both p->dl.dl_bw and new_bw are present in dl_b->total_bw and subtracted from rq->dl.extra_bw, which can cause concurrent sched_dl_global_validate() or dl_server_apply_params() calls to fail with -EBUSY and transiently skews (or underflows when admission control is disabled) rq->dl.extra_bw in grub_reclaim(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796146461.gi= t.mathieu.desnoyers@efficios.com?part=3D6