From fc6151d0e952ebcf7318bc2dccfb9dab6934d61c Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 26 Aug 2005 17:57:09 +0000 Subject: [PATCH] Refactor sync_lazy_execstate_cpu() into the more sensible sync_vcpu_execstate(). Signed-off-by: Keir Fraser --- xen/arch/ia64/xenmisc.c | 2 +- xen/arch/x86/domain.c | 7 ++++++- xen/common/schedule.c | 4 +--- xen/include/xen/sched.h | 9 +++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/xen/arch/ia64/xenmisc.c b/xen/arch/ia64/xenmisc.c index c76a93eca8..e651db4c65 100644 --- a/xen/arch/ia64/xenmisc.c +++ b/xen/arch/ia64/xenmisc.c @@ -58,7 +58,7 @@ platform_is_hp_ski(void) /* calls in xen/common code that are unused on ia64 */ -void sync_lazy_execstate_cpu(unsigned int cpu) {} +void sync_vcpu_execstate(struct vcpu *v) {} #ifdef CONFIG_VTI int grant_table_create(struct domain *d) { return 0; } diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index db1d630e64..974ec0c2dc 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -885,8 +885,13 @@ int __sync_lazy_execstate(void) return switch_required; } -void sync_lazy_execstate_cpu(unsigned int cpu) +void sync_vcpu_execstate(struct vcpu *v) { + unsigned int cpu = v->processor; + + if ( !cpu_isset(cpu, v->domain->cpumask) ) + return; + if ( cpu == smp_processor_id() ) { (void)__sync_lazy_execstate(); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 3cec109727..ff9373d60f 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -218,9 +218,7 @@ void vcpu_sleep_sync(struct vcpu *v) && spin_is_locked(&schedule_data[v->processor].schedule_lock) ) cpu_relax(); - /* Counteract lazy context switching. */ - if ( cpu_isset(v->processor, v->domain->cpumask) ) - sync_lazy_execstate_cpu(v->processor); + sync_vcpu_execstate(v); } void vcpu_wake(struct vcpu *v) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 2d93f7576d..e7b06ff4ca 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -250,10 +250,11 @@ void vcpu_sleep_nosync(struct vcpu *d); void vcpu_sleep_sync(struct vcpu *d); /* - * Force loading of currently-executing domain state on the specified CPU. - * This is used to counteract lazy state switching where required. + * Force synchronisation of given VCPU's state. If it is currently descheduled, + * this call will ensure that all its state is committed to memory and that + * no CPU is using critical state (e.g., page tables) belonging to the VCPU. */ -extern void sync_lazy_execstate_cpu(unsigned int cpu); +extern void sync_vcpu_execstate(struct vcpu *v); /* * Called by the scheduler to switch to another VCPU. On entry, although @@ -265,7 +266,7 @@ extern void sync_lazy_execstate_cpu(unsigned int cpu); * The callee must ensure that the local CPU is no longer running in @prev's * context, and that the context is saved to memory, before returning. * Alternatively, if implementing lazy context switching, it suffices to ensure - * that invoking sync_lazy_execstate() will switch and commit @prev's state. + * that invoking sync_vcpu_execstate() will switch and commit @prev's state. */ extern void context_switch( struct vcpu *prev, -- 2.30.2