Skip to contentSkip to conversation

xen/sched: fix onlining cpu with core scheduling active

PATCH In review Juergen Gross 2 participants 5 messages Mar 3, 2020 – Mar 10, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/sched: fix onlining cpu with core scheduling active

When onlining a cpu cpupool_cpu_add() checks whether all siblings of the new cpu are free in order to decide whether to add it to cpupool0. In case the added cpu is not the last sibling to be onlined this test is wrong as it only checks for all online siblings to be free. The test should include the check for the number of siblings having reached the scheduling granularity of cpupool0, too.

---
 xen/common/sched/cpupool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/sched/cpupool.c +2 -1
index 9f70c7ec17..4a67df8584 100644
@@ -616,7 +616,8 @@ static int cpupool_cpu_add(unsigned int cpu)
     get_sched_res(cpu)->cpupool = NULL;
 
     cpus = sched_get_opt_cpumask(cpupool0->gran, cpu);
-    if ( cpumask_subset(cpus, &cpupool_free_cpus) )
+    if ( cpumask_subset(cpus, &cpupool_free_cpus) &&
+         cpumask_weight(cpus) >= cpupool_get_granularity(cpupool0) )
         ret = cpupool_assign_cpu_locked(cpupool0, cpu);
 
     rcu_read_unlock(&sched_res_rculock);
Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

xen/common/sched/cpupool.c static int cpupool_cpu_add(unsigned int cpu) · line 620

Quoted 9 lines · Juergen Gross
xen/common/sched/cpupool.c +2 -1
@@ -616,7 +616,8 @@ static int cpupool_cpu_add(unsigned int cpu)
     get_sched_res(cpu)->cpupool = NULL;
 
     cpus = sched_get_opt_cpumask(cpupool0->gran, cpu);
-    if ( cpumask_subset(cpus, &cpupool_free_cpus) )
+    if ( cpumask_subset(cpus, &cpupool_free_cpus) &&
+         cpumask_weight(cpus) >= cpupool_get_granularity(cpupool0) )

Why >= , not == ? And is the other part of the condition needed? Isn't this rather a condition that could be ASSERT()ed, as CPUs shouldn't move out of the "free" set before reaching the granularity?

Jan

xen/common/sched/cpupool.c static int cpupool_cpu_add(unsigned int cpu) · line 623

Quoted 4 lines
xen/common/sched/cpupool.c +0 -0
         ret = cpupool_assign_cpu_locked(cpupool0, cpu);
 
     rcu_read_unlock(&sched_res_rculock);

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Juergen Gross
xen/common/sched/cpupool.c +0 -0
@@ -616,7 +616,8 @@ static int cpupool_cpu_add(unsigned int cpu)
      get_sched_res(cpu)->cpupool = NULL;
 
Quoted 6 lines

xen/common/sched/cpupool.c static int cpupool_cpu_add(unsigned int cpu) · line 620

Quoted 4 lines
xen/common/sched/cpupool.c +2 -1
      cpus = sched_get_opt_cpumask(cpupool0->gran, cpu);
-    if ( cpumask_subset(cpus, &cpupool_free_cpus) )
+    if ( cpumask_subset(cpus, &cpupool_free_cpus) &&
+         cpumask_weight(cpus) >= cpupool_get_granularity(cpupool0) )

Why >= , not == ? And is the other part of the condition needed?

I can switch to ==.

Quoted 3 lines

Isn't this rather a condition that could be ASSERT()ed, as CPUs shouldn't move out of the "free" set before reaching the granularity?

Probably, yes. I'll give it some testing and change it in the case of (expected) success.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 13 lines · Jürgen Groß
Quoted 11 lines · Jan Beulich

xen/common/sched/cpupool.c static int cpupool_cpu_add(unsigned int cpu) · line 619

Quoted 8 lines · Juergen Gross
xen/common/sched/cpupool.c +2 -1
@@ -616,7 +616,8 @@ static int cpupool_cpu_add(unsigned int cpu)
       get_sched_res(cpu)->cpupool = NULL;
       cpus = sched_get_opt_cpumask(cpupool0->gran, cpu);
-    if ( cpumask_subset(cpus, &cpupool_free_cpus) )
+    if ( cpumask_subset(cpus, &cpupool_free_cpus) &&
+         cpumask_weight(cpus) >= cpupool_get_granularity(cpupool0) )

Why >= , not == ? And is the other part of the condition needed?

Quoted 8 lines

I can switch to ==.

Quoted 3 lines

Isn't this rather a condition that could be ASSERT()ed, as CPUs shouldn't move out of the "free" set before reaching the granularity?

Probably, yes. I'll give it some testing and change it in the case of (expected) success.

Thinking more about it I'm inclined to keep testing both conditions. In case we are supporting cpupools with different granularities we'll need to test for all cpus to be free in case the other sibling has been moved to a cpupool with gran=1 already.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 20 lines · Jürgen Groß
Quoted 19 lines · Jürgen Groß
Quoted 11 lines · Jan Beulich

xen/common/sched/cpupool.c static int cpupool_cpu_add(unsigned int cpu) · line 619

Quoted 8 lines · Juergen Gross
xen/common/sched/cpupool.c +2 -1
@@ -616,7 +616,8 @@ static int cpupool_cpu_add(unsigned int cpu)
       get_sched_res(cpu)->cpupool = NULL;
       cpus = sched_get_opt_cpumask(cpupool0->gran, cpu);
-    if ( cpumask_subset(cpus, &cpupool_free_cpus) )
+    if ( cpumask_subset(cpus, &cpupool_free_cpus) &&
+         cpumask_weight(cpus) >= cpupool_get_granularity(cpupool0) )

Why >= , not == ? And is the other part of the condition needed?

I can switch to ==.

Quoted 3 lines

Isn't this rather a condition that could be ASSERT()ed, as CPUs shouldn't move out of the "free" set before reaching the granularity?

Quoted 7 lines
Quoted 2 lines

Probably, yes. I'll give it some testing and change it in the case of (expected) success.

Thinking more about it I'm inclined to keep testing both conditions. In case we are supporting cpupools with different granularities we'll need to test for all cpus to be free in case the other sibling has been moved to a cpupool with gran=1 already.

Ah, yes, makes sense.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel