From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=158.69.130.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796309954; b=1hJM9VqFaxzkHOln+RtepjFkEZZhboYyiXuU/2FUbEHLzT+dN6AK+IuM4+9I/hWJqGDv vyEagD0YZKBrSPo4S6tpsfTJ/EBKs1kKhIDf3is/G44ISCZ/ZtOzOcEWo1pRqy6vc72/d dFvYgFnsz4pzPZA5bhtYF7IgqTIWUrw9R/XwGIVtSQCy3sDWye4qsem/yq98prUB9tSAl GkKgM3mLV3DK90OD+wnPjRys/8RA1lFHrqcRVtNXaxlQwwUfo7Vm/b2B0uafHhPrExLmp bLryS9JME/Z1qiGeOXScp1sL3l6FjoXNVYcu/o+SvvSFPMTZFVEPKGGRpaxZQcoWK3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309954; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=OPiyCWID/b2KVQaQFKhqYznUV285f5nsCFpuf6l0Lps=; b=fZlyj29lXLiELa9Wuqyxkpq2xgC8Z+au0jn5hmWaKIFhEzkHguerOll1UXciBHOyDG7l nmwN0/D7RzJ60ysoE8pELFmaKPEsthtXXv1PAmNKMtJ4m7uy2Aoh8PX3wNv8YGJ3yEqCq UEbrxvBvz4zrskqm5ibHM4Qs4/944CtHhA0e97fubyxWq7Pp4WLIQoMRS2/hBDUbSBQJp VAHe98yQ2bjB3fMvwmiVjc0MkQuYnaqOgSoAPSO2Cdtc8ozIJPZSNFlzybkXdlJKYWvD6 wfqf5KeKft69Y/b+DPQPMSuZ15p3kaRCrXTUta6FbEfNmX9LuTejiMMsp6+VbM1+YWA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=DDv3UPP8; arc=none smtp.remote-ip=158.69.130.18 Received: from smtpout.efficios.com (smtpout.efficios.com [158.69.130.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 356FC60A2609; Thu, 3 Dec 2026 14:59:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 356FC60A2609 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=DDv3UPP8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1796309953; bh=OPiyCWID/b2KVQaQFKhqYznUV285f5nsCFpuf6l0Lps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DDv3UPP8JHSIT/ZHHSNSsoI82NLr/NMEF6roGUKAszLWbOLWgstKvAWGJdjyWuepg ZV/SISHrKFgTa8lqqwuWz2fjgOa4YzWCz8d25gFrdtQM/aVYK0FZkmL4iemglTZXag hAwNZaRgeP6y2rOV29rp29+ASI1gs51/vH7iTIEkixbi5lz/WufPSRmM8LCxIpaANM 28ykThd3Fj/6ltvBpfTyoT3PI81ytU+w0t3qy1OIqFicuxa/YrX1JuSbk/XRfLX8XS IZPRTEVV89iCMmWiraw7SBLWVTV/+kH8aKTDjYpWr87Z8N2Xh7f194frqD5GbsEmA5 IAiqT+pSMFZQw== Received: from thinkos.internal.efficios.com (unknown [IPv6:2605:8d80:7180:6739:ac39:5d4:4093:61c6]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4jgHp75jdRzZBR; Thu, 03 Dec 2026 09:59:11 -0500 (EST) From: Mathieu Desnoyers To: juri.lelli@redhat.com, peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org Cc: Mathieu Desnoyers , tglx@kernel.org, anna-maria@linutronix.de, frederic@kernel.org, will@kernel.org, boqun@kernel.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com, luca.abeni@santannapisa.it, tommaso.cucinotta@gmail.com, mathieu.poirier@linaro.org, longman@redhat.com, ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, bigeasy@linutronix.de, clrkwllms@kernel.org, parri.andrea@gmail.com, m.szyprowski@samsung.com, kayracizmeci@gmail.com, weihengqiuu@gmail.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rt-devel@lists.linux.dev, oleg@redhat.com, brauner@kernel.org, stable@vger.kernel.org Subject: [PATCH v14 07/39] sched/deadline: Leave an active task alone in the inactive timer Date: Thu, 3 Dec 2026 09:58:21 -0500 Message-ID: X-Mailer: git-send-email 2.47.3 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit inactive_task_timer() runs at the 0-lag time of a deadline task that blocked. A wakeup cannot cancel the timer once its handler runs. So task_contending() clears dl_non_contending. The comment there says that the handler then sees the flag clear, and leaves the active utilization alone. But the handler first checks whether the task left the class or is dying. It checks dl_non_contending after that. For a dying task, this first branch releases total_bw and clears the parameters, even if the task woke up in between. switched_to_dl() cannot cancel a running handler either, so a task that comes back into the class and then dies takes the same branch. T is a SCHED_DEADLINE task on CPU 1. It blocked before its 0-lag time, so dl_non_contending is set and its inactive timer is armed. The timer fires on CPU 0. CPU 0 is then delayed, for example by a preempted vCPU, and gets the rq lock of T only after T has exited: CPU 0 CPU 1 inactive_task_timer() runs task_rq_lock(T) waits T wakes up task_contending(): dl_non_contending = 0 cannot cancel the timer T exits do_task_dead(): T->__state = TASK_DEAD gets the lock T is TASK_DEAD: releases total_bw __dl_clear_params() __schedule() dequeue_task_dl(T) task_non_contending(): dl_runtime == 0, returns The last dequeue of T then leaves its bandwidth in running_bw and in this_bw of CPU 1. schedutil reads running_bw, so CPU 1 would keep a raised minimum frequency. GRUB would also reclaim less runtime there. Fix this by leaving the task alone when it is in the class and dl_non_contending is clear. Its last dequeue then removes its bandwidth, as for any task that dies. The Sashiko AI review of this series found this case by reading. It was not reproduced. Fixes: 209a0cbda7a0 ("sched/deadline: Improve the tracking of active utilization") Signed-off-by: Mathieu Desnoyers Cc: stable@vger.kernel.org --- kernel/sched/deadline.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 26b02ae8683a..c88cac6bc5fe 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2321,6 +2321,14 @@ static enum hrtimer_restart inactive_task_timer(struct hrtimer *timer) if (dl_server(dl_se)) goto no_task; + /* + * The task woke up, or came back into the class, while this handler + * waited for the rq lock. Leave it alone, even if it is dying: its + * last dequeue needs its parameters to remove its bandwidth. + */ + if (dl_task(p) && !dl_se->dl_non_contending) + goto unlock; + if (!dl_task(p) || READ_ONCE(p->__state) == TASK_DEAD) { struct dl_bw *dl_b = dl_bw_of(task_cpu(p)); -- 2.47.3