diff options
author | Ben Guthro <benjamin.guthro@citrix.com> | 2013-04-09 16:13:11 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2013-04-09 16:13:11 +0200 |
commit | 95483087da57c29d778cbc1941a807f60357daf7 (patch) | |
tree | abdab84b590c25aa6c830dc9dca5c5c5a707c65b | |
parent | d7d4d16afe2460a4e988ba237ec44c7fc36b7b1f (diff) | |
download | xen-95483087da57c29d778cbc1941a807f60357daf7.tar.gz xen-95483087da57c29d778cbc1941a807f60357daf7.tar.bz2 xen-95483087da57c29d778cbc1941a807f60357daf7.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>
master commit: 41e71c2607e036f1ac00df898b8f4acb2d4df7ee
master date: 2013-04-02 09:52:32 +0200
-rw-r--r-- | xen/arch/x86/acpi/power.c | 3 | ||||
-rw-r--r-- | xen/common/schedule.c | 45 | ||||
-rw-r--r-- | xen/include/xen/sched.h | 6 |
3 files changed, 51 insertions, 3 deletions
diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c index 7a08091b00..dc37be88b5 100644 --- a/xen/arch/x86/acpi/power.c +++ b/xen/arch/x86/acpi/power.c @@ -96,7 +96,10 @@ static void thaw_domains(void) rcu_read_lock(&domlist_read_lock); for_each_domain ( d ) + { + restore_vcpu_affinity(d); domain_unpause(d); + } rcu_read_unlock(&domlist_read_lock); } diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 001da3d03a..edb0177a59 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -545,6 +545,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); + cpus_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. @@ -559,7 +591,7 @@ int cpu_disable_scheduler(unsigned int cpu) bool_t affinity_broken; c = per_cpu(cpupool, cpu); - if ( (c == NULL) || (system_state == SYS_STATE_suspend) ) + if ( c == NULL ) return ret; for_each_domain ( d ) @@ -577,8 +609,15 @@ int cpu_disable_scheduler(unsigned int cpu) if ( cpus_empty(online_affinity) && cpu_isset(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) + { + cpus_copy(v->cpu_affinity_saved, v->cpu_affinity); + v->affinity_broken = 1; + } + cpus_setall(v->cpu_affinity); affinity_broken = 1; } diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 35c3a7f13c..5909d9ace7 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -143,6 +143,9 @@ struct vcpu bool_t defer_shutdown; /* VCPU is paused following shutdown request (d->is_shutting_down)? */ bool_t paused_for_shutdown; + /* VCPU need affinity restored */ + bool_t affinity_broken; + /* * > 0: a single port is being polled; @@ -165,6 +168,8 @@ struct vcpu cpumask_t cpu_affinity; /* Used to change affinity temporarily. */ cpumask_t cpu_affinity_tmp; + /* Used to restore affinity across S3. */ + cpumask_t cpu_affinity_saved; /* Bitmask of CPUs which are holding onto this VCPU's state. */ cpumask_t vcpu_dirty_cpumask; @@ -619,6 +624,7 @@ int schedule_cpu_switch(unsigned int cpu, struct cpupool *c); void vcpu_force_reschedule(struct vcpu *v); int cpu_disable_scheduler(unsigned int cpu); int vcpu_set_affinity(struct vcpu *v, cpumask_t *affinity); +void restore_vcpu_affinity(struct domain *d); void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate); uint64_t get_cpu_idle_time(unsigned int cpu); |