Add self pause ability, which is required by vcpu0/dom0 when running on a AP. This can''t be satisfied by existing interface, since the new flag also serves as a sync point. Signed-off-by Kevin Tian <kevin.tian@intel.com> diff -r d5315422dbc8 xen/common/domain.c --- a/xen/common/domain.c Mon May 14 18:35:31 2007 -0400 +++ b/xen/common/domain.c Mon May 14 20:21:04 2007 -0400 @@ -530,6 +530,17 @@ void vcpu_pause_nosync(struct vcpu *v) vcpu_sleep_nosync(v); } +/* _VPF_need_sync serves not only as flag for sync pause, but also + * as hint for other cpu waiting for this pause. + */ +void vcpu_pause_self(void) +{ + struct vcpu *v = current; + + set_bit(_VPF_need_sync, &v->pause_flags); + vcpu_pause_nosync(v); +} + void vcpu_unpause(struct vcpu *v) { if ( atomic_dec_and_test(&v->pause_count) ) diff -r d5315422dbc8 xen/common/schedule.c --- a/xen/common/schedule.c Mon May 14 18:35:31 2007 -0400 +++ b/xen/common/schedule.c Mon May 14 18:54:28 2007 -0400 @@ -691,6 +691,13 @@ void context_saved(struct vcpu *prev) if ( unlikely(test_bit(_VPF_migrating, &prev->pause_flags)) ) vcpu_migrate(prev); + + if ( unlikely(test_bit(_VPF_need_sync, &prev->pause_flags)) ) + { + sync_vcpu_execstate(prev); + /* test and clear can be split, since here is the only clear point */ + clear_bit(_VPF_need_sync, &prev->pause_flags); + } } /* The scheduler timer: force a run through the scheduler */ diff -r d5315422dbc8 xen/include/xen/sched.h --- a/xen/include/xen/sched.h Mon May 14 18:35:31 2007 -0400 +++ b/xen/include/xen/sched.h Mon May 14 20:21:30 2007 -0400 @@ -457,6 +457,9 @@ extern struct domain *domain_list; /* VCPU affinity has changed: migrating to a new CPU. */ #define _VPF_migrating 3 #define VPF_migrating (1UL<<_VPF_migrating) + /* VCPU needs full context sync once switched out */ +#define _VPF_need_sync 4 +#define VPF_need_sync (1UL<<_VPF_need_sync) static inline int vcpu_runnable(struct vcpu *v) { @@ -467,6 +470,7 @@ static inline int vcpu_runnable(struct v void vcpu_pause(struct vcpu *v); void vcpu_pause_nosync(struct vcpu *v); +void vcpu_pause_self(void); void domain_pause(struct domain *d); void vcpu_unpause(struct vcpu *v); void domain_unpause(struct domain *d); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel