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=1796147083; b=VHV9pLhj0hmJXRRiaFNS2yrxEPKv2AEvX8Eg3+qFJulh3wyycph14ZvlZr61CBlg5qQQ IyxG3SQRHiEFq59/mBHh/JeWzRTdK5tcxZr5vYNCR9TlaXPTal9sx3eoE97hukgSdazBz 48EK0MzOtfRDP86oEIEIAONrhXPDHEoJtJ6MKgTLWataXK7idP376fJW5FUyuV/Ioveu7 BgkEhnMQZtPLcP45SgUq/4V7cfYC53LpbciIxCbfQ9e7Z/FoABDXGPlbeZE4H5cPT/KZL PzvWRZFsfYEJN4K2Q2qzcjgRZMfW1xNUkwE9qT5uJU1EuOhlW9ibcIKbpL/+d8zFSzw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796147083; 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=+78xb+9LFliK435zFN4yJiw3wUq45tdpGIJMjNJK0Mk=; b=a0kEoKTpEPW06QTLnsBOad4Tz8adZIlI0xSsfZGEewkR/D1vom+n8bvqUOcatbz7JCye Q12/84JU1xSPXwwS3UqlTybVZev0DgSWDhCsl+oS54YiUHv/DUftBJ2Lq2pDqfTi3S7rV otKa12BISgACXupoFirPiKErdbQ9FdOW7loeZGnIPMd82a1J6i95lO6ckSAEsliG/Dmih Hskklp6lXKKfwFZmQjACVucaDeGCIqsQmVx8vsnmlPJLJMgnptxaRWDhhw0FJdL4LMzNb Tu6asYtDeAPOkSO/zNFfbof3QDeFZNhT8qd4w1VEaOhjWKZQzziz5A0niik4/P7to/Q== 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="GW/RbhnP"; 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 20EDB60A5BDA; Tue, 1 Dec 2026 17:44:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 20EDB60A5BDA 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=GW/RbhnP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1796147078; bh=+78xb+9LFliK435zFN4yJiw3wUq45tdpGIJMjNJK0Mk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GW/RbhnPYfdtDqBznKr047M6UzSBUvMxN8w4v1NwbV0dAQbAfctY4QJ5JLRfLl6ul 5nACjffIhruoGvgTFmI9FJLaTMfo7jI9ON4f9PGBVqvfAFEmSY90yMJDAT3YIem72E yQYsB2oIMwtm7JAOT6PfVYPBj71+5YroeEX7wa27ReryML6pQbQkdJh0wWCP3lpXNe SWOucCjreBVj1I8KbakoJlwidUeqa63t5R1RjixvGwjxXEgOHzCPljxNig3AQ+/zik frlq8f+FnJgH3n+CsoNDaPqCg5n+x4JPluo6Gj1sGdLokgEWPvWGA/cb/KSt/vZGXo zpDqQcg1cws9w== Received: from thinkos.internal.efficios.com (mtl.efficios.com [216.120.195.104]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4jf7Yy2KdYzZ4P; Tue, 01 Dec 2026 12:44:38 -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 28/36] sched/deadline: Record the start of the period Date: Tue, 1 Dec 2026 12:44:22 -0500 Message-ID: <6d2f0ab49e2b82a51a730025cac0c15dfa2b3614.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 dl_next_period() computes the next period from the deadline: deadline - dl_deadline + dl_period. After sched_setattr() changes dl_deadline, this subtracts the new dl_deadline from a deadline set with the old one. The result is a wrong next period. The next patch fits the period in progress to new parameters at sched_setattr(). To do that, it needs the start of the period. Add the field period_start. Set it wherever a period starts, and clear it with the deadline. Nothing reads it yet: no functional change. Signed-off-by: Mathieu Desnoyers Cc: stable@vger.kernel.org --- include/linux/sched.h | 1 + kernel/sched/deadline.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 689952d7fd15..ccd972ca44e4 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -661,6 +661,7 @@ struct sched_dl_entity { */ s64 runtime; /* Remaining runtime for this instance */ u64 deadline; /* Absolute deadline for this instance */ + u64 period_start; /* Absolute start of this instance */ unsigned int flags; /* Specifying the scheduler behaviour */ /* diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 9754b72af895..5cc4f36c5146 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1169,7 +1169,8 @@ static inline void replenish_dl_new_period(struct sched_dl_entity *dl_se, struct rq *rq) { /* for non-boosted task, pi_of(dl_se) == dl_se */ - dl_se->deadline = rq_clock(rq) + pi_of(dl_se)->dl_deadline; + dl_se->period_start = rq_clock(rq); + dl_se->deadline = dl_se->period_start + pi_of(dl_se)->dl_deadline; dl_se->runtime = pi_of(dl_se)->dl_runtime; /* @@ -1268,6 +1269,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se) WARN_ON_ONCE(!is_dl_boosted(dl_se)); if (!dl_se->dl_deadline) { dl_se->deadline = rq_clock(rq); + dl_se->period_start = dl_se->deadline; dl_se->runtime = 0; } if (dl_se->runtime < 0 || dl_se->dl_yielded) @@ -1289,7 +1291,8 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se) */ if (dl_se->dl_deadline == 0 || (dl_se->dl_defer_armed && dl_entity_overflow(dl_se, rq_clock(rq)))) { - dl_se->deadline = rq_clock(rq) + deadline; + dl_se->period_start = rq_clock(rq); + dl_se->deadline = dl_se->period_start + deadline; dl_se->runtime = runtime; } @@ -1304,6 +1307,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se) */ while (dl_se->runtime <= 0) { dl_se->deadline += period; + dl_se->period_start += period; dl_se->runtime += runtime; } @@ -2446,6 +2450,7 @@ int dl_server_apply_params(struct sched_dl_entity *dl_se, u64 runtime, u64 perio dl_se->runtime = 0; dl_se->deadline = 0; + dl_se->period_start = 0; dl_se->dl_bw = to_ratio(dl_se->dl_period, dl_se->dl_runtime); dl_se->dl_density = to_ratio(dl_se->dl_deadline, dl_se->dl_runtime); @@ -4707,6 +4712,7 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p) */ if (!p->dl.dl_runtime) { p->dl.deadline = 0; + p->dl.period_start = 0; p->dl.runtime = 0; } @@ -5206,6 +5212,7 @@ static void __dl_clear_params(struct sched_dl_entity *dl_se) dl_se->dl_density = 0; dl_se->deadline = 0; + dl_se->period_start = 0; dl_se->runtime = 0; dl_se->dl_throttled = 0; -- 2.47.3