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 <[email protected]>"
- Modify commit description to make it more clear
[v1] https://lore.kernel.org/all/[email protected]
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
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 <[email protected]>
Acked-by: Mel Gorman <[email protected]>
---
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
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 <[email protected]>
---
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
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 <[email protected]>"
> - Modify commit description to make it more clear
>
> [v1] https://lore.kernel.org/all/[email protected]
>
> 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(-)
>
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 <[email protected]>
Test results in general look ok so
Acked-by: Mel Gorman <[email protected]>
--
Mel Gorman
SUSE Labs
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 <[email protected]>
>
> Test results in general look ok so
>
> Acked-by: Mel Gorman <[email protected]>
>
Thanks for your review and feedback.
Thanks,
Hao
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 <[email protected]>
>
> Test results in general look ok so
>
> Acked-by: Mel Gorman <[email protected]>
>
Hi, Peter
These two patches have been Acked-by Mel Gorman.
If you have time, please review these two patches.
Thanks,
Hao
On Wed, 30 Nov 2022 at 07:35, Hao Jia <[email protected]> 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 <[email protected]>
> >
> > Test results in general look ok so
> >
> > Acked-by: Mel Gorman <[email protected]>
Reviewed-by: Vincent Guittot <[email protected]>
> >
>
> Hi, Peter
> These two patches have been Acked-by Mel Gorman.
> If you have time, please review these two patches.
>
> Thanks,
> Hao