diff options
author | Ben Guthro <benjamin.guthro@citrix.com> | 2013-04-02 09:52:32 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2013-04-02 09:52:32 +0200 |
commit | 41e71c2607e036f1ac00df898b8f4acb2d4df7ee (patch) | |
tree | bb768df8cdebd22eabbfa39e8f8d5c1ff4fbf00e /xen/common/schedule.c | |
parent | af699220ad6d111ba76fc3040342184e423cc9a1 (diff) | |
download | xen-41e71c2607e036f1ac00df898b8f4acb2d4df7ee.tar.gz xen-41e71c2607e036f1ac00df898b8f4acb2d4df7ee.tar.bz2 xen-41e71c2607e036f1ac00df898b8f4acb2d4df7ee.zip |
x86/S3: Restore broken vcpu affinity on resume
When in SYS_STATE_suspend, and going through the cpu_disable_scheduler
path, save a copy of the current cpu affinity, and mark a flag to
restore it later.
Later, in the resume process, when enabling nonboot cpus restore these
affinities.
Signed-off-by: Ben Guthro <benjamin.guthro@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/common/schedule.c')
-rw-r--r-- | xen/common/schedule.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 83fae4c9d2..7364ff8a7d 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -541,6 +541,38 @@ void vcpu_force_reschedule(struct vcpu *v) } } +void restore_vcpu_affinity(struct domain *d) +{ + struct vcpu *v; + + for_each_vcpu ( d, v ) + { + vcpu_schedule_lock_irq(v); + + if ( v->affinity_broken ) + { + printk(XENLOG_DEBUG "Restoring affinity for d%dv%d\n", + d->domain_id, v->vcpu_id); + cpumask_copy(v->cpu_affinity, v->cpu_affinity_saved); + v->affinity_broken = 0; + } + + if ( v->processor == smp_processor_id() ) + { + set_bit(_VPF_migrating, &v->pause_flags); + vcpu_schedule_unlock_irq(v); + vcpu_sleep_nosync(v); + vcpu_migrate(v); + } + else + { + vcpu_schedule_unlock_irq(v); + } + } + + domain_update_node_affinity(d); +} + /* * This function is used by cpu_hotplug code from stop_machine context * and from cpupools to switch schedulers on a cpu. @@ -554,7 +586,7 @@ int cpu_disable_scheduler(unsigned int cpu) int ret = 0; c = per_cpu(cpupool, cpu); - if ( (c == NULL) || (system_state == SYS_STATE_suspend) ) + if ( c == NULL ) return ret; for_each_domain_in_cpupool ( d, c ) @@ -567,8 +599,15 @@ int cpu_disable_scheduler(unsigned int cpu) if ( cpumask_empty(&online_affinity) && cpumask_test_cpu(cpu, v->cpu_affinity) ) { - printk("Breaking vcpu affinity for domain %d vcpu %d\n", - v->domain->domain_id, v->vcpu_id); + printk(XENLOG_DEBUG "Breaking affinity for d%dv%d\n", + d->domain_id, v->vcpu_id); + + if (system_state == SYS_STATE_suspend) + { + cpumask_copy(v->cpu_affinity_saved, v->cpu_affinity); + v->affinity_broken = 1; + } + cpumask_setall(v->cpu_affinity); } |