All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Clean up the process of scanning the CPU for some functions
@ 2022-10-26  6:42 Hao Jia
  2022-10-26  6:42 ` [PATCH v2 1/2] sched/numa: Stop an exhastive search if an idle core is found Hao Jia
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Hao Jia @ 2022-10-26  6:42 UTC (permalink / raw)
  To: mingo, peterz, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
	mgorman
  Cc: linux-kernel, Hao Jia

These two patches clean up the process of scanning the CPU.

Patch 1 stops checking for a new idle core in time
if an idle core has already been found.

Patch 2 tries to minimize false attempts by adjusting the order
of scanning CPU.

v1->v2:
    - Simplified patch1 code and add
      "Acked-by: Mel Gorman <mgorman@techsingularity.net>"
    - Modify commit description to make it more clear

[v1] https://lore.kernel.org/all/20221021061558.34767-1-jiahao.os@bytedance.com

Hao Jia (2):
  sched/numa: Stop an exhastive search if an idle core is found
  sched/core: Adjusting the order of scanning CPU

 kernel/sched/core.c | 2 +-
 kernel/sched/fair.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.37.0


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

* [PATCH v2 1/2] sched/numa: Stop an exhastive search if an idle core is found
  2022-10-26  6:42 [PATCH v2 0/2] Clean up the process of scanning the CPU for some functions Hao Jia
@ 2022-10-26  6:42 ` Hao Jia
  2022-10-26  6:43 ` [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU Hao Jia
  2022-11-08  3:01 ` [PATCH v2 0/2] Clean up the process of scanning the CPU for some functions Hao Jia
  2 siblings, 0 replies; 8+ messages in thread
From: Hao Jia @ 2022-10-26  6:42 UTC (permalink / raw)
  To: mingo, peterz, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
	mgorman
  Cc: linux-kernel, Hao Jia

In update_numa_stats() we try to find an idle cpu on the NUMA node,
preferably an idle core. we can stop looking for the next idle core
or idle cpu after finding an idle core. But we can't stop the
whole loop of scanning the CPU, because we need to calculate
approximate NUMA stats at a point in time. For example,
the src and dst nr_running is needed by task_numa_find_cpu().

Signed-off-by: Hao Jia <jiahao.os@bytedance.com>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e4a0b8bd941c..dfcb620bfe50 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1792,7 +1792,7 @@ static void update_numa_stats(struct task_numa_env *env,
 		ns->nr_running += rq->cfs.h_nr_running;
 		ns->compute_capacity += capacity_of(cpu);
 
-		if (find_idle && !rq->nr_running && idle_cpu(cpu)) {
+		if (find_idle && idle_core < 0 && !rq->nr_running && idle_cpu(cpu)) {
 			if (READ_ONCE(rq->numa_migrate_on) ||
 			    !cpumask_test_cpu(cpu, env->p->cpus_ptr))
 				continue;
-- 
2.37.0


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

* [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU
  2022-10-26  6:42 [PATCH v2 0/2] Clean up the process of scanning the CPU for some functions Hao Jia
  2022-10-26  6:42 ` [PATCH v2 1/2] sched/numa: Stop an exhastive search if an idle core is found Hao Jia
@ 2022-10-26  6:43 ` Hao Jia
  2022-11-14 12:15   ` Mel Gorman
  2022-11-08  3:01 ` [PATCH v2 0/2] Clean up the process of scanning the CPU for some functions Hao Jia
  2 siblings, 1 reply; 8+ messages in thread
From: Hao Jia @ 2022-10-26  6:43 UTC (permalink / raw)
  To: mingo, peterz, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
	mgorman
  Cc: linux-kernel, Hao Jia

When select_idle_capacity() starts scanning for an idle CPU, it starts
with target CPU that has already been checked in select_idle_sibling().
So we start checking from the next CPU and try the target CPU at the end.
Similarly for task_numa_assign(), we have just checked numa_migrate_on
of dst_cpu, so start from the next CPU. This also works for
steal_cookie_task(), the first scan must fail and start directly
from the next one.

Signed-off-by: Hao Jia <jiahao.os@bytedance.com>
---
 kernel/sched/core.c | 2 +-
 kernel/sched/fair.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index cb2aa2b54c7a..5c3c539e1712 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6154,7 +6154,7 @@ static bool steal_cookie_task(int cpu, struct sched_domain *sd)
 {
 	int i;
 
-	for_each_cpu_wrap(i, sched_domain_span(sd), cpu) {
+	for_each_cpu_wrap(i, sched_domain_span(sd), cpu + 1) {
 		if (i == cpu)
 			continue;
 
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index dfcb620bfe50..ba91d4478260 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1824,7 +1824,7 @@ static void task_numa_assign(struct task_numa_env *env,
 		int start = env->dst_cpu;
 
 		/* Find alternative idle CPU. */
-		for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start) {
+		for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start + 1) {
 			if (cpu == env->best_cpu || !idle_cpu(cpu) ||
 			    !cpumask_test_cpu(cpu, env->p->cpus_ptr)) {
 				continue;
@@ -6663,7 +6663,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
 
 	task_util = uclamp_task_util(p);
 
-	for_each_cpu_wrap(cpu, cpus, target) {
+	for_each_cpu_wrap(cpu, cpus, target + 1) {
 		unsigned long cpu_cap = capacity_of(cpu);
 
 		if (!available_idle_cpu(cpu) && !sched_idle_cpu(cpu))
-- 
2.37.0


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

* Re: [PATCH v2 0/2] Clean up the process of scanning the CPU for some functions
  2022-10-26  6:42 [PATCH v2 0/2] Clean up the process of scanning the CPU for some functions Hao Jia
  2022-10-26  6:42 ` [PATCH v2 1/2] sched/numa: Stop an exhastive search if an idle core is found Hao Jia
  2022-10-26  6:43 ` [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU Hao Jia
@ 2022-11-08  3:01 ` Hao Jia
  2 siblings, 0 replies; 8+ messages in thread
From: Hao Jia @ 2022-11-08  3:01 UTC (permalink / raw)
  To: mingo, peterz, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
	mgorman
  Cc: linux-kernel


Friendly ping...

On 2022/10/26 Hao Jia wrote:
> These two patches clean up the process of scanning the CPU.
> 
> Patch 1 stops checking for a new idle core in time
> if an idle core has already been found.
> 
> Patch 2 tries to minimize false attempts by adjusting the order
> of scanning CPU.
> 
> v1->v2:
>      - Simplified patch1 code and add
>        "Acked-by: Mel Gorman <mgorman@techsingularity.net>"
>      - Modify commit description to make it more clear
> 
> [v1] https://lore.kernel.org/all/20221021061558.34767-1-jiahao.os@bytedance.com
> 
> Hao Jia (2):
>    sched/numa: Stop an exhastive search if an idle core is found
>    sched/core: Adjusting the order of scanning CPU
> 
>   kernel/sched/core.c | 2 +-
>   kernel/sched/fair.c | 6 +++---
>   2 files changed, 4 insertions(+), 4 deletions(-)
> 

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

* Re: [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU
  2022-10-26  6:43 ` [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU Hao Jia
@ 2022-11-14 12:15   ` Mel Gorman
  2022-11-16  8:48     ` [External] " Hao Jia
  2022-11-30  6:35     ` Hao Jia
  0 siblings, 2 replies; 8+ messages in thread
From: Mel Gorman @ 2022-11-14 12:15 UTC (permalink / raw)
  To: Hao Jia
  Cc: mingo, peterz, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
	linux-kernel

On Wed, Oct 26, 2022 at 02:43:00PM +0800, Hao Jia wrote:
> When select_idle_capacity() starts scanning for an idle CPU, it starts
> with target CPU that has already been checked in select_idle_sibling().
> So we start checking from the next CPU and try the target CPU at the end.
> Similarly for task_numa_assign(), we have just checked numa_migrate_on
> of dst_cpu, so start from the next CPU. This also works for
> steal_cookie_task(), the first scan must fail and start directly
> from the next one.
> 
> Signed-off-by: Hao Jia <jiahao.os@bytedance.com>

Test results in general look ok so

Acked-by: Mel Gorman <mgorman@techsingularity.net>

-- 
Mel Gorman
SUSE Labs

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

* Re: [External] Re: [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU
  2022-11-14 12:15   ` Mel Gorman
@ 2022-11-16  8:48     ` Hao Jia
  2022-11-30  6:35     ` Hao Jia
  1 sibling, 0 replies; 8+ messages in thread
From: Hao Jia @ 2022-11-16  8:48 UTC (permalink / raw)
  To: Mel Gorman
  Cc: mingo, peterz, mingo, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
	linux-kernel



On 2022/11/14 Mel Gorman wrote:
> On Wed, Oct 26, 2022 at 02:43:00PM +0800, Hao Jia wrote:
>> When select_idle_capacity() starts scanning for an idle CPU, it starts
>> with target CPU that has already been checked in select_idle_sibling().
>> So we start checking from the next CPU and try the target CPU at the end.
>> Similarly for task_numa_assign(), we have just checked numa_migrate_on
>> of dst_cpu, so start from the next CPU. This also works for
>> steal_cookie_task(), the first scan must fail and start directly
>> from the next one.
>>
>> Signed-off-by: Hao Jia <jiahao.os@bytedance.com>
> 
> Test results in general look ok so
> 
> Acked-by: Mel Gorman <mgorman@techsingularity.net>
> 

Thanks for your review and feedback.

Thanks,
Hao

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

* Re: [External] Re: [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU
  2022-11-14 12:15   ` Mel Gorman
  2022-11-16  8:48     ` [External] " Hao Jia
@ 2022-11-30  6:35     ` Hao Jia
  2022-11-30  7:59       ` Vincent Guittot
  1 sibling, 1 reply; 8+ messages in thread
From: Hao Jia @ 2022-11-30  6:35 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, mingo, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, bristot, vschneid, linux-kernel,
	Mel Gorman



On 2022/11/14 Mel Gorman wrote:
> On Wed, Oct 26, 2022 at 02:43:00PM +0800, Hao Jia wrote:
>> When select_idle_capacity() starts scanning for an idle CPU, it starts
>> with target CPU that has already been checked in select_idle_sibling().
>> So we start checking from the next CPU and try the target CPU at the end.
>> Similarly for task_numa_assign(), we have just checked numa_migrate_on
>> of dst_cpu, so start from the next CPU. This also works for
>> steal_cookie_task(), the first scan must fail and start directly
>> from the next one.
>>
>> Signed-off-by: Hao Jia <jiahao.os@bytedance.com>
> 
> Test results in general look ok so
> 
> Acked-by: Mel Gorman <mgorman@techsingularity.net>
> 

Hi, Peter
These two patches have been Acked-by Mel Gorman.
If you have time, please review these two patches.

Thanks,
Hao

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

* Re: [External] Re: [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU
  2022-11-30  6:35     ` Hao Jia
@ 2022-11-30  7:59       ` Vincent Guittot
  0 siblings, 0 replies; 8+ messages in thread
From: Vincent Guittot @ 2022-11-30  7:59 UTC (permalink / raw)
  To: Hao Jia
  Cc: Peter Zijlstra, mingo, mingo, juri.lelli, dietmar.eggemann,
	rostedt, bsegall, mgorman, bristot, vschneid, linux-kernel,
	Mel Gorman

On Wed, 30 Nov 2022 at 07:35, Hao Jia <jiahao.os@bytedance.com> wrote:
>
>
>
> On 2022/11/14 Mel Gorman wrote:
> > On Wed, Oct 26, 2022 at 02:43:00PM +0800, Hao Jia wrote:
> >> When select_idle_capacity() starts scanning for an idle CPU, it starts
> >> with target CPU that has already been checked in select_idle_sibling().
> >> So we start checking from the next CPU and try the target CPU at the end.
> >> Similarly for task_numa_assign(), we have just checked numa_migrate_on
> >> of dst_cpu, so start from the next CPU. This also works for
> >> steal_cookie_task(), the first scan must fail and start directly
> >> from the next one.
> >>
> >> Signed-off-by: Hao Jia <jiahao.os@bytedance.com>
> >
> > Test results in general look ok so
> >
> > Acked-by: Mel Gorman <mgorman@techsingularity.net>

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

> >
>
> Hi, Peter
> These two patches have been Acked-by Mel Gorman.
> If you have time, please review these two patches.
>
> Thanks,
> Hao

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

end of thread, other threads:[~2022-11-30  8:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26  6:42 [PATCH v2 0/2] Clean up the process of scanning the CPU for some functions Hao Jia
2022-10-26  6:42 ` [PATCH v2 1/2] sched/numa: Stop an exhastive search if an idle core is found Hao Jia
2022-10-26  6:43 ` [PATCH v2 2/2] sched/core: Adjusting the order of scanning CPU Hao Jia
2022-11-14 12:15   ` Mel Gorman
2022-11-16  8:48     ` [External] " Hao Jia
2022-11-30  6:35     ` Hao Jia
2022-11-30  7:59       ` Vincent Guittot
2022-11-08  3:01 ` [PATCH v2 0/2] Clean up the process of scanning the CPU for some functions Hao Jia

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.