From nobody Mon Dec 1 22:02:17 2025 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 C5FED30F924 for ; Mon, 1 Dec 2025 12:42:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764592939; cv=none; b=GZp51n5RaqURSfwKvm/hveOGXyI1vRGg0VtEahwwdr/ILsetw1K5f8p5dHJooaHhI1GAgtloUDFlk6g5TstcYs5WQLdxqaPw9ntpAcah2VKjOwt6iWempv5jJHpVfCLN2g9UxxFw+0dIZS/92XLsto14Ig7hfQW1WtGZScROxZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764592939; c=relaxed/simple; bh=LWVL0V1CMyaANTn5Z44oxog+SfIvK0iqhIrhT3E77MA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cLOTCvI8mBrfbPl34gpJIcbyc/3JrZKewWVyZS+ssTa79xQusu6TBcmj6cObKZX09Ji4SomvI1n0r7+3zGeAUzDEG6zvCWMT39AJwuvIkpFSPpvZoPhN/jLITatbagUl1pTddqVbXqDGPYlzCzgX8XYk+3hjbOm/6EVgdmYlwRE= 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=VWzybl9b; arc=none smtp.client-ip=209.85.218.43 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="VWzybl9b" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-b7636c96b9aso566747366b.2 for ; Mon, 01 Dec 2025 04:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764592935; x=1765197735; 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=04AxSFOwxQMQiMuntsx/5ZGU1FwJkihpErkM8vIVFio=; b=VWzybl9bQ+GfVjQKmQ38G3MPNW/8L0JV5Vb7AkGsEIHxK47u+xyHMi5/HqO2CqXRiv TpeXgOgwJelgA1y9buTzDofi6GHIfaWPCkVcrxoF24QCxnID2yJbQKlAKOTnrniEZyac zmCp3J39kieFEtGXahioT7PpF2y/QAfwHFKgszlZYhmnSpuMdZm+AwNnd1QJ5t/t02uO lgIrT83un5CsDTDiJden19EmNIglpXQHJ2WSEQWggPAuqcAvUOF7boQ4JAjiklbK9nAe 5+DkIi8MDNTSkeMFaNA0Ud+0J/WhfLpDxr5P8sQ1eusqbb/yotorTYaEyPWckVRXfesj Fu5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764592935; x=1765197735; 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=04AxSFOwxQMQiMuntsx/5ZGU1FwJkihpErkM8vIVFio=; b=m/UoyoLsuexT3S6O8T+q0ordEgldHowy61a3zt2NPc86FvHYYegOaxceERgAAH6O23 W4W9DLbXY3n3yqv59AEaSk2cc9VGigvdxyOBjGWscSV7cGCbxKFGH0z3cvN/zmqLQkfs Xb1RYJ6bqh/8wysNwTzoRTechvdy7jzlGul3KLq6DL0baYnXXQvpkW7MeYvfLJQM/35q /hU/p9fIR/agRmOa/FAh22RC+8d5r96rNgVJexi76/TUvSXX4G5JCeViEmriEYF5c4VS zKNgDtR3LsVNXsyYUE5qP7MZUXikjWLnMjSNVFe7vDWx0ODkZnoglCuQ1DTtbv2Oi4Iy cDUg== X-Gm-Message-State: AOJu0YxFh3qNYKW4ViGQCTZf+LbeNt77LbnqOK/Ta3jfFPYa0b1tkkfv m1pjc+5rMFkC0lnCl66/MS9GMa2iqfUEg8/qMNbbjuVwNhk7H+yxsEQg X-Gm-Gg: ASbGnctuNjSrmw/SBo7fxGcmbeCtWCX4T6Fvm70k+CX99XAcRU+XtP40Gm60E2WthoP EynTAt+Q6IA4FoUl9nVg9ovIKWCvo/eoqkA15dvS2vuAOY7Ssw3fC15lVVnTttTcoaojRCxxdxW +mlc+DbKH7r77FCYlRmcOaq+Yh6K8/7Xm6VTizh03/leCsKAF7u8RV9dkySt2tLcnZGI51Pfu2u 0dj3SNRZJwPY87DFYdgO/o+RBxll1JjBWBYV2LepOVloS4Az1csJbjo/ZYec9Kv4DSWPWxgoctN wdmaHOKbEhjzKo2S7wJozILAOFeP0dH+uewPa3Oo4Amp7t3uRqB9Yo7elP1xU9vF3H4AS5gF1le Ho6h5rieve4Q5pVA3HXz+oNuYBCaiopxyZSjJ6FHqFF3iVMXUQ5fr4CP++9r0wj/v9xiNR0A+Mr Du2Qgd7tAC X-Google-Smtp-Source: AGHT+IFofmYDQIzDHpmspVKfKEjJ8aYV/NPOl+VwSiIdmApwpti0dXqINXJ7JpshQYzNKuaUaO/byQ== X-Received: by 2002:a17:907:9628:b0:b4a:e11a:195b with SMTP id a640c23a62f3a-b767184bc82mr3844451666b.44.1764592934803; Mon, 01 Dec 2025 04:42:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 04:42:14 -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 08/28] sched/core: Initialize HCBS specific structures. Date: Mon, 1 Dec 2025 13:41:41 +0100 Message-ID: <20251201124205.11169-9-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 - Update autogroups' creation/destruction to use the new data structures. - Initialize the default bandwidth for rt-cgroups (sched_init). - Initialize rt-scheduler's specific data structures for the root control group (sched_init). - Change signature of init_tg_rt_entry to accept a rq pointer for the local runqueue and a dl_se pointer for the global runqueue / dl_server entity, update the function to initialize the newly added HCBS fields. - Add utility functions to check (and get) if a rt_rq entity is connected to a rt-cgroup. Co-developed-by: Alessio Balsini Signed-off-by: Alessio Balsini Co-developed-by: Andrea Parri Signed-off-by: Andrea Parri Co-developed-by: Yuri Andriaccio Signed-off-by: Yuri Andriaccio Signed-off-by: luca abeni --- kernel/sched/autogroup.c | 4 ++-- kernel/sched/core.c | 11 +++++++++-- kernel/sched/deadline.c | 8 ++++++++ kernel/sched/rt.c | 11 ----------- kernel/sched/sched.h | 30 +++++++++++++++++++++++++++--- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/kernel/sched/autogroup.c b/kernel/sched/autogroup.c index cdea931aae..017eadc0a0 100644 --- a/kernel/sched/autogroup.c +++ b/kernel/sched/autogroup.c @@ -52,7 +52,7 @@ static inline void autogroup_destroy(struct kref *kref) =20 #ifdef CONFIG_RT_GROUP_SCHED /* We've redirected RT tasks to the root task group... */ - ag->tg->rt_se =3D NULL; + ag->tg->dl_se =3D NULL; ag->tg->rt_rq =3D NULL; #endif sched_release_group(ag->tg); @@ -109,7 +109,7 @@ static inline struct autogroup *autogroup_create(void) * the policy change to proceed. */ free_rt_sched_group(tg); - tg->rt_se =3D root_task_group.rt_se; + tg->dl_se =3D root_task_group.dl_se; tg->rt_rq =3D root_task_group.rt_rq; #endif /* CONFIG_RT_GROUP_SCHED */ tg->autogroup =3D ag; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ac5820b18c..495cbdfdc5 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8680,7 +8680,7 @@ void __init sched_init(void) scx_tg_init(&root_task_group); #endif /* CONFIG_EXT_GROUP_SCHED */ #ifdef CONFIG_RT_GROUP_SCHED - root_task_group.rt_se =3D (struct sched_rt_entity **)ptr; + root_task_group.dl_se =3D (struct sched_dl_entity **)ptr; ptr +=3D nr_cpu_ids * sizeof(void **); =20 root_task_group.rt_rq =3D (struct rt_rq **)ptr; @@ -8691,6 +8691,11 @@ void __init sched_init(void) =20 init_defrootdomain(); =20 +#ifdef CONFIG_RT_GROUP_SCHED + init_dl_bandwidth(&root_task_group.dl_bandwidth, + global_rt_period(), global_rt_runtime()); +#endif /* CONFIG_RT_GROUP_SCHED */ + #ifdef CONFIG_CGROUP_SCHED task_group_cache =3D KMEM_CACHE(task_group, 0); =20 @@ -8742,7 +8747,9 @@ void __init sched_init(void) * starts working after scheduler_running, which is not the case * yet. */ - init_tg_rt_entry(&root_task_group, &rq->rt, NULL, i, NULL); + rq->rt.tg =3D &root_task_group; + root_task_group.rt_rq[i] =3D &rq->rt; + root_task_group.dl_se[i] =3D NULL; #endif rq->sd =3D NULL; rq->rd =3D NULL; diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 501121d58b..3046148c94 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -513,6 +513,14 @@ static inline int is_leftmost(struct sched_dl_entity *= dl_se, struct dl_rq *dl_rq =20 static void init_dl_rq_bw_ratio(struct dl_rq *dl_rq); =20 +void init_dl_bandwidth(struct dl_bandwidth *dl_b, u64 period, u64 runtime) +{ + raw_spin_lock_init(&dl_b->dl_runtime_lock); + dl_b->dl_period =3D period; + dl_b->dl_runtime =3D runtime; +} + + void init_dl_bw(struct dl_bw *dl_b) { raw_spin_lock_init(&dl_b->lock); diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 21f4e94235..6a51232de6 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -96,17 +96,6 @@ void free_rt_sched_group(struct task_group *tg) return; } =20 -void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, - struct sched_rt_entity *rt_se, int cpu, - struct sched_rt_entity *parent) -{ - rt_rq->highest_prio.curr =3D MAX_RT_PRIO-1; - rt_rq->tg =3D tg; - - tg->rt_rq[cpu] =3D rt_rq; - tg->rt_se[cpu] =3D rt_se; -} - int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent) { if (!rt_group_sched_enabled()) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 75a3dc475b..6f6e39a628 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -601,9 +601,6 @@ extern void start_cfs_bandwidth(struct cfs_bandwidth *c= fs_b); extern void unthrottle_cfs_rq(struct cfs_rq *cfs_rq); extern bool cfs_task_bw_constrained(struct task_struct *p); =20 -extern void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, - struct sched_rt_entity *rt_se, int cpu, - struct sched_rt_entity *parent); extern int sched_group_set_rt_runtime(struct task_group *tg, long rt_runti= me_us); extern int sched_group_set_rt_period(struct task_group *tg, u64 rt_period_= us); extern long sched_group_rt_runtime(struct task_group *tg); @@ -2701,6 +2698,7 @@ extern void resched_curr(struct rq *rq); extern void resched_curr_lazy(struct rq *rq); extern void resched_cpu(int cpu); =20 +void init_dl_bandwidth(struct dl_bandwidth *dl_b, u64 period, u64 runtime); extern void init_dl_entity(struct sched_dl_entity *dl_se); =20 extern void init_cfs_throttle_work(struct task_struct *p); @@ -3114,6 +3112,22 @@ static inline struct rq *rq_of_rt_se(struct sched_rt= _entity *rt_se) { return rq_of_rt_rq(rt_se->rt_rq); } + +static inline int is_dl_group(struct rt_rq *rt_rq) +{ + return rt_rq->tg !=3D &root_task_group; +} + +/* + * Return the scheduling entity of this group of tasks. + */ +static inline struct sched_dl_entity *dl_group_of(struct rt_rq *rt_rq) +{ + if (WARN_ON_ONCE(!is_dl_group(rt_rq))) + return NULL; + + return rt_rq->tg->dl_se[served_rq_of_rt_rq(rt_rq)->cpu]; +} #else static inline struct task_struct *rt_task_of(struct sched_rt_entity *rt_se) { @@ -3143,6 +3157,16 @@ static inline struct rt_rq *rt_rq_of_se(struct sched= _rt_entity *rt_se) =20 return &rq->rt; } + +static inline int is_dl_group(struct rt_rq *rt_rq) +{ + return 0; +} + +static inline struct sched_dl_entity *dl_group_of(struct rt_rq *rt_rq) +{ + return NULL; +} #endif =20 DEFINE_LOCK_GUARD_2(double_rq_lock, struct rq, --=20 2.51.0