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=1796147082; b=bCnmXPHUzi8L0+Rq6XAUhxrJBATvzFh47SaWpX3ODoyQIwqrnpuRYdRyGGjF7ONcDOXb rw/sDlJep0s2T5xsYRCvnbPjwbuAEDVtmAzU5fjop7cevDiEeJOj9FP+OoMWC1O6ak2SK XxAzn0d8ilFf5oJHyptpjQ/XDpO3tBtm4jyUi1eBw09UBvFIHXtHPVxGYD+QBbvwhoHwe QfEhqZHhNG9ixy0eKQLSvinU93jkhYVLkOeRQNZKvS5mq9/eSLfYmWtlqX9q6jGaML0Vp 9Ymv5vnd6Ndtc4LoK/+G5k4zbUxvqNIErCgkCNc08BRGRD6CdWHYYEVBxgFDiZmfHMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796147082; 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=WbvTkfcizG96BeIjT5cjVT4BLOa/50w94PLcebth0dA=; b=pr3/vEIPDuL6mF+XnkEXMfw8lkVIA6PilD9Pgzi1Zu8gKArcEZ1QyPRwapcz5Zb0nfqT DhF08CjH65eT0Up3o+22HUurl8qPQvB+tFWDQfOr7jt4MIm1voMjQ9JPppR+UuszLF278 JYcJcY9m2GF6799vagj3M7LJiUElhL1vrCzTu4Iu/j2T9sDxh4Ab9lhXF2XP43bJlAJHL NaVOK0ed5wvBQ+nrT9mA0eyuvdhKUO1rhKzBqCC1I0Tsn17onrGNDRnI2xUInUMdK72Xx /JFEYJ5+cOe7MV1DYovQGOgXhH720qNa6lKVb9h0xBjXmPMViqIij+16pVWRt+udgiQ== 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=jqucRpte; 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 BC6CB606A69E; Tue, 1 Dec 2026 17:44:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BC6CB606A69E 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=jqucRpte DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1796147077; bh=WbvTkfcizG96BeIjT5cjVT4BLOa/50w94PLcebth0dA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqucRpteuhRPtq32Q9A8oMxxe9Upu6nxRx5ZcDtaZmug7kJaIvbnxhDA4s8wovPwD zQgbUHb1s05/VHSLFuDE29mt06uaLJDqi3bzYcyFI0GwkB4t+hOshEaX7c/55VlW2V 7SLxDMZwBIiTVSRXKAJkVeQ5R9TXPPhujl9mmSJ9SA1Slm2q4rgYsk7FP+tuQGIPf7 lOMc/kOKzkz4ziDfA5WvoPwIeuraxsmuilwBtvnsJopztgAfZkXmUlUQoom4Q5fMKQ pHF963Xgx4q90kEzV0tTH5mPIGuY9FzDgCgE9hYnzwsrrJU7tF3OcLD8AWKbMFS4Tv VZNtugvL3jddQ== Received: from thinkos.internal.efficios.com (mtl.efficios.com [216.120.195.104]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4jf7Yx5cD8zYw9; Tue, 01 Dec 2026 12:44:37 -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, 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 v13 25/36] sched/deadline: Cancel the replenishment timer with the parameters Date: Tue, 1 Dec 2026 12:44:19 -0500 Message-ID: <6bb7124f8087dab6d79d41b38a9e893f4efda234.1796146461.git.mathieu.desnoyers@efficios.com> 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 A task that leaves SCHED_DEADLINE has its parameters cleared at its 0-lag time. Its replenishment timer can still be armed then. If the task comes back and throttles before that timer fires, start_dl_timer() does not restart it, since it is queued. The replenishment would then come at the period of the reservation the task left. Too early, it would give the task runtime it has not earned. Too late, it would delay the task by up to a period. Commit a649f237db18 ("sched,dl: Fix sched class hopping CBS hole") armed the replenishment timer when a task leaves the class. The timer then reset the task if it was still out. Commit 209a0cbda7a0 ("sched/deadline: Improve the tracking of active utilization") moved that reset to the inactive timer, at the 0-lag time. Nothing cancels the replenishment timer there. The timer of a throttled task fires at its next period, which can come after the 0-lag time. A task that yielded is throttled with runtime left. Its 0-lag time comes before its deadline. On v7.4-rc2, a constrained-deadline task that overran by little also reaches its 0-lag time before the end of its period. "sched/deadline: Count the 0-lag time from the next period", earlier in this series, puts that 0-lag time after the next period. Fix this by cancelling the timer where the parameters are cleared. This includes task_non_contending(). switched_from_dl() calls it to release the bandwidth of a task that leaves asleep past its 0-lag time. A constrained task that overran as it blocked has the timer armed there too. The Sashiko AI review of this series found this. It has no reproducer. Fixes: 209a0cbda7a0 ("sched/deadline: Improve the tracking of active utilization") Signed-off-by: Mathieu Desnoyers Reviewed-by: Juri Lelli Cc: stable@vger.kernel.org --- kernel/sched/deadline.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 6ca78be82b27..2a2e6e321fec 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -829,6 +829,7 @@ static void task_non_contending(struct sched_dl_entity *dl_se, bool dl_task) if (dl_task && READ_ONCE(p->__state) == TASK_DEAD) sub_rq_bw(dl_se, &rq->dl); dl_task_release_bw(p); + cancel_replenish_timer(dl_se); __dl_clear_params(dl_se); } } @@ -2704,6 +2705,7 @@ static enum hrtimer_restart inactive_task_timer(struct hrtimer *timer) } dl_task_release_bw(p); + cancel_replenish_timer(dl_se); __dl_clear_params(dl_se); goto unlock; -- 2.47.3