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(-)
--
2.17.1
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.
Signed-off-by: Dietmar Eggemann <[email protected]>
---
kernel/sched/idle.c | 7 -------
kernel/sched/stop_task.c | 8 --------
2 files changed, 15 deletions(-)
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index b743bf38f08f..70ea8565ae48 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -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,
diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
index 4c9e9975684f..3e50a6a8f1e5 100644
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -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,
--
2.17.1
Since commit 8ec59c0f5f49 ("sched/topology: Remove unused 'sd'
parameter from arch_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(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 5c4a559d0dae..7158d4e3c855 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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
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.
Signed-off-by: Dietmar Eggemann <[email protected]>
---
kernel/sched/pelt.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
index b4b1ff96642f..dea5567e4f72 100644
--- a/kernel/sched/pelt.c
+++ b/kernel/sched/pelt.c
@@ -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
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().
Signed-off-by: Dietmar Eggemann <[email protected]>
---
kernel/sched/core.c | 2 +-
kernel/sched/fair.c | 2 +-
kernel/sched/sched.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 95e457d4ed1c..687b16047f92 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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);
/*
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index dda9b194d225..5c4a559d0dae 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 4b32cff0dcbe..12a0d0c7c164 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -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);
--
2.17.1
On Wed, Jun 03, 2020 at 10:03:00AM +0200, Dietmar Eggemann wrote:
> 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()
Thanks!
On Wed, 3 Jun 2020 at 10:03, Dietmar Eggemann <[email protected]> wrote:
>
> Since commit 8ec59c0f5f49 ("sched/topology: Remove unused 'sd'
> parameter from arch_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(-)
>
Reviewed-by: Vincent Guittot <[email protected]>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 5c4a559d0dae..7158d4e3c855 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -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
>
On Wed, 3 Jun 2020 at 10:03, Dietmar Eggemann <[email protected]> wrote:
>
> 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.
>
> Signed-off-by: Dietmar Eggemann <[email protected]>
Reviewed-by: Vincent Guittot <[email protected]>
> ---
> kernel/sched/pelt.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
> index b4b1ff96642f..dea5567e4f72 100644
> --- a/kernel/sched/pelt.c
> +++ b/kernel/sched/pelt.c
> @@ -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
>
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.
Signed-off-by: Dietmar Eggemann <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Vincent Guittot <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
kernel/sched/fair.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6a4dab2..69da576 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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);
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.
Signed-off-by: Dietmar Eggemann <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
kernel/sched/idle.c | 7 -------
kernel/sched/stop_task.c | 8 --------
2 files changed, 15 deletions(-)
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index 05deb81..8d75ca2 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -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,
diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
index 4c9e997..3e50a6a 100644
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -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,
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().
Signed-off-by: Dietmar Eggemann <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
kernel/sched/core.c | 2 +-
kernel/sched/fair.c | 2 +-
kernel/sched/sched.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8f36032..9c89b0e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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);
/*
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index cbcb2f7..6a4dab2 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 1d4e94c..8d5d068 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -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);
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.
Signed-off-by: Dietmar Eggemann <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Vincent Guittot <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
kernel/sched/pelt.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
index b4b1ff9..dea5567 100644
--- a/kernel/sched/pelt.c
+++ b/kernel/sched/pelt.c
@@ -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