[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xen/sched: fix locking in restore_vcpu_affinity()



commit 0d10a77cc98dda1b8f9a96954149a872f46048c9
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Tue Jul 23 11:20:55 2019 +0200
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Tue Jul 23 12:46:58 2019 +0100

    xen/sched: fix locking in restore_vcpu_affinity()
    
    Commit 0763cd2687897b55e7 ("xen/sched: don't disable scheduler on cpus
    during suspend") removed a lock in restore_vcpu_affinity() which needs
    to stay: cpumask_scratch_cpu() must be protected by the scheduler
    lock. restore_vcpu_affinity() is being called by thaw_domains(), so
    with multiple domains in the system another domain might already be
    running and the scheduler might make use of cpumask_scratch_cpu()
    already.
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Reviewed-by: Dario Faggioli <dfaggioli@xxxxxxxx>
---
 xen/common/schedule.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 25f6ab388d..349f9624f5 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -708,6 +708,8 @@ void restore_vcpu_affinity(struct domain *d)
          * set v->processor of each of their vCPUs to something that will
          * make sense for the scheduler of the cpupool in which they are in.
          */
+        lock = vcpu_schedule_lock_irq(v);
+
         cpumask_and(cpumask_scratch_cpu(cpu), v->cpu_hard_affinity,
                     cpupool_domain_cpumask(d));
         if ( cpumask_empty(cpumask_scratch_cpu(cpu)) )
@@ -731,6 +733,9 @@ void restore_vcpu_affinity(struct domain *d)
 
         v->processor = cpumask_any(cpumask_scratch_cpu(cpu));
 
+        spin_unlock_irq(lock);
+
+        /* v->processor might have changed, so reacquire the lock. */
         lock = vcpu_schedule_lock_irq(v);
         v->processor = sched_pick_cpu(vcpu_scheduler(v), v);
         spin_unlock_irq(lock);
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.