From nobody Mon Dec 1 22:35:04 2025 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5BFE2550AF for ; Mon, 1 Dec 2025 12:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764592932; cv=none; b=rUCySxWEMN9LH9grA+WqeDIT2e1lre0CnKn+iZDR3auyEtwzcsWB27RVpt7VB/0qJPJis2tJGQW9iiMes/706wsItExR0bRWSW5e/LkOUg7pVcuXtQ9FI0w3ZvAilBETqn5SFO0JTslhXqxcQc1NcKriD36Nl8LFtznukWpG5XU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764592932; c=relaxed/simple; bh=jbA548yJQDkqAtQzfJUj6On8p4dvfo9kGRb+k7p2L6I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oUB5JVOHL5ziiZhpz5rkN3xt1AxIOPTq4jL7t8/d9CB90be0DDXZoo1TBoXolPHH4IRYdKz1Wr4JC2mlKMvoLdcitaAYH9gBFHd47u8xdj9aCEKiHBPzmip6TZmzCPmNkWL37qkmPzK169oTPlsWbp03r3/4nOCx9MzJV3oELak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Mbd2z+GX; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Mbd2z+GX" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-b735ce67d1dso687545866b.3 for ; Mon, 01 Dec 2025 04:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764592928; x=1765197728; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MfZWhz4tfpGGO+7FZPEiHA0UbhTazLSPBY31aWjLIRo=; b=Mbd2z+GXyOFUzKlmGBe7GZwJmRymKI7OBcqe2XN7ul2/OUfb3IKNwQpiGDV+sW85CN 1htnjdYFxpw1c4mDPTOd0IeygNoHngg/Wy3kEs0dbhTB+tnG2JRjEBEXttOfb4uOK043 0tZh3euE4BFJjyaeORt0tLUfSQDOwk7MYVDtU+XytxwQIWj5MnVTDiDRQqmqeb3TeDD2 kpORSgj2GwzvrlGfwxD0yi3Y+RRtT0lhecFO4yvuANFxLeZoGZBSYoymWyrjNYJkOjDx 3sOQYzwZFB6ep+L1p1Q+K18+LzEYCIq+gbt3hPBQstfLd6zmlq+3Iah6enMOq3wKsbxn 98mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764592928; x=1765197728; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MfZWhz4tfpGGO+7FZPEiHA0UbhTazLSPBY31aWjLIRo=; b=q56N6XHyOORVyLdXEe+/dCmWWUbUD2PDEqTm6wMu1OPGd6uDWqIPKBzcGPqxo9TxqK 8kMUSkIHEgdWFutvgSF2TdqV7QfnWWgYmsTPPO6NJaS6jdAmhRX7TfoUIlW2DSCZMQTL 6PcJylmcSjIRSog0M/4xhD2nmpWbHOuz/dOLfGSBjzqoTN+4Tlg/u445hsTIL366q5wl Bw98ky8JJT4GA817YAYXYqZ8XjPfVcI6cpNnAN79gHS8nyxkxCmghq6tqI9JgNmAn5qX ZIpHqHtRtGcus+0RamiSkdqcN/cwhBa/Eb+3TlT+GhIGyT4MFT1hwpSZYjm2IQGh5bK5 1DQQ== X-Gm-Message-State: AOJu0YxIpl7fpQ0q+ue4wt4xb43d/Ei2k9G+u3iUY3r+MPKL5wMc1BAe jkp3K7a02yKYkkTW2M6b8tzUIO07/O6O6YXA5e6gpB/pxaDIvn3FhGlt X-Gm-Gg: ASbGncvoQ2VCViTOoflLqbngUhCnnJogZtgfDTuTsu0XpA+zLf/g0/WqXhFEQh2XSkx yWnx+oflwU/c9zqZnqeTfTojnrQAMisQZiSEZSQ7UsQ+VadIFKiGHUGPD22YyvctyZXBztfc/Bj bQu6hx2W/nSQpejz0xEUNOLGpyhVem7rVaF/FJvjWVzooc/9vNUQ5LAb0GCSZ9pYRA6/DlUDte0 y3QGVKuIJRpFmZxtek09TfhV27HmNw4pBrTAtfxa2F/+atx6fdBPP7nIoK3XNKvhu2IDLnLJ5pu Is55chNa/H4K52Gc86n2YHyuU6AAiATA9X8qxMRAN7vEncuxBkAj98EsQ8yLAR9eR+f+CkxdAXy bLk0kzQWgkRGsk0JOlwEOGwwe4XNZGO1NJkqpV9SFmV1hm/eSUlBOo8X2N6TxDXiew6X4VV+njD m6+jrAb7rm X-Google-Smtp-Source: AGHT+IHpngQZ3ykuqVkwLPiQyqKVbbW0LFmvmVbm39ZWFBWeY7IKsSnO7jI8da+/ocCOoGZdDaInyA== X-Received: by 2002:a17:907:809:b0:b73:7280:7821 with SMTP id a640c23a62f3a-b76c558f338mr2667024366b.60.1764592927725; Mon, 01 Dec 2025 04:42:07 -0800 (PST) Received: from victus-lab ([193.205.81.5]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b76f59e8612sm1173738266b.52.2025.12.01.04.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 04:42:07 -0800 (PST) From: Yuri Andriaccio To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: linux-kernel@vger.kernel.org, Luca Abeni , Yuri Andriaccio Subject: [RFC PATCH v4 01/28] sched/deadline: Do not access dl_se->rq directly Date: Mon, 1 Dec 2025 13:41:34 +0100 Message-ID: <20251201124205.11169-2-yurand2000@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251201124205.11169-1-yurand2000@gmail.com> References: <20251201124205.11169-1-yurand2000@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: luca abeni Make deadline.c code access the runqueue of a scheduling entity saved in the sched_dl_entity data structure. This allows future patches to save different runqueues in sched_dl_entity other than the global runqueues. Move dl_server_apply_params call in sched_init_dl_servers as the rq_of_dl_se function will return the correct deadline entity only if the dl_server flag is set. Add a WARN_ON on the return value of dl_server_apply_params in sched_init_dl_servers as this function may fail if the kernel is not configured correctly. Signed-off-by: luca abeni Signed-off-by: Yuri Andriaccio --- kernel/sched/deadline.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 7b7671060b..d7940c45f7 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -874,7 +874,7 @@ static void replenish_dl_entity(struct sched_dl_entity = *dl_se) * and arm the defer timer. */ if (dl_se->dl_defer && !dl_se->dl_defer_running && - dl_time_before(rq_clock(dl_se->rq), dl_se->deadline - dl_se->runtime)= ) { + dl_time_before(rq_clock(rq), dl_se->deadline - dl_se->runtime)) { if (!is_dl_boosted(dl_se)) { =20 /* @@ -1176,11 +1176,11 @@ static enum hrtimer_restart dl_server_timer(struct = hrtimer *timer, struct sched_ * of time. The dl_server_min_res serves as a limit to avoid * forwarding the timer for a too small amount of time. */ - if (dl_time_before(rq_clock(dl_se->rq), + if (dl_time_before(rq_clock(rq), (dl_se->deadline - dl_se->runtime - dl_server_min_res))) { =20 /* reset the defer timer */ - fw =3D dl_se->deadline - rq_clock(dl_se->rq) - dl_se->runtime; + fw =3D dl_se->deadline - rq_clock(rq) - dl_se->runtime; =20 hrtimer_forward_now(timer, ns_to_ktime(fw)); return HRTIMER_RESTART; @@ -1191,7 +1191,7 @@ static enum hrtimer_restart dl_server_timer(struct hr= timer *timer, struct sched_ =20 enqueue_dl_entity(dl_se, ENQUEUE_REPLENISH); =20 - if (!dl_task(dl_se->rq->curr) || dl_entity_preempt(dl_se, &dl_se->rq->cu= rr->dl)) + if (!dl_task(rq->curr) || dl_entity_preempt(dl_se, &rq->curr->dl)) resched_curr(rq); =20 __push_dl_task(rq, rf); @@ -1459,7 +1459,7 @@ static void update_curr_dl_se(struct rq *rq, struct s= ched_dl_entity *dl_se, s64 =20 hrtimer_try_to_cancel(&dl_se->dl_timer); =20 - replenish_dl_new_period(dl_se, dl_se->rq); + replenish_dl_new_period(dl_se, rq); =20 /* * Not being able to start the timer seems problematic. If it could not @@ -1572,23 +1572,24 @@ void dl_server_update(struct sched_dl_entity *dl_se= , s64 delta_exec) { /* 0 runtime =3D fair server disabled */ if (dl_se->dl_runtime) - update_curr_dl_se(dl_se->rq, dl_se, delta_exec); + update_curr_dl_se(rq_of_dl_se(dl_se), dl_se, delta_exec); } =20 void dl_server_start(struct sched_dl_entity *dl_se) { - struct rq *rq =3D dl_se->rq; + struct rq *rq; =20 if (!dl_server(dl_se) || dl_se->dl_server_active) return; =20 + rq =3D rq_of_dl_se(dl_se); if (WARN_ON_ONCE(!cpu_online(cpu_of(rq)))) return; =20 dl_se->dl_server_active =3D 1; enqueue_dl_entity(dl_se, ENQUEUE_WAKEUP); - if (!dl_task(dl_se->rq->curr) || dl_entity_preempt(dl_se, &rq->curr->dl)) - resched_curr(dl_se->rq); + if (!dl_task(rq->curr) || dl_entity_preempt(dl_se, &rq->curr->dl)) + resched_curr(rq); } =20 void dl_server_stop(struct sched_dl_entity *dl_se) @@ -1628,9 +1629,9 @@ void sched_init_dl_servers(void) =20 WARN_ON(dl_server(dl_se)); =20 - dl_server_apply_params(dl_se, runtime, period, 1); - dl_se->dl_server =3D 1; + WARN_ON(dl_server_apply_params(dl_se, runtime, period, 1)); + dl_se->dl_defer =3D 1; setup_new_dl_entity(dl_se); } @@ -1655,7 +1656,7 @@ int dl_server_apply_params(struct sched_dl_entity *dl= _se, u64 runtime, u64 perio { u64 old_bw =3D init ? 0 : to_ratio(dl_se->dl_period, dl_se->dl_runtime); u64 new_bw =3D to_ratio(period, runtime); - struct rq *rq =3D dl_se->rq; + struct rq *rq =3D rq_of_dl_se(dl_se); int cpu =3D cpu_of(rq); struct dl_bw *dl_b; unsigned long cap; @@ -1732,7 +1733,7 @@ static enum hrtimer_restart inactive_task_timer(struc= t hrtimer *timer) p =3D dl_task_of(dl_se); rq =3D task_rq_lock(p, &rf); } else { - rq =3D dl_se->rq; + rq =3D rq_of_dl_se(dl_se); rq_lock(rq, &rf); } =20 --=20 2.51.0