sched: Remove some redundancy
Dietmar Eggemann
reviewercover sched: Remove some redundancy
Remove redundant functions, parameters and macros from the task scheduler code.
Dietmar Eggemann (4):
sched/pelt: Remove redundant cap_scale() definition sched/core: Remove redundant 'preempt' param from
sched_class->yield_to_task()
sched/idle,stop: Remove .get_rr_interval from sched_class sched/fair: Remove unused 'sd' parameter from scale_rt_capacity()
kernel/sched/core.c | 2 +- kernel/sched/fair.c | 6 +++--- kernel/sched/idle.c | 7 ------- kernel/sched/pelt.c | 2 -- kernel/sched/sched.h | 2 +- kernel/sched/stop_task.c | 8 -------- 6 files changed, 5 insertions(+), 22 deletions(-)
Signature · 1 line
2.17.1
Dietmar Eggemann
reviewerPATCH 1/4 sched/pelt: Remove redundant cap_scale() definition
Besides in PELT cap_scale() is used in the Deadline scheduler class for scale-invariant bandwidth enforcement.
Remove the cap_scale() definition in kernel/sched/pelt.c and keep the one in kernel/sched/sched.h.
--- kernel/sched/pelt.c | 2 -- 1 file changed, 2 deletions(-)
kernel/sched/pelt.c +0 -2
@@ -83,8 +83,6 @@ static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3)return c1 + c2 + c3; } -#define cap_scale (v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) -/* * Accumulate the three separate parts of the sum; d1 the remainder * of the last (incomplete) period, d2 the span of full periods and d3
Signature · 1 line
2.17.1
Re: [PATCH 1/4] sched/pelt: Remove redundant cap_scale() definition
Quoted 7 lines · Dietmar Eggemann
Besides in PELT
cap_scale()is used in the Deadline scheduler class for scale-invariant bandwidth enforcement.
Remove thecap_scale()definition inkernel/sched/pelt.cand keep the one inkernel/sched/sched.h.Signed-off-by Dietmar Eggemann <[email protected]>
Quoted 20 lines
--- kernel/sched/pelt.c | 2 -- 1 file changed, 2 deletions(-)kernel/sched/pelt.c +0
-3@@ -83,8 +83,6 @@ static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3)return c1 + c2 + c3; } -#define cap_scale (v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) -/* * Accumulate the three separate parts of the sum; d1 the remainder * of the last (incomplete) period, d2 the span of full periods and d3 -- 2.17.1
[tip: sched/core] sched/pelt: Remove redundant cap_scale() definition
In reply to Dietmar EggemannThe following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 844eb6458facb09d4871a480d8bda06550927a80 Gitweb: https://git.kernel.org/tip/844eb6458facb09d4871a480d8bda06550927a80 Author: Dietmar Eggemann <[email protected]> AuthorDate: Wed, 03 Jun 2020 10:03:01 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 15 Jun 2020 14:10:01 +02:00
sched/pelt: Remove redundant cap_scale() definition
Besides in PELT cap_scale() is used in the Deadline scheduler class for scale-invariant bandwidth enforcement.
Remove the cap_scale() definition in kernel/sched/pelt.c and keep the one in kernel/sched/sched.h.
--- kernel/sched/pelt.c | 2 -- 1 file changed, 2 deletions(-)
kernel/sched/pelt.c +0 -2
@@ -83,8 +83,6 @@ static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3)return c1 + c2 + c3; } -#define cap_scale (v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) -/* * Accumulate the three separate parts of the sum; d1 the remainder * of the last (incomplete) period, d2 the span of full periods and d3
Dietmar Eggemann
reviewerPATCH 2/4 sched/core: Remove redundant 'preempt' param from sched_class->yield_to_task()
In reply to Dietmar EggemannCommit 6d1cafd8b56e ("sched: Resched proper CPU on yield_to()") moved the code to resched the CPU from yield_to_task_fair() to yield_to() making the preempt parameter in sched_class->yield_to_task() unnecessary. Remove it. No other sched_class implements yield_to_task().
--- kernel/sched/core.c | 2 +- kernel/sched/fair.c | 2 +- kernel/sched/sched.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
kernel/sched/core.c +1 -1
@@ -5812,7 +5812,7 @@ int __sched yield_to(struct task_struct *p, bool preempt)if (task_running (p_rq, p) || p->state) goto out_unlock; - yielded = curr->sched_class->yield_to_task (rq, p, preempt); + yielded = curr->sched_class->yield_to_task (rq, p);if (yielded) {schedstat_inc (rq->yld_count);/*
kernel/sched/fair.c +1 -1
@@ -7158,7 +7158,7 @@ static void yield_task_fair(struct rq *rq)set_skip_buddy (se); } -static bool yield_to_task_fair (struct rq *rq,struct task_struct *p,bool preempt) +static bool yield_to_task_fair (struct rq *rq,struct task_struct *p) {struct sched_entity *se = &p->se;
kernel/sched/sched.h +1 -1
@@ -1752,7 +1752,7 @@ struct sched_class {void (*enqueue_task) (struct rq *rq,struct task_struct *p,int flags);void (*dequeue_task) (struct rq *rq,struct task_struct *p,int flags);void (*yield_task) (struct rq *rq); -bool (*yield_to_task)(struct rq *rq,struct task_struct *p,bool preempt); +bool (*yield_to_task)(struct rq *rq,struct task_struct *p);void (*check_preempt_curr)(struct rq *rq,struct task_struct *p,int flags);
Signature · 1 line
2.17.1
[tip: sched/core] sched/core: Remove redundant 'preempt' param from sched_class->yield_to_task()
The following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 0900acf2d8273f79432a4ded122ad5a265e85783 Gitweb: https://git.kernel.org/tip/0900acf2d8273f79432a4ded122ad5a265e85783 Author: Dietmar Eggemann <[email protected]> AuthorDate: Wed, 03 Jun 2020 10:03:02 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 15 Jun 2020 14:10:01 +02:00
sched/core: Remove redundant 'preempt' param from sched_class->yield_to_task()
Commit 6d1cafd8b56e ("sched: Resched proper CPU on yield_to()") moved the code to resched the CPU from yield_to_task_fair() to yield_to() making the preempt parameter in sched_class->yield_to_task() unnecessary. Remove it. No other sched_class implements yield_to_task().
--- kernel/sched/core.c | 2 +- kernel/sched/fair.c | 2 +- kernel/sched/sched.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
kernel/sched/core.c +1 -1
@@ -5810,7 +5810,7 @@ again:if (task_running (p_rq, p) || p->state) goto out_unlock; - yielded = curr->sched_class->yield_to_task (rq, p, preempt); + yielded = curr->sched_class->yield_to_task (rq, p);if (yielded) {schedstat_inc (rq->yld_count);/*
kernel/sched/fair.c +1 -1
@@ -7157,7 +7157,7 @@ static void yield_task_fair(struct rq *rq)set_skip_buddy (se); } -static bool yield_to_task_fair (struct rq *rq,struct task_struct *p,bool preempt) +static bool yield_to_task_fair (struct rq *rq,struct task_struct *p) {struct sched_entity *se = &p->se;
kernel/sched/sched.h +1 -1
@@ -1748,7 +1748,7 @@ struct sched_class {void (*enqueue_task) (struct rq *rq,struct task_struct *p,int flags);void (*dequeue_task) (struct rq *rq,struct task_struct *p,int flags);void (*yield_task) (struct rq *rq); -bool (*yield_to_task)(struct rq *rq,struct task_struct *p,bool preempt); +bool (*yield_to_task)(struct rq *rq,struct task_struct *p);void (*check_preempt_curr)(struct rq *rq,struct task_struct *p,int flags);
Dietmar Eggemann
reviewerPATCH 3/4 sched/idle,stop: Remove .get_rr_interval from sched_class
In reply to Dietmar EggemannThe idle task and stop task sched_classes return 0 in this function.
The single call site in sched_rr_get_interval() calls p->sched_class->get_rr_interval() only conditional in case it is defined. Otherwise time_slice=0 will be used.
The deadline sched class does not define it. Commit a57beec5d427 ("sched: Make sched_class::get_rr_interval() optional") introduced the default time-slice=0 for sched classes which do not provide this function.
So .get_rr_interval for idle and stop sched_class can be removed to shrink the code a little.
--- kernel/sched/idle.c | 7 ------- kernel/sched/stop_task.c | 8 -------- 2 files changed, 15 deletions(-)
kernel/sched/idle.c +0 -7
@@ -442,11 +442,6 @@ prio_changed_idle(struct rq *rq, struct task_struct *p, int oldprio)BUG (); } -static unsigned int get_rr_interval_idle (struct rq *rq,struct task_struct *task) -{ -return 0 ; -} -static void update_curr_idle (struct rq *rq) { }
@@ -475,8 +470,6 @@ const struct sched_class idle_sched_class = { .task_tick = task_tick_idle, - .get_rr_interval = get_rr_interval_idle, - .prio_changed = prio_changed_idle, .switched_to = switched_to_idle, .update_curr = update_curr_idle,
kernel/sched/stop_task.c +0 -8
@@ -102,12 +102,6 @@ prio_changed_stop(struct rq *rq, struct task_struct *p, int oldprio)BUG ();/* how!?, what priority? */ } -static unsigned int -get_rr_interval_stop (struct rq *rq,struct task_struct *task) -{ -return 0 ; -} -static void update_curr_stop (struct rq *rq) { }
@@ -136,8 +130,6 @@ const struct sched_class stop_sched_class = { .task_tick = task_tick_stop, - .get_rr_interval = get_rr_interval_stop, - .prio_changed = prio_changed_stop, .switched_to = switched_to_stop, .update_curr = update_curr_stop,
Signature · 1 line
2.17.1
[tip: sched/core] sched/idle,stop: Remove .get_rr_interval from sched_class
The following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: e3e76a6a04114ec95b0969cd026e8904c67b431b Gitweb: https://git.kernel.org/tip/e3e76a6a04114ec95b0969cd026e8904c67b431b Author: Dietmar Eggemann <[email protected]> AuthorDate: Wed, 03 Jun 2020 10:03:03 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 15 Jun 2020 14:10:01 +02:00
sched/idle,stop: Remove .get_rr_interval from sched_class
The idle task and stop task sched_classes return 0 in this function.
The single call site in sched_rr_get_interval() calls p->sched_class->get_rr_interval() only conditional in case it is defined. Otherwise time_slice=0 will be used.
The deadline sched class does not define it. Commit a57beec5d427 ("sched: Make sched_class::get_rr_interval() optional") introduced the default time-slice=0 for sched classes which do not provide this function.
So .get_rr_interval for idle and stop sched_class can be removed to shrink the code a little.
--- kernel/sched/idle.c | 7 ------- kernel/sched/stop_task.c | 8 -------- 2 files changed, 15 deletions(-)
kernel/sched/idle.c +0 -7
@@ -446,11 +446,6 @@ prio_changed_idle(struct rq *rq, struct task_struct *p, int oldprio)BUG (); } -static unsigned int get_rr_interval_idle (struct rq *rq,struct task_struct *task) -{ -return 0 ; -} -static void update_curr_idle (struct rq *rq) { }
@@ -479,8 +474,6 @@ const struct sched_class idle_sched_class = { .task_tick = task_tick_idle, - .get_rr_interval = get_rr_interval_idle, - .prio_changed = prio_changed_idle, .switched_to = switched_to_idle, .update_curr = update_curr_idle,
kernel/sched/stop_task.c +0 -8
@@ -102,12 +102,6 @@ prio_changed_stop(struct rq *rq, struct task_struct *p, int oldprio)BUG ();/* how!?, what priority? */ } -static unsigned int -get_rr_interval_stop (struct rq *rq,struct task_struct *task) -{ -return 0 ; -} -static void update_curr_stop (struct rq *rq) { }
@@ -136,8 +130,6 @@ const struct sched_class stop_sched_class = { .task_tick = task_tick_stop, - .get_rr_interval = get_rr_interval_stop, - .prio_changed = prio_changed_stop, .switched_to = switched_to_stop, .update_curr = update_curr_stop,
Dietmar Eggemann
reviewerPATCH 4/4 sched/fair: Remove unused 'sd' parameter from scale_rt_capacity()
In reply to Dietmar EggemannSince commit 8ec59c0f5f49 ("sched/topology: Remove unused 'sd' parameter from arch_scale_cpu_capacity()") it is no longer needed.
--- kernel/sched/fair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +2 -2
@@ -8039,7 +8039,7 @@ static inline void init_sd_lb_stats(struct sd_lb_stats *sds) }; } -static unsigned long scale_rt_capacity (struct sched_domain *sd,int cpu) +static unsigned long scale_rt_capacity (int cpu) {struct rq *rq =cpu_rq (cpu);unsigned long max =arch_scale_cpu_capacity (cpu);
@@ -8071,7 +8071,7 @@ static unsigned long scale_rt_capacity(struct sched_domain *sd, int cpu)static void update_cpu_capacity (struct sched_domain *sd,int cpu) { -unsigned long capacity =scale_rt_capacity (sd, cpu); +unsigned long capacity =scale_rt_capacity (cpu);struct sched_group *sdg = sd->groups;cpu_rq (cpu)->cpu_capacity_orig =arch_scale_cpu_capacity (cpu);
Signature · 1 line
2.17.1
Re: [PATCH 4/4] sched/fair: Remove unused 'sd' parameter from scale_rt_capacity()
Quoted 9 lines · Dietmar Eggemann
Since commit
8ec59c0f5f49("sched/topology: Remove unused 'sd' parameter fromarch_scale_cpu_capacity()") it is no longer needed.Signed-off-by Dietmar Eggemann <[email protected]>--- kernel/sched/fair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 25 lines
kernel/sched/fair.c +2
-3@@ -8039,7 +8039,7 @@ static inline void init_sd_lb_stats(struct sd_lb_stats *sds) }; } -static unsigned long scale_rt_capacity (struct sched_domain *sd,int cpu) +static unsigned long scale_rt_capacity (int cpu) {struct rq *rq =cpu_rq (cpu);unsigned long max =arch_scale_cpu_capacity (cpu);@@ -8071,7 +8071,7 @@ static unsigned long scale_rt_capacity(struct sched_domain *sd, int cpu)static void update_cpu_capacity (struct sched_domain *sd,int cpu) { -unsigned long capacity =scale_rt_capacity (sd, cpu); +unsigned long capacity =scale_rt_capacity (cpu);struct sched_group *sdg = sd->groups;cpu_rq (cpu)->cpu_capacity_orig =arch_scale_cpu_capacity (cpu); --2.17.1
[tip: sched/core] sched/fair: Remove unused 'sd' parameter from scale_rt_capacity()
In reply to Dietmar EggemannThe following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 1ca2034ed798aea72a68d3904bd39a6cbfbdf405 Gitweb: https://git.kernel.org/tip/1ca2034ed798aea72a68d3904bd39a6cbfbdf405 Author: Dietmar Eggemann <[email protected]> AuthorDate: Wed, 03 Jun 2020 10:03:04 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 15 Jun 2020 14:10:01 +02:00
sched/fair: Remove unused 'sd' parameter from scale_rt_capacity()
Since commit 8ec59c0f5f49 ("sched/topology: Remove unused 'sd' parameter from arch_scale_cpu_capacity()") it is no longer needed.
--- kernel/sched/fair.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +2 -2
@@ -8038,7 +8038,7 @@ static inline void init_sd_lb_stats(struct sd_lb_stats *sds) }; } -static unsigned long scale_rt_capacity (struct sched_domain *sd,int cpu) +static unsigned long scale_rt_capacity (int cpu) {struct rq *rq =cpu_rq (cpu);unsigned long max =arch_scale_cpu_capacity (cpu);
@@ -8070,7 +8070,7 @@ static unsigned long scale_rt_capacity(struct sched_domain *sd, int cpu)static void update_cpu_capacity (struct sched_domain *sd,int cpu) { -unsigned long capacity =scale_rt_capacity (sd, cpu); +unsigned long capacity =scale_rt_capacity (cpu);struct sched_group *sdg = sd->groups;cpu_rq (cpu)->cpu_capacity_orig =arch_scale_cpu_capacity (cpu);
Peter Zijlstra
maintainerQuoted 9 lines · Dietmar Eggemann
Remove redundant functions, parameters and macros from the task scheduler code.
Dietmar Eggemann (4):
sched/pelt: Remove redundantcap_scale()definition sched/core: Remove redundant 'preempt' param fromsched_class->yield_to_task()sched/idle,stop: Remove .get_rr_interval from
sched_classsched/fair: Remove unused 'sd' parameter fromscale_rt_capacity()
Thanks!