From nobody Tue Jun 23 16:14:52 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 2BC97C433F5 for ; Wed, 2 Mar 2022 18:34:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244632AbiCBSfi (ORCPT ); Wed, 2 Mar 2022 13:35:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244615AbiCBSfg (ORCPT ); Wed, 2 Mar 2022 13:35:36 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 90AE4CA305 for ; Wed, 2 Mar 2022 10:34:52 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 46E371424; Wed, 2 Mar 2022 10:34:52 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B53193F73D; Wed, 2 Mar 2022 10:34:46 -0800 (PST) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Daniel Bristot de Oliveira Cc: Vincent Guittot , Mel Gorman , Ben Segall , Luca Abeni , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] sched/deadline: Remove unused def_dl_bandwidth Date: Wed, 2 Mar 2022 19:34:28 +0100 Message-Id: <20220302183433.333029-2-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302183433.333029-1-dietmar.eggemann@arm.com> References: <20220302183433.333029-1-dietmar.eggemann@arm.com> 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" Since commit 1724813d9f2c ("sched/deadline: Remove the sysctl_sched_dl knobs") the default deadline bandwidth control structure has no purpose. Remove it. Signed-off-by: Dietmar Eggemann Acked-by: Juri Lelli --- kernel/sched/core.c | 1 - kernel/sched/deadline.c | 7 ------- kernel/sched/sched.h | 1 - 3 files changed, 9 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 3aafc15da24a..d342c4c779f7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9420,7 +9420,6 @@ void __init sched_init(void) #endif /* CONFIG_CPUMASK_OFFSTACK */ =20 init_rt_bandwidth(&def_rt_bandwidth, global_rt_period(), global_rt_runtim= e()); - init_dl_bandwidth(&def_dl_bandwidth, global_rt_period(), global_rt_runtim= e()); =20 #ifdef CONFIG_SMP init_defrootdomain(); diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 62f0cf842277..ed4251fa87c7 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -18,8 +18,6 @@ #include "sched.h" #include "pelt.h" =20 -struct dl_bandwidth def_dl_bandwidth; - static inline struct task_struct *dl_task_of(struct sched_dl_entity *dl_se) { return container_of(dl_se, struct task_struct, dl); @@ -423,12 +421,10 @@ void init_dl_bandwidth(struct dl_bandwidth *dl_b, u64= period, u64 runtime) void init_dl_bw(struct dl_bw *dl_b) { raw_spin_lock_init(&dl_b->lock); - raw_spin_lock(&def_dl_bandwidth.dl_runtime_lock); if (global_rt_runtime() =3D=3D RUNTIME_INF) dl_b->bw =3D -1; else dl_b->bw =3D to_ratio(global_rt_period(), global_rt_runtime()); - raw_spin_unlock(&def_dl_bandwidth.dl_runtime_lock); dl_b->total_bw =3D 0; } =20 @@ -2731,9 +2727,6 @@ void sched_dl_do_global(void) int cpu; unsigned long flags; =20 - def_dl_bandwidth.dl_period =3D global_rt_period(); - def_dl_bandwidth.dl_runtime =3D global_rt_runtime(); - if (global_rt_runtime() !=3D RUNTIME_INF) new_bw =3D to_ratio(global_rt_period(), global_rt_runtime()); =20 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 3da5718cd641..a8b8516b8452 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2333,7 +2333,6 @@ extern void resched_cpu(int cpu); extern struct rt_bandwidth def_rt_bandwidth; extern void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 r= untime); =20 -extern struct dl_bandwidth def_dl_bandwidth; extern void init_dl_bandwidth(struct dl_bandwidth *dl_b, u64 period, u64 r= untime); 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); --=20 2.25.1 From nobody Tue Jun 23 16:14:52 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 4CDACC433F5 for ; Wed, 2 Mar 2022 18:35:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244623AbiCBSfn (ORCPT ); Wed, 2 Mar 2022 13:35:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236812AbiCBSfj (ORCPT ); Wed, 2 Mar 2022 13:35:39 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 83571D64ED for ; Wed, 2 Mar 2022 10:34:55 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 405871480; Wed, 2 Mar 2022 10:34:55 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A30463F73D; Wed, 2 Mar 2022 10:34:52 -0800 (PST) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Daniel Bristot de Oliveira Cc: Vincent Guittot , Mel Gorman , Ben Segall , Luca Abeni , linux-kernel@vger.kernel.org Subject: [PATCH 2/6] sched/deadline: Move bandwidth mgmt and reclaim functions into sched class source file Date: Wed, 2 Mar 2022 19:34:29 +0100 Message-Id: <20220302183433.333029-3-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302183433.333029-1-dietmar.eggemann@arm.com> References: <20220302183433.333029-1-dietmar.eggemann@arm.com> 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" Move the deadline bandwidth management (admission control) functions __dl_add(), __dl_sub() and __dl_overflow() as well as the bandwidth reclaim function __dl_update() from private task scheduler header file to the deadline sched class source file. The functions are only used internally so they don't have to be exported. Signed-off-by: Dietmar Eggemann Acked-by: Juri Lelli --- kernel/sched/deadline.c | 44 ++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 49 ----------------------------------------- 2 files changed, 44 insertions(+), 49 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index ed4251fa87c7..81bf97648e42 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -128,6 +128,21 @@ static inline bool dl_bw_visited(int cpu, u64 gen) rd->visit_gen =3D gen; return false; } + +static inline +void __dl_update(struct dl_bw *dl_b, s64 bw) +{ + struct root_domain *rd =3D container_of(dl_b, struct root_domain, dl_bw); + int i; + + RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(), + "sched RCU must be held"); + for_each_cpu_and(i, rd->span, cpu_active_mask) { + struct rq *rq =3D cpu_rq(i); + + rq->dl.extra_bw +=3D bw; + } +} #else static inline struct dl_bw *dl_bw_of(int i) { @@ -148,8 +163,37 @@ static inline bool dl_bw_visited(int cpu, u64 gen) { return false; } + +static inline +void __dl_update(struct dl_bw *dl_b, s64 bw) +{ + struct dl_rq *dl =3D container_of(dl_b, struct dl_rq, dl_bw); + + dl->extra_bw +=3D bw; +} #endif =20 +static inline +void __dl_sub(struct dl_bw *dl_b, u64 tsk_bw, int cpus) +{ + dl_b->total_bw -=3D tsk_bw; + __dl_update(dl_b, (s32)tsk_bw / cpus); +} + +static inline +void __dl_add(struct dl_bw *dl_b, u64 tsk_bw, int cpus) +{ + dl_b->total_bw +=3D tsk_bw; + __dl_update(dl_b, -((s32)tsk_bw / cpus)); +} + +static inline bool +__dl_overflow(struct dl_bw *dl_b, unsigned long cap, u64 old_bw, u64 new_b= w) +{ + return dl_b->bw !=3D -1 && + cap_scale(dl_b->bw, cap) < dl_b->total_bw - old_bw + new_bw; +} + static inline void __add_running_bw(u64 dl_bw, struct dl_rq *dl_rq) { diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index a8b8516b8452..4dfc3b02df61 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -301,29 +301,6 @@ struct dl_bw { u64 total_bw; }; =20 -static inline void __dl_update(struct dl_bw *dl_b, s64 bw); - -static inline -void __dl_sub(struct dl_bw *dl_b, u64 tsk_bw, int cpus) -{ - dl_b->total_bw -=3D tsk_bw; - __dl_update(dl_b, (s32)tsk_bw / cpus); -} - -static inline -void __dl_add(struct dl_bw *dl_b, u64 tsk_bw, int cpus) -{ - dl_b->total_bw +=3D tsk_bw; - __dl_update(dl_b, -((s32)tsk_bw / cpus)); -} - -static inline bool __dl_overflow(struct dl_bw *dl_b, unsigned long cap, - u64 old_bw, u64 new_bw) -{ - return dl_b->bw !=3D -1 && - cap_scale(dl_b->bw, cap) < dl_b->total_bw - old_bw + new_bw; -} - /* * Verify the fitness of task @p to run on @cpu taking into account the * CPU original capacity and the runtime/deadline ratio of the task. @@ -2748,32 +2725,6 @@ extern void nohz_run_idle_balance(int cpu); static inline void nohz_run_idle_balance(int cpu) { } #endif =20 -#ifdef CONFIG_SMP -static inline -void __dl_update(struct dl_bw *dl_b, s64 bw) -{ - struct root_domain *rd =3D container_of(dl_b, struct root_domain, dl_bw); - int i; - - RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(), - "sched RCU must be held"); - for_each_cpu_and(i, rd->span, cpu_active_mask) { - struct rq *rq =3D cpu_rq(i); - - rq->dl.extra_bw +=3D bw; - } -} -#else -static inline -void __dl_update(struct dl_bw *dl_b, s64 bw) -{ - struct dl_rq *dl =3D container_of(dl_b, struct dl_rq, dl_bw); - - dl->extra_bw +=3D bw; -} -#endif - - #ifdef CONFIG_IRQ_TIME_ACCOUNTING struct irqtime { u64 total; --=20 2.25.1 From nobody Tue Jun 23 16:14:52 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 B3682C433EF for ; Wed, 2 Mar 2022 18:35:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244653AbiCBSfp (ORCPT ); Wed, 2 Mar 2022 13:35:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244615AbiCBSfm (ORCPT ); Wed, 2 Mar 2022 13:35:42 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 538C0D5DD2 for ; Wed, 2 Mar 2022 10:34:58 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1E5CF1509; Wed, 2 Mar 2022 10:34:58 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9F08F3F73D; Wed, 2 Mar 2022 10:34:55 -0800 (PST) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Daniel Bristot de Oliveira Cc: Vincent Guittot , Mel Gorman , Ben Segall , Luca Abeni , linux-kernel@vger.kernel.org Subject: [PATCH 3/6] sched/deadline: Merge dl_task_can_attach() and dl_cpu_busy() Date: Wed, 2 Mar 2022 19:34:30 +0100 Message-Id: <20220302183433.333029-4-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302183433.333029-1-dietmar.eggemann@arm.com> References: <20220302183433.333029-1-dietmar.eggemann@arm.com> 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" Both functions are doing almost the same, that is checking if admission control is still respected. With exclusive cpusets, dl_task_can_attach() checks if the destination cpuset (i.e. its root domain) has enough CPU capacity to accommodate the task. dl_cpu_busy() checks if there is enough CPU capacity in the cpuset in case the CPU is hot-plugged out. dl_task_can_attach() is used to check if a task can be admitted while dl_cpu_busy() is used to check if a CPU can be hotplugged out. Make dl_cpu_busy() able to deal with a task and use it instead of dl_task_can_attach() in task_can_attach(). Signed-off-by: Dietmar Eggemann Acked-by: Juri Lelli --- kernel/sched/core.c | 13 +++++++---- kernel/sched/deadline.c | 52 +++++++++++------------------------------ kernel/sched/sched.h | 3 +-- 3 files changed, 24 insertions(+), 44 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d342c4c779f7..68736d1dc0f4 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8805,8 +8805,11 @@ int task_can_attach(struct task_struct *p, } =20 if (dl_task(p) && !cpumask_intersects(task_rq(p)->rd->span, - cs_cpus_allowed)) - ret =3D dl_task_can_attach(p, cs_cpus_allowed); + cs_cpus_allowed)) { + int cpu =3D cpumask_any_and(cpu_active_mask, cs_cpus_allowed); + + ret =3D dl_cpu_busy(cpu, p); + } =20 out: return ret; @@ -9090,8 +9093,10 @@ static void cpuset_cpu_active(void) static int cpuset_cpu_inactive(unsigned int cpu) { if (!cpuhp_tasks_frozen) { - if (dl_cpu_busy(cpu)) - return -EBUSY; + int ret =3D dl_cpu_busy(cpu, NULL); + + if (ret) + return ret; cpuset_update_active_cpus(); } else { num_cpus_frozen++; diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 81bf97648e42..de677b1e3767 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2992,41 +2992,6 @@ bool dl_param_changed(struct task_struct *p, const s= truct sched_attr *attr) } =20 #ifdef CONFIG_SMP -int dl_task_can_attach(struct task_struct *p, const struct cpumask *cs_cpu= s_allowed) -{ - unsigned long flags, cap; - unsigned int dest_cpu; - struct dl_bw *dl_b; - bool overflow; - int ret; - - dest_cpu =3D cpumask_any_and(cpu_active_mask, cs_cpus_allowed); - - rcu_read_lock_sched(); - dl_b =3D dl_bw_of(dest_cpu); - raw_spin_lock_irqsave(&dl_b->lock, flags); - cap =3D dl_bw_capacity(dest_cpu); - overflow =3D __dl_overflow(dl_b, cap, 0, p->dl.dl_bw); - if (overflow) { - ret =3D -EBUSY; - } else { - /* - * We reserve space for this task in the destination - * root_domain, as we can't fail after this point. - * We will free resources in the source root_domain - * later on (see set_cpus_allowed_dl()). - */ - int cpus =3D dl_bw_cpus(dest_cpu); - - __dl_add(dl_b, p->dl.dl_bw, cpus); - ret =3D 0; - } - raw_spin_unlock_irqrestore(&dl_b->lock, flags); - rcu_read_unlock_sched(); - - return ret; -} - int dl_cpuset_cpumask_can_shrink(const struct cpumask *cur, const struct cpumask *trial) { @@ -3048,7 +3013,7 @@ int dl_cpuset_cpumask_can_shrink(const struct cpumask= *cur, return ret; } =20 -bool dl_cpu_busy(unsigned int cpu) +int dl_cpu_busy(int cpu, struct task_struct *p) { unsigned long flags, cap; struct dl_bw *dl_b; @@ -3058,11 +3023,22 @@ bool dl_cpu_busy(unsigned int cpu) dl_b =3D dl_bw_of(cpu); raw_spin_lock_irqsave(&dl_b->lock, flags); cap =3D dl_bw_capacity(cpu); - overflow =3D __dl_overflow(dl_b, cap, 0, 0); + overflow =3D __dl_overflow(dl_b, cap, 0, p ? p->dl.dl_bw : 0); + + if (!overflow && p) { + /* + * We reserve space for this task in the destination + * root_domain, as we can't fail after this point. + * We will free resources in the source root_domain + * later on (see set_cpus_allowed_dl()). + */ + __dl_add(dl_b, p->dl.dl_bw, dl_bw_cpus(cpu)); + } + raw_spin_unlock_irqrestore(&dl_b->lock, flags); rcu_read_unlock_sched(); =20 - return overflow; + return overflow ? -EBUSY : 0; } #endif =20 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 4dfc3b02df61..0720cf0c7df1 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -324,9 +324,8 @@ extern void __setparam_dl(struct task_struct *p, const = struct sched_attr *attr); extern void __getparam_dl(struct task_struct *p, struct sched_attr *attr); extern bool __checkparam_dl(const struct sched_attr *attr); extern bool dl_param_changed(struct task_struct *p, const struct sched_att= r *attr); -extern int dl_task_can_attach(struct task_struct *p, const struct cpumask= *cs_cpus_allowed); extern int dl_cpuset_cpumask_can_shrink(const struct cpumask *cur, const = struct cpumask *trial); -extern bool dl_cpu_busy(unsigned int cpu); +extern int dl_cpu_busy(int cpu, struct task_struct *p); =20 #ifdef CONFIG_CGROUP_SCHED =20 --=20 2.25.1 From nobody Tue Jun 23 16:14:52 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 26F46C433F5 for ; Wed, 2 Mar 2022 18:35:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244615AbiCBSft (ORCPT ); Wed, 2 Mar 2022 13:35:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244650AbiCBSfp (ORCPT ); Wed, 2 Mar 2022 13:35:45 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3B656D8371 for ; Wed, 2 Mar 2022 10:35:01 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EBF4A150C; Wed, 2 Mar 2022 10:35:00 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7E17B3F73D; Wed, 2 Mar 2022 10:34:58 -0800 (PST) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Daniel Bristot de Oliveira Cc: Vincent Guittot , Mel Gorman , Ben Segall , Luca Abeni , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] sched/deadline: Use __node_2_[pdl|dle]() and rb_first_cached() consistently Date: Wed, 2 Mar 2022 19:34:31 +0100 Message-Id: <20220302183433.333029-5-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302183433.333029-1-dietmar.eggemann@arm.com> References: <20220302183433.333029-1-dietmar.eggemann@arm.com> 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" Deploy __node_2_pdl(node), __node_2_dle(node) and rb_first_cached() consistently throughout the sched class source file which makes the code at least easier to read. Signed-off-by: Dietmar Eggemann Acked-by: Juri Lelli --- kernel/sched/deadline.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index de677b1e3767..3242dd4972e1 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -450,7 +450,7 @@ static inline int is_leftmost(struct task_struct *p, st= ruct dl_rq *dl_rq) { struct sched_dl_entity *dl_se =3D &p->dl; =20 - return dl_rq->root.rb_leftmost =3D=3D &dl_se->rb_node; + return rb_first_cached(&dl_rq->root) =3D=3D &dl_se->rb_node; } =20 static void init_dl_rq_bw_ratio(struct dl_rq *dl_rq); @@ -1433,6 +1433,9 @@ void init_dl_inactive_task_timer(struct sched_dl_enti= ty *dl_se) timer->function =3D inactive_task_timer; } =20 +#define __node_2_dle(node) \ + rb_entry((node), struct sched_dl_entity, rb_node) + #ifdef CONFIG_SMP =20 static void inc_dl_deadline(struct dl_rq *dl_rq, u64 deadline) @@ -1462,10 +1465,9 @@ static void dec_dl_deadline(struct dl_rq *dl_rq, u64= deadline) cpudl_clear(&rq->rd->cpudl, rq->cpu); cpupri_set(&rq->rd->cpupri, rq->cpu, rq->rt.highest_prio.curr); } else { - struct rb_node *leftmost =3D dl_rq->root.rb_leftmost; - struct sched_dl_entity *entry; + struct rb_node *leftmost =3D rb_first_cached(&dl_rq->root); + struct sched_dl_entity *entry =3D __node_2_dle(leftmost); =20 - entry =3D rb_entry(leftmost, struct sched_dl_entity, rb_node); dl_rq->earliest_dl.curr =3D entry->deadline; cpudl_set(&rq->rd->cpudl, rq->cpu, entry->deadline); } @@ -1506,9 +1508,6 @@ void dec_dl_tasks(struct sched_dl_entity *dl_se, stru= ct dl_rq *dl_rq) dec_dl_migration(dl_se, dl_rq); } =20 -#define __node_2_dle(node) \ - rb_entry((node), struct sched_dl_entity, rb_node) - static inline bool __dl_less(struct rb_node *a, const struct rb_node *b) { return dl_time_before(__node_2_dle(a)->deadline, __node_2_dle(b)->deadlin= e); @@ -1979,7 +1978,7 @@ static struct sched_dl_entity *pick_next_dl_entity(st= ruct rq *rq, if (!left) return NULL; =20 - return rb_entry(left, struct sched_dl_entity, rb_node); + return __node_2_dle(left); } =20 static struct task_struct *pick_task_dl(struct rq *rq) @@ -2074,15 +2073,17 @@ static int pick_dl_task(struct rq *rq, struct task_= struct *p, int cpu) */ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, i= nt cpu) { - struct rb_node *next_node =3D rq->dl.pushable_dl_tasks_root.rb_leftmost; struct task_struct *p =3D NULL; + struct rb_node *next_node; =20 if (!has_pushable_dl_tasks(rq)) return NULL; =20 + next_node =3D rb_first_cached(&rq->dl.pushable_dl_tasks_root); + next_node: if (next_node) { - p =3D rb_entry(next_node, struct task_struct, pushable_dl_tasks); + p =3D __node_2_pdl(next_node); =20 if (pick_dl_task(rq, p, cpu)) return p; @@ -2248,8 +2249,7 @@ static struct task_struct *pick_next_pushable_dl_task= (struct rq *rq) if (!has_pushable_dl_tasks(rq)) return NULL; =20 - p =3D rb_entry(rq->dl.pushable_dl_tasks_root.rb_leftmost, - struct task_struct, pushable_dl_tasks); + p =3D __node_2_pdl(rb_first_cached(&rq->dl.pushable_dl_tasks_root)); =20 BUG_ON(rq->cpu !=3D task_cpu(p)); BUG_ON(task_current(rq, p)); --=20 2.25.1 From nobody Tue Jun 23 16:14:52 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 7C52AC433F5 for ; Wed, 2 Mar 2022 18:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244656AbiCBSf4 (ORCPT ); Wed, 2 Mar 2022 13:35:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244643AbiCBSfs (ORCPT ); Wed, 2 Mar 2022 13:35:48 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27EC2D887C for ; Wed, 2 Mar 2022 10:35:04 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EA2761515; Wed, 2 Mar 2022 10:35:03 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5DAAD3F73D; Wed, 2 Mar 2022 10:35:01 -0800 (PST) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Daniel Bristot de Oliveira Cc: Vincent Guittot , Mel Gorman , Ben Segall , Luca Abeni , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] sched/deadline,rt: Remove unused functions for !CONFIG_SMP Date: Wed, 2 Mar 2022 19:34:32 +0100 Message-Id: <20220302183433.333029-6-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302183433.333029-1-dietmar.eggemann@arm.com> References: <20220302183433.333029-1-dietmar.eggemann@arm.com> 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" The need_pull_[rt|dl]_task() and pull_[rt|dl]_task() functions are not used on a !CONFIG_SMP system. Remove them. Signed-off-by: Dietmar Eggemann Acked-by: Juri Lelli --- kernel/sched/deadline.c | 9 --------- kernel/sched/rt.c | 11 ----------- 2 files changed, 20 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 3242dd4972e1..93fcef57dd59 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -723,15 +723,6 @@ void dec_dl_migration(struct sched_dl_entity *dl_se, s= truct dl_rq *dl_rq) { } =20 -static inline bool need_pull_dl_task(struct rq *rq, struct task_struct *pr= ev) -{ - return false; -} - -static inline void pull_dl_task(struct rq *rq) -{ -} - static inline void deadline_queue_push_tasks(struct rq *rq) { } diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 14f273c29518..b62e7652464b 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -271,8 +271,6 @@ int alloc_rt_sched_group(struct task_group *tg, struct = task_group *parent) =20 #ifdef CONFIG_SMP =20 -static void pull_rt_task(struct rq *this_rq); - static inline bool need_pull_rt_task(struct rq *rq, struct task_struct *pr= ev) { /* Try to pull RT tasks here if we lower this rq's prio */ @@ -429,15 +427,6 @@ void dec_rt_migration(struct sched_rt_entity *rt_se, s= truct rt_rq *rt_rq) { } =20 -static inline bool need_pull_rt_task(struct rq *rq, struct task_struct *pr= ev) -{ - return false; -} - -static inline void pull_rt_task(struct rq *this_rq) -{ -} - static inline void rt_queue_push_tasks(struct rq *rq) { } --=20 2.25.1 From nobody Tue Jun 23 16:14:52 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 510D2C433F5 for ; Wed, 2 Mar 2022 18:35:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244658AbiCBSgA (ORCPT ); Wed, 2 Mar 2022 13:36:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241828AbiCBSfw (ORCPT ); Wed, 2 Mar 2022 13:35:52 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 53579D8355 for ; Wed, 2 Mar 2022 10:35:07 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E34501516; Wed, 2 Mar 2022 10:35:06 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 563333F73D; Wed, 2 Mar 2022 10:35:04 -0800 (PST) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Daniel Bristot de Oliveira Cc: Vincent Guittot , Mel Gorman , Ben Segall , Luca Abeni , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] sched/deadline,rt: Remove unused parameter from pick_next_[rt|dl]_entity() Date: Wed, 2 Mar 2022 19:34:33 +0100 Message-Id: <20220302183433.333029-7-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302183433.333029-1-dietmar.eggemann@arm.com> References: <20220302183433.333029-1-dietmar.eggemann@arm.com> 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" The `struct rq *rq` parameter isn't used. Remove it. Signed-off-by: Dietmar Eggemann Acked-by: Juri Lelli --- kernel/sched/deadline.c | 5 ++--- kernel/sched/rt.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 93fcef57dd59..11cdc6d0c45f 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1961,8 +1961,7 @@ static void set_next_task_dl(struct rq *rq, struct ta= sk_struct *p, bool first) deadline_queue_push_tasks(rq); } =20 -static struct sched_dl_entity *pick_next_dl_entity(struct rq *rq, - struct dl_rq *dl_rq) +static struct sched_dl_entity *pick_next_dl_entity(struct dl_rq *dl_rq) { struct rb_node *left =3D rb_first_cached(&dl_rq->root); =20 @@ -1981,7 +1980,7 @@ static struct task_struct *pick_task_dl(struct rq *rq) if (!sched_dl_runnable(rq)) return NULL; =20 - dl_se =3D pick_next_dl_entity(rq, dl_rq); + dl_se =3D pick_next_dl_entity(dl_rq); BUG_ON(!dl_se); p =3D dl_task_of(dl_se); =20 diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index b62e7652464b..67039e5d359b 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1719,8 +1719,7 @@ static inline void set_next_task_rt(struct rq *rq, st= ruct task_struct *p, bool f rt_queue_push_tasks(rq); } =20 -static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq, - struct rt_rq *rt_rq) +static struct sched_rt_entity *pick_next_rt_entity(struct rt_rq *rt_rq) { struct rt_prio_array *array =3D &rt_rq->active; struct sched_rt_entity *next =3D NULL; @@ -1742,7 +1741,7 @@ static struct task_struct *_pick_next_task_rt(struct = rq *rq) struct rt_rq *rt_rq =3D &rq->rt; =20 do { - rt_se =3D pick_next_rt_entity(rq, rt_rq); + rt_se =3D pick_next_rt_entity(rt_rq); BUG_ON(!rt_se); rt_rq =3D group_rt_rq(rt_se); } while (rt_rq); --=20 2.25.1