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=1796312999; b=0SGc7lb4O9X0iWLcjotfkJ5ewj+fjrX+vqb4WZqfFed6kZm3JOU/gz1RANMoC+kyjmUN hrxQTvQrIKJ0gJaw4evr58Nh9YopTwMrKdVjEV13oZUoPRH4sw5Lzh1yftrw9Nq1rFK9l CEfj3AfkZusTUR0tx1EKpltuYxLrU3TQq/sqektLntXdWrAj/ZsZSyKj+6BwCIC+qFe+z disAyen5xIZCZhVUc4Lo4dz3Y4oYbIfLP1uVbXmq3/J8ryx2QtrPMdo+2XBf1P1Q9eME3 et3daAXCuOZyEl2j/FDVe6flZobKMkEOHMcldxCL02p3SYdQatzcDqb2SYbTameFhrg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796312999; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=gEOfc8PQ5720Bp3cxSBTbjOjySydkScnrbjl8JJsjIU=; b=RrOhwfYKWDUXpr3XjWJsLF/sXrG4bWxxjpBPRuqq/yJor+OZMJbgkPaYOUWryis3wD5P AGmlvvaFLmH8UobsjKSlu4RFMIxHuGOjxZtCkZuUGr3G4cn5GSXuTsNNTnEF67ZJ9psYn Ikb58Llzy+R6tb6iFT9E7IO8qcjdlLvHQ2Yt062HPXaPxkn8jFPHViIv87MDbflRA1nXA +7Srms4HWzv8l85oSN+UIg2P+1FM0f0iwb3Uux89R095dmuHC15oiPP3GaF3im42rOBuO MsgyHcVp2KGcuBR5/0b1fBbcMzUcgGtvqYWcPaVGhGw2RXPTLR5Wh4UhKs9fULMDD6w== 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=iD7mCEAF; 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 94057606A32D; Thu, 3 Dec 2026 15:49:59 +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=iD7mCEAF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33C3B1F00893; Thu, 3 Dec 2026 15:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796312999; bh=gEOfc8PQ5720Bp3cxSBTbjOjySydkScnrbjl8JJsjIU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=iD7mCEAFrE8PAmRY3xq46rXlnbZfbLGImkTvE92fu8TSC1sR7F2/8xOOHWJXMwsDM fL6jO1/0IoCT2FoJM+6E4Ypamw2jJ4MCbCcs29V4Cgh6AlAh0pXO13BSlBo0LQ+k31 j93wc01y2EJhZXWTV8hVZzczoEgTe7cGYAZfe4BE2+3rlom05Jmfs6/Lzn1JWiyxkQ FS1fzR4RXwKBUYm9iPdJf2QIz5O2aIFrgn/EcnxTSsVvBAGORYpagjAB5jXtpgJ2YW flxn0QdtHsCa4F+uGTZQ0stw8zA52SMymPYMGKZ2B5T5jhYlo7loGgtmAMpIn+Z6pq Nx1/aGyvNwlWQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v14 09/39] 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: <9ab68e7bb2bf0a109ac26f8976820f96354193f1.1796296313.git.mathieu.desnoyers@efficios.com> References: <9ab68e7bb2bf0a109ac26f8976820f96354193f1.1796296313.git.mathieu.desnoyers@efficios.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 15:49:58 +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 3 potential issues to consider: - [Medium] sched/deadline: global raw spinlock held across all root domains in dl_clear_root_domains() - [Medium] sched/deadline: global dl_departed_lock wraps dl_b->lock and __dl_update() - [Medium] sched/deadline: departed bw misattributed in dl_clear_root_domains() -- commit a0e3318afb889030b52c3d3e246d5783369fcb93 Author: Mathieu Desnoyers sched/deadline: Keep departing bandwidth across a root domain rebuild This commit tracks tasks that leave SCHED_DEADLINE or exit before their 0-lag time on a global dl_departed_list with their departing CPU and a rebuild generation counter, so root domain accounting rebuilds and inactive_task_timer() account their bandwidth against the right root domain. > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index 422a8120454a3..7d1e305049c25 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c [ ... ] > +static void dl_task_release_bw(struct task_struct *p, int cpu) > +{ > + struct sched_dl_entity *dl_se =3D &p->dl; > + struct dl_bw *dl_b; > + > + lockdep_assert_irqs_disabled(); > + guard(raw_spinlock)(&dl_departed_lock); > + if (dl_se->dl_departed_cpu >=3D 0) { > + cpu =3D dl_se->dl_departed_cpu; > + dl_se->dl_departed_cpu =3D -1; > + list_del_init(&dl_se->dl_departed_node); > + } > + if (dl_se->dl_bw_gen =3D=3D dl_bw_gen) { > + dl_b =3D dl_bw_of(cpu); > + raw_spin_lock(&dl_b->lock); > + __dl_sub(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 holding the global raw spinlock dl_departed_lock across dl_b->lock and __dl_sub() -> __dl_update() stall unrelated root domains? Previously, bandwidth accounting was isolated per root domain via rd->dl_bw.lock. Now dl_task_release_bw() holds dl_departed_lock while __dl_update() loops over every active CPU in rd->span touching remote rq->dl.extra_bw cachelines. sched_dl_overflow() also acquires dl_departed_lock unconditionally on every entry into SCHED_DEADLINE (even when dl_departed_cpu < 0) and holds it across dl_b->lock, dl_bw_capacity(), and __dl_update(). When a large housekeeping root domain runs sched_dl_overflow() or releases departed bandwidth, inactive_task_timer() hardirqs in an unrelated isolated RT partition spin on dl_departed_lock with rq->__lock held and IRQs disabled. [ ... ] > @@ -3670,9 +3805,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); > + } [Severity: Medium] Does holding dl_departed_lock with IRQs disabled across all root domains here introduce long IRQ-off stalls on large SMP systems? Previously, dl_rebuild_rd_accounting() walked root domains with IRQs enabled and locked each rd->dl_bw.lock separately. Now one raw_spinlock_irqsave section spans every root domain's O(|rd->span|^2) dl_server_add_bw() -> __dl_update() loop plus the dl_departed_list walk. During a cpuset partition change or CPU hotplug, this creates a long non-preemptible IRQ-off stall (even on PREEMPT_RT) and stalls unrelated isolated RT partitions whenever their CPUs hit dl_departed_lock from inactive_task_timer() or switched_from_dl() while holding rq->__lock. > + 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] Will splitting a CPU into a child cpuset partition root misattribute departed bandwidth and wrap rq->dl.extra_bw below zero? dl_task_depart() records only task_cpu(p) in dl_departed_cpu, and dl_clear_root_domains() charges dl_se->dl_bw to dl_bw_of(dl_departed_cpu) whenever that CPU is active. If two 60% deadline tasks on CPUs 0-2 leave SCHED_DEADLINE or exit on CPU 2, and CPU 2 is split into a 1-CPU child partition root before their 0-lag timers fire, both tasks' bandwidth is charged to the child partition instead of the original root domain. Until inactive_task_timer() fires, the original root domain can over-admit deadline tasks while the child partition rejects valid admissions. Worse, __dl_add() -> __dl_update() subtracts the misattributed bandwidth from the unsigned u64 rq->dl.extra_bw, wrapping it near U64_MAX. While rq->dl.extra_bw is wrapped, grub_reclaim() sees u_inact + rq->dl.extra_bw > rq->dl.max_bw - dl_se->dl_bw as true and grants maximum GRUB reclamation to SCHED_FLAG_RECLAIM tasks in the overcommitted partition. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796296313.gi= t.mathieu.desnoyers@efficios.com?part=3D9