All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/1] sched/fair: feec() improvement
@ 2022-10-06  8:10 Pierre Gondois
  2022-10-06  8:10 ` [PATCH v2 1/1] sched/fair: Check if prev_cpu has highest spare cap in feec() Pierre Gondois
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Gondois @ 2022-10-06  8:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pierre Gondois, Ingo Molnar, Peter Zijlstra, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, Daniel Bristot de Oliveira, Valentin Schneider

v2:
- Dropped 'sched/fair: Use IRQ scaling for all sched classes'
- Added Reviewed-by from Dietmar.

This patch-set aims to improve find_energy_efficient_cpu()
by removing max_spare_cap_cpu from the candidate CPUs if
prev_cpu is already the CPU with the maximum spared capacity.

Pierre Gondois (1):
  sched/fair: Check if prev_cpu has highest spare cap in feec()

 kernel/sched/fair.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/1] sched/fair: Check if prev_cpu has highest spare cap in feec()
  2022-10-06  8:10 [PATCH v2 0/1] sched/fair: feec() improvement Pierre Gondois
@ 2022-10-06  8:10 ` Pierre Gondois
  2022-10-06  9:56   ` Vincent Guittot
  2022-10-28  6:42   ` [tip: sched/core] " tip-bot2 for Pierre Gondois
  0 siblings, 2 replies; 4+ messages in thread
From: Pierre Gondois @ 2022-10-06  8:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pierre Gondois, Dietmar Eggemann, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Steven Rostedt, Ben Segall,
	Mel Gorman, Daniel Bristot de Oliveira, Valentin Schneider

When evaluating the CPU candidates in the perf domain (pd) containing
the previously used CPU (prev_cpu), find_energy_efficient_cpu()
evaluates the energy of the pd:
- without the task (base_energy)
- with the task placed on prev_cpu (if the task fits)
- with the task placed on the CPU with the highest spare capacity,
  prev_cpu being excluded from this set

If prev_cpu is already the CPU with the highest spare capacity,
max_spare_cap_cpu will be the CPU with the second highest spare
capacity.

On an Arm64 Juno-r2, with a workload of 10 tasks at a 10% duty cycle,
when prev_cpu and max_spare_cap_cpu are both valid candidates,
prev_spare_cap > max_spare_cap at ~82%.
Thus the energy of the pd when placing the task on max_spare_cap_cpu
is computed with no possible positive outcome 82% most of the time.

Do not consider max_spare_cap_cpu as a valid candidate if
prev_spare_cap > max_spare_cap.

Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 kernel/sched/fair.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 914096c5b1ae..bcae7bdd5582 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6900,7 +6900,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 	for (; pd; pd = pd->next) {
 		unsigned long cpu_cap, cpu_thermal_cap, util;
 		unsigned long cur_delta, max_spare_cap = 0;
-		bool compute_prev_delta = false;
+		unsigned long prev_spare_cap = 0;
 		int max_spare_cap_cpu = -1;
 		unsigned long base_energy;
 
@@ -6944,18 +6944,19 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 
 			if (cpu == prev_cpu) {
 				/* Always use prev_cpu as a candidate. */
-				compute_prev_delta = true;
+				prev_spare_cap = cpu_cap;
 			} else if (cpu_cap > max_spare_cap) {
 				/*
 				 * Find the CPU with the maximum spare capacity
-				 * in the performance domain.
+				 * among the remaining CPUs in the performance
+				 * domain.
 				 */
 				max_spare_cap = cpu_cap;
 				max_spare_cap_cpu = cpu;
 			}
 		}
 
-		if (max_spare_cap_cpu < 0 && !compute_prev_delta)
+		if (max_spare_cap_cpu < 0 && prev_spare_cap == 0)
 			continue;
 
 		eenv_pd_busy_time(&eenv, cpus, p);
@@ -6963,7 +6964,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 		base_energy = compute_energy(&eenv, pd, cpus, p, -1);
 
 		/* Evaluate the energy impact of using prev_cpu. */
-		if (compute_prev_delta) {
+		if (prev_spare_cap > 0) {
 			prev_delta = compute_energy(&eenv, pd, cpus, p,
 						    prev_cpu);
 			/* CPU utilization has changed */
@@ -6974,7 +6975,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 		}
 
 		/* Evaluate the energy impact of using max_spare_cap_cpu. */
-		if (max_spare_cap_cpu >= 0) {
+		if (max_spare_cap_cpu >= 0 && max_spare_cap > prev_spare_cap) {
 			cur_delta = compute_energy(&eenv, pd, cpus, p,
 						   max_spare_cap_cpu);
 			/* CPU utilization has changed */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] sched/fair: Check if prev_cpu has highest spare cap in feec()
  2022-10-06  8:10 ` [PATCH v2 1/1] sched/fair: Check if prev_cpu has highest spare cap in feec() Pierre Gondois
@ 2022-10-06  9:56   ` Vincent Guittot
  2022-10-28  6:42   ` [tip: sched/core] " tip-bot2 for Pierre Gondois
  1 sibling, 0 replies; 4+ messages in thread
From: Vincent Guittot @ 2022-10-06  9:56 UTC (permalink / raw)
  To: Pierre Gondois
  Cc: linux-kernel, Dietmar Eggemann, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Steven Rostedt, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira, Valentin Schneider

On Thu, 6 Oct 2022 at 10:11, Pierre Gondois <pierre.gondois@arm.com> wrote:
>
> When evaluating the CPU candidates in the perf domain (pd) containing
> the previously used CPU (prev_cpu), find_energy_efficient_cpu()
> evaluates the energy of the pd:
> - without the task (base_energy)
> - with the task placed on prev_cpu (if the task fits)
> - with the task placed on the CPU with the highest spare capacity,
>   prev_cpu being excluded from this set
>
> If prev_cpu is already the CPU with the highest spare capacity,
> max_spare_cap_cpu will be the CPU with the second highest spare
> capacity.
>
> On an Arm64 Juno-r2, with a workload of 10 tasks at a 10% duty cycle,
> when prev_cpu and max_spare_cap_cpu are both valid candidates,
> prev_spare_cap > max_spare_cap at ~82%.
> Thus the energy of the pd when placing the task on max_spare_cap_cpu
> is computed with no possible positive outcome 82% most of the time.
>
> Do not consider max_spare_cap_cpu as a valid candidate if
> prev_spare_cap > max_spare_cap.
>
> Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>

nit: the reviewed tag should be after the signed-off

> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>

Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>

> ---
>  kernel/sched/fair.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 914096c5b1ae..bcae7bdd5582 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6900,7 +6900,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>         for (; pd; pd = pd->next) {
>                 unsigned long cpu_cap, cpu_thermal_cap, util;
>                 unsigned long cur_delta, max_spare_cap = 0;
> -               bool compute_prev_delta = false;
> +               unsigned long prev_spare_cap = 0;
>                 int max_spare_cap_cpu = -1;
>                 unsigned long base_energy;
>
> @@ -6944,18 +6944,19 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>
>                         if (cpu == prev_cpu) {
>                                 /* Always use prev_cpu as a candidate. */
> -                               compute_prev_delta = true;
> +                               prev_spare_cap = cpu_cap;
>                         } else if (cpu_cap > max_spare_cap) {
>                                 /*
>                                  * Find the CPU with the maximum spare capacity
> -                                * in the performance domain.
> +                                * among the remaining CPUs in the performance
> +                                * domain.
>                                  */
>                                 max_spare_cap = cpu_cap;
>                                 max_spare_cap_cpu = cpu;
>                         }
>                 }
>
> -               if (max_spare_cap_cpu < 0 && !compute_prev_delta)
> +               if (max_spare_cap_cpu < 0 && prev_spare_cap == 0)
>                         continue;
>
>                 eenv_pd_busy_time(&eenv, cpus, p);
> @@ -6963,7 +6964,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>                 base_energy = compute_energy(&eenv, pd, cpus, p, -1);
>
>                 /* Evaluate the energy impact of using prev_cpu. */
> -               if (compute_prev_delta) {
> +               if (prev_spare_cap > 0) {
>                         prev_delta = compute_energy(&eenv, pd, cpus, p,
>                                                     prev_cpu);
>                         /* CPU utilization has changed */
> @@ -6974,7 +6975,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>                 }
>
>                 /* Evaluate the energy impact of using max_spare_cap_cpu. */
> -               if (max_spare_cap_cpu >= 0) {
> +               if (max_spare_cap_cpu >= 0 && max_spare_cap > prev_spare_cap) {
>                         cur_delta = compute_energy(&eenv, pd, cpus, p,
>                                                    max_spare_cap_cpu);
>                         /* CPU utilization has changed */
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip: sched/core] sched/fair: Check if prev_cpu has highest spare cap in feec()
  2022-10-06  8:10 ` [PATCH v2 1/1] sched/fair: Check if prev_cpu has highest spare cap in feec() Pierre Gondois
  2022-10-06  9:56   ` Vincent Guittot
@ 2022-10-28  6:42   ` tip-bot2 for Pierre Gondois
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Pierre Gondois @ 2022-10-28  6:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Pierre Gondois, Peter Zijlstra (Intel),
	Dietmar Eggemann, Vincent Guittot, x86, linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     ad841e569f5c88e3332b32a000f251f33ff32187
Gitweb:        https://git.kernel.org/tip/ad841e569f5c88e3332b32a000f251f33ff32187
Author:        Pierre Gondois <pierre.gondois@arm.com>
AuthorDate:    Thu, 06 Oct 2022 10:10:52 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 27 Oct 2022 11:01:20 +02:00

sched/fair: Check if prev_cpu has highest spare cap in feec()

When evaluating the CPU candidates in the perf domain (pd) containing
the previously used CPU (prev_cpu), find_energy_efficient_cpu()
evaluates the energy of the pd:
- without the task (base_energy)
- with the task placed on prev_cpu (if the task fits)
- with the task placed on the CPU with the highest spare capacity,
  prev_cpu being excluded from this set

If prev_cpu is already the CPU with the highest spare capacity,
max_spare_cap_cpu will be the CPU with the second highest spare
capacity.

On an Arm64 Juno-r2, with a workload of 10 tasks at a 10% duty cycle,
when prev_cpu and max_spare_cap_cpu are both valid candidates,
prev_spare_cap > max_spare_cap at ~82%.
Thus the energy of the pd when placing the task on max_spare_cap_cpu
is computed with no possible positive outcome 82% most of the time.

Do not consider max_spare_cap_cpu as a valid candidate if
prev_spare_cap > max_spare_cap.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20221006081052.3862167-2-pierre.gondois@arm.com
---
 kernel/sched/fair.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 919d016..4cc56c9 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7221,7 +7221,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 		unsigned long cur_delta, max_spare_cap = 0;
 		unsigned long rq_util_min, rq_util_max;
 		unsigned long util_min, util_max;
-		bool compute_prev_delta = false;
+		unsigned long prev_spare_cap = 0;
 		int max_spare_cap_cpu = -1;
 		unsigned long base_energy;
 
@@ -7283,18 +7283,19 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 
 			if (cpu == prev_cpu) {
 				/* Always use prev_cpu as a candidate. */
-				compute_prev_delta = true;
+				prev_spare_cap = cpu_cap;
 			} else if (cpu_cap > max_spare_cap) {
 				/*
 				 * Find the CPU with the maximum spare capacity
-				 * in the performance domain.
+				 * among the remaining CPUs in the performance
+				 * domain.
 				 */
 				max_spare_cap = cpu_cap;
 				max_spare_cap_cpu = cpu;
 			}
 		}
 
-		if (max_spare_cap_cpu < 0 && !compute_prev_delta)
+		if (max_spare_cap_cpu < 0 && prev_spare_cap == 0)
 			continue;
 
 		eenv_pd_busy_time(&eenv, cpus, p);
@@ -7302,7 +7303,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 		base_energy = compute_energy(&eenv, pd, cpus, p, -1);
 
 		/* Evaluate the energy impact of using prev_cpu. */
-		if (compute_prev_delta) {
+		if (prev_spare_cap > 0) {
 			prev_delta = compute_energy(&eenv, pd, cpus, p,
 						    prev_cpu);
 			/* CPU utilization has changed */
@@ -7313,7 +7314,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 		}
 
 		/* Evaluate the energy impact of using max_spare_cap_cpu. */
-		if (max_spare_cap_cpu >= 0) {
+		if (max_spare_cap_cpu >= 0 && max_spare_cap > prev_spare_cap) {
 			cur_delta = compute_energy(&eenv, pd, cpus, p,
 						   max_spare_cap_cpu);
 			/* CPU utilization has changed */

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-28  6:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06  8:10 [PATCH v2 0/1] sched/fair: feec() improvement Pierre Gondois
2022-10-06  8:10 ` [PATCH v2 1/1] sched/fair: Check if prev_cpu has highest spare cap in feec() Pierre Gondois
2022-10-06  9:56   ` Vincent Guittot
2022-10-28  6:42   ` [tip: sched/core] " tip-bot2 for Pierre Gondois

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.