From nobody Wed Feb 11 07:48:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5813CC7EE23 for ; Thu, 8 Jun 2023 15:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237330AbjFHP7M (ORCPT ); Thu, 8 Jun 2023 11:59:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237141AbjFHP6l (ORCPT ); Thu, 8 Jun 2023 11:58:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 247D2E57 for ; Thu, 8 Jun 2023 08:58:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ABC4E64EC5 for ; Thu, 8 Jun 2023 15:58:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F821C4339B; Thu, 8 Jun 2023 15:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686239919; bh=hZr0IFnTxWMviMRdkn01XGuFZNJYi9czfgwV8AAhCIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BhiX8l8xRhpmhLR1xlVVX6jYb98Vl/3OF39Laq3v/ZvN+0bhYmuPZqXbUkHvoSGuX Zsh6dttXsdWQ23uITRcwXoC3Uw1eeU2NpS/qoYRNCyUQJjUkkP6xPmgbIA01yeoS+b BQ6Up46wBqs2r+dFfPYYAnxzXf04d+yvaI29ZZ2VZBvwdQtKJgxHcGFOM9qVBtVH1x b6NIdce73xXchVxz81yoyYPGAJK13FZ89TS0FdaK+wuESDf8F7kKYlXHwvidIiUipK tFH0YgjMWgCh4qDFDcRaQGbt5JyPYhJveO+ZNHrkyDk9ya4e4+GJOtl3/C1Lm4ro0+ 4mT/b9hDoUqIg== From: Daniel Bristot de Oliveira To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org, Luca Abeni , Tommaso Cucinotta , Thomas Gleixner , Joel Fernandes , Vineeth Pillai , Shuah Khan , Daniel Bristot de Oliveira Subject: [RFC PATCH V3 2/6] sched/deadline: Collect sched_dl_entity initialization Date: Thu, 8 Jun 2023 17:58:14 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Peter Zijlstra Create a single function that initializes a sched_dl_entity. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Daniel Bristot de Oliveira Reviewed-by: Phil Auld Reviewed-by: Valentin Schneider --- kernel/sched/core.c | 5 +---- kernel/sched/deadline.c | 22 +++++++++++++++------- kernel/sched/sched.h | 5 +---- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ac38225e6d09..e34b02cbe41f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4511,10 +4511,7 @@ static void __sched_fork(unsigned long clone_flags, = struct task_struct *p) memset(&p->stats, 0, sizeof(p->stats)); #endif =20 - RB_CLEAR_NODE(&p->dl.rb_node); - init_dl_task_timer(&p->dl); - init_dl_inactive_task_timer(&p->dl); - __dl_clear_params(p); + init_dl_entity(&p->dl); =20 INIT_LIST_HEAD(&p->rt.run_list); p->rt.timeout =3D 0; diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 030e7c11607f..22e5e64812c9 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -333,6 +333,8 @@ static void dl_change_utilization(struct task_struct *p= , u64 new_bw) __add_rq_bw(new_bw, &rq->dl); } =20 +static void __dl_clear_params(struct sched_dl_entity *dl_se); + /* * The utilization of a task cannot be immediately removed from * the rq active utilization (running_bw) when the task blocks. @@ -432,7 +434,7 @@ static void task_non_contending(struct task_struct *p) raw_spin_lock(&dl_b->lock); __dl_sub(dl_b, p->dl.dl_bw, dl_bw_cpus(task_cpu(p))); raw_spin_unlock(&dl_b->lock); - __dl_clear_params(p); + __dl_clear_params(dl_se); } =20 return; @@ -1205,7 +1207,7 @@ static enum hrtimer_restart dl_task_timer(struct hrti= mer *timer) return HRTIMER_NORESTART; } =20 -void init_dl_task_timer(struct sched_dl_entity *dl_se) +static void init_dl_task_timer(struct sched_dl_entity *dl_se) { struct hrtimer *timer =3D &dl_se->dl_timer; =20 @@ -1415,7 +1417,7 @@ static enum hrtimer_restart inactive_task_timer(struc= t hrtimer *timer) raw_spin_lock(&dl_b->lock); __dl_sub(dl_b, p->dl.dl_bw, dl_bw_cpus(task_cpu(p))); raw_spin_unlock(&dl_b->lock); - __dl_clear_params(p); + __dl_clear_params(dl_se); =20 goto unlock; } @@ -1431,7 +1433,7 @@ static enum hrtimer_restart inactive_task_timer(struc= t hrtimer *timer) return HRTIMER_NORESTART; } =20 -void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se) +static void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se) { struct hrtimer *timer =3D &dl_se->inactive_timer; =20 @@ -2974,10 +2976,8 @@ bool __checkparam_dl(const struct sched_attr *attr) /* * This function clears the sched_dl_entity static params. */ -void __dl_clear_params(struct task_struct *p) +static void __dl_clear_params(struct sched_dl_entity *dl_se) { - struct sched_dl_entity *dl_se =3D &p->dl; - dl_se->dl_runtime =3D 0; dl_se->dl_deadline =3D 0; dl_se->dl_period =3D 0; @@ -2995,6 +2995,14 @@ void __dl_clear_params(struct task_struct *p) #endif } =20 +void init_dl_entity(struct sched_dl_entity *dl_se) +{ + RB_CLEAR_NODE(&dl_se->rb_node); + init_dl_task_timer(dl_se); + init_dl_inactive_task_timer(dl_se); + __dl_clear_params(dl_se); +} + bool dl_param_changed(struct task_struct *p, const struct sched_attr *attr) { struct sched_dl_entity *dl_se =3D &p->dl; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index da0cec2fc63a..fa6512070fa7 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -284,8 +284,6 @@ struct rt_bandwidth { unsigned int rt_period_active; }; =20 -void __dl_clear_params(struct task_struct *p); - static inline int dl_bandwidth_enabled(void) { return sysctl_sched_rt_runtime >=3D 0; @@ -2390,8 +2388,7 @@ extern struct rt_bandwidth def_rt_bandwidth; extern void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 r= untime); extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq); =20 -extern void init_dl_task_timer(struct sched_dl_entity *dl_se); -extern void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se); +extern void init_dl_entity(struct sched_dl_entity *dl_se); =20 #define BW_SHIFT 20 #define BW_UNIT (1 << BW_SHIFT) --=20 2.40.1