Skip to contentSkip to conversation

xen/sched: fix error path in cpupool_unassign_cpu_start()

PATCH Superseded Juergen Gross 2 participants 2 messages Mar 3, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/sched: fix error path in cpupool_unassign_cpu_start()

In case moving away all domains from the cpu to be removed is failing in cpupool_unassign_cpu_start() the error path is missing to release sched_res_rculock.

The normal exit path is releasing domlist_read_lock instead (this is currently no problem as the reference to the specific rcu lock is not used by rcu_read_unlock()).

---
 xen/common/sched/cpupool.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
xen/common/sched/cpupool.c +3 -2
index b7721b5d02..4bf3d8434d 100644
@@ -466,7 +466,7 @@ static int cpupool_unassign_cpu_start(struct cpupool *c, unsigned int cpu)
         }
         rcu_read_unlock(&domlist_read_lock);
         if ( ret )
-            goto out;
+            goto out_rcu;
     }
     cpupool_moving_cpu = cpu;
     atomic_inc(&c->refcnt);
@@ -474,7 +474,8 @@ static int cpupool_unassign_cpu_start(struct cpupool *c, unsigned int cpu)
     cpumask_andnot(c->cpu_valid, c->cpu_valid, cpus);
     cpumask_and(c->res_valid, c->cpu_valid, &sched_res_mask);
 
-    rcu_read_unlock(&domlist_read_lock);
+out_rcu:
+    rcu_read_unlock(&sched_res_rculock);
 out:
     spin_unlock(&cpupool_lock);
 
Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Juergen Gross

In case moving away all domains from the cpu to be removed is failing in cpupool_unassign_cpu_start() the error path is missing to release sched_res_rculock.

The normal exit path is releasing domlist_read_lock instead (this is currently no problem as the reference to the specific rcu lock is not used by rcu_read_unlock()).

albeit preferably with ...

Quoted 12 lines
xen/common/sched/cpupool.c +1 -1
@@ -466,7 +466,7 @@ static int cpupool_unassign_cpu_start(struct cpupool *c, unsigned int cpu)
         }
         rcu_read_unlock(&domlist_read_lock);
         if ( ret )
-            goto out;
+            goto out_rcu;
     }
     cpupool_moving_cpu = cpu;
     atomic_inc(&c->refcnt);

xen/common/sched/cpupool.c static int cpupool_unassign_cpu_start(struct cpupool *c, unsigned int cpu) · line 477

Quoted 5 lines
xen/common/sched/cpupool.c +1 -1
@@ -474,7 +474,8 @@ static int cpupool_unassign_cpu_start(struct cpupool *c, unsigned int cpu)
     cpumask_andnot(c->cpu_valid, c->cpu_valid, cpus);
     cpumask_and(c->res_valid, c->cpu_valid, &sched_res_mask);
 
-    rcu_read_unlock(&domlist_read_lock);
+out_rcu:

... the label indented by at least one blank, at which point it may make sense to also ...

xen/common/sched/cpupool.c static int cpupool_unassign_cpu_start(struct cpupool *c, unsigned int cpu) · line 479

Quoted 2 lines
xen/common/sched/cpupool.c +1 -0
+    rcu_read_unlock(&sched_res_rculock);
 out:

... correct this one.

Jan

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