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=1796320917; b=fMB4bF3Z5BQ+eI/f1x2DNnSLfRYSWawlmDpeSOSNv9y7crGj/qJj50H4qzxT7cfJfLps Pen+CzUJbC9yzM0FgxLCUufynHSqo3KrSgJ0cdRiwK48r+j3VAKlZvxZmS6D6GXOTHDN5 RGvUtRsYiRJcW9jUyWK/R/uX94AAu9OCnnffYXXOX/0Qbf4mPL3bkQ3P3RZm2RV/aQkSG NceBxKDNb1JbYkgd1+2aiHPriHdbAxbA2+zELKGA6Bk1Ylr4NmjtiLf3W/ItHEgBzwB7x Il9CxGEb/FEQVCmeooEsoJ0IM7l9th/r3mPPqsmgMe4oLOh+OV4ZQxBa1hJndGvJ0fQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796320917; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Dvq3h1NRqhfbzp5yiEd4YEk29MFnwmMXJLFcbGaJFuI=; b=5klxyY/mxW4dW3CVc7L80W82Q0IBYFv94gH4AtHWfK5qrsfnXVqi6E4yXRZPEzKQkrSo sE/gKOmcD+rJHfpxFmofPq2U4a3DULB6v2Ta+BDGYlH0nr2+AN6vS4Z+I6AypJxOnEfV+ OXwzIAUVPvSpCsfcMQZS9sii5EfR1dQEto6/GDYFIUD63yzOQbfi93T1jbezzq3UUmaSL vglAJCmjaluIM5YeH1Y1OOMaxXiG8G2klUwk9cxTo04qjiYYZXoDwGzUWH9ip3XcBHcc8 e5d+hVRQOVol4jbFVZNbJ6iFRbRcSmN574ffcHYRtqVlLyjtUXK010TxkSu1gDdEWiQ== 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=JC2jUIlw; 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 1CB4F606A322; Thu, 3 Dec 2026 18:01:56 +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=JC2jUIlw Received: by smtp.kernel.org (Postfix) with ESMTPSA id 691BE1F00893; Thu, 3 Dec 2026 18:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796320916; bh=Dvq3h1NRqhfbzp5yiEd4YEk29MFnwmMXJLFcbGaJFuI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JC2jUIlwnhL0A1rgOFl/H3673Wi4LpIXDlWwfZYj2Pt6CkXcKBIbL8mzHQwtHE2nZ 5ZzhjgopHqrcOvzKG/tQfjjDO3O8/rLGmwW9JyzyZc+t1eVwlmNcuaCnkvDu38rriU zNlTVOth2issbvQExxS0X8n+3frCGikMjox9g4UcRPe65IhK1zaKPALiss4iepOfrn nLZj9jlZkYQEmiAqfM4kV4NGtGlmR8TDtjg4a4P6gZ4j82vdcFuwg812skaa5bGrzd CcAj64Gc8TKxpYJP+DfajaH1Uz/6MCFCF6fy+IrCG2wzlwcsra2goWiUfQ++Y4w6I4 okDcc5wqSsTEg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v14 35/39] sched/deadline: Count again a departed task that a boost brings back 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: <47cd9c920674eb112c1800ea6568370eaf4db6f0.1796296313.git.mathieu.desnoyers@efficios.com> References: <47cd9c920674eb112c1800ea6568370eaf4db6f0.1796296313.git.mathieu.desnoyers@efficios.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 18:01:55 +0000 X-Mailing-List: linux-rt-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] sched/deadline: data race and missing ordering on dl_bw_gen and dl_bw_cpu -- commit 8b5f6b6125146e7ac12829f073f80ce655afb418 Author: Mathieu Desnoyers sched/deadline: Count again a departed task that a boost brings back This commit updates dl_task_undepart() to recount a departed task's bandwidth when priority inheritance brings it back into SCHED_DEADLINE after a root domain rebuild dropped it. It also marks skipped departed tasks in dl_bw_skip_gen so dl_bw_move_blocked() allows the boost to recount them before the rebuild walk finishes. > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index 02c6e2c200279..f2429672358c0 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c [ ... ] > @@ -4787,6 +4802,14 @@ void dl_clear_root_domains(void) > */ > dl_record_bw_cpu(dl_se, cpu); > dl_se->dl_bw_gen =3D dl_bw_gen; > + continue; > +left_out: > + /* > + * The walk counts only the tasks in the class. It can pass > + * this task before a boost brings it back. Mark the task, so > + * that dl_bw_move_blocked() lets the boost count it at once. > + */ > + WRITE_ONCE(dl_se->dl_bw_skip_gen, dl_bw_gen); > } > } [Severity: Medium] Can the plain stores to dl_bw_gen and the lockless load order in dl_task_bw_elsewhere() and dl_task_bw_rd() race with concurrent writers? dl_clear_root_domains(), dl_task_count_bw() (now also called from dl_task_undepart()), dl_add_task_root_domain(), and dl_task_move_bw() update dl_bw_cpu and dl_bw_def via dl_record_bw_cpu() and then assign dl_bw_gen with a plain store under dl_departed_lock. Lockless readers such as dl_task_bw_elsewhere() load dl_bw_cpu before reading dl_bw_gen with READ_ONCE(), without holding dl_departed_lock or acquire ordering: CPU0 CPU1 ---- ---- sched_ttwu_pending() rq_lock(rq_rd2) ... -> task_woken_dl(rq_rd2, p) dl_task_bw_elsewhere(p, cpu_rd2) bw_cpu =3D READ_ONCE(dl_bw_cpu) (stale CPU in rd2, gen G-1) dl_add_task_root_domain(p) lock(pi_lock, dl_departed_lock) dl_record_bw_cpu(&p->dl, cpu_rd1) p->dl.dl_bw_gen =3D G unlock(...) READ_ONCE(dl_bw_gen) =3D=3D G rd(bw_cpu) =3D=3D rd(cpu_rd2) return false <-- skips move Besides the data race on dl_bw_gen, CPU1 pairs the stale bw_cpu in rd2 with the new generation G and skips dl_task_move_bw(). That leaves p running in rd2 while its bandwidth is accounted in rd1, allowing temporary bandwidth over-admission or spurious admission failures until a later migration or rebuild. Similarly, dl_task_bw_rd() runs under p->pi_lock without dl_departed_lock and reads dl_bw_cpu before dl_bw_gen and dl_bw_def, so it can race with dl_task_move_bw() or dl_task_count_bw() to return a stale root domain or pair an old dl_bw_cpu with a new dl_bw_def. Publishing dl_bw_gen with smp_store_release() after dl_record_bw_cpu() and loading dl_bw_gen with smp_load_acquire() before dl_bw_cpu (or rechecking under a consistent ordering protocol) would prevent both the data race and the mismatched reads. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796296313.gi= t.mathieu.desnoyers@efficios.com?part=3D35