diff options
author | Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> | 2011-01-12 02:40:31 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2011-03-17 12:08:26 -0400 |
commit | 6b7e2d0991489559a1df4500d77f7b76c4607ed0 (patch) | |
tree | b82e941c3ca4d519c71577ad21807af4d02b0679 /include/linux/kvm_host.h | |
parent | d48ead8b0b48862a87138d04efb7580a1a25beb5 (diff) |
KVM: Add "exiting guest mode" state
Currently we keep track of only two states: guest mode and host
mode. This patch adds an "exiting guest mode" state that tells
us that an IPI will happen soon, so unless we need to wait for the
IPI, we can avoid it completely.
Also
1: No need atomically to read/write ->mode in vcpu's thread
2: reorganize struct kvm_vcpu to make ->mode and ->requests
in the same cache line explicitly
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r-- | include/linux/kvm_host.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index b5021db21858..b99eacd988ab 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -98,19 +98,26 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn, | |||
98 | int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu); | 98 | int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu); |
99 | #endif | 99 | #endif |
100 | 100 | ||
101 | enum { | ||
102 | OUTSIDE_GUEST_MODE, | ||
103 | IN_GUEST_MODE, | ||
104 | EXITING_GUEST_MODE | ||
105 | }; | ||
106 | |||
101 | struct kvm_vcpu { | 107 | struct kvm_vcpu { |
102 | struct kvm *kvm; | 108 | struct kvm *kvm; |
103 | #ifdef CONFIG_PREEMPT_NOTIFIERS | 109 | #ifdef CONFIG_PREEMPT_NOTIFIERS |
104 | struct preempt_notifier preempt_notifier; | 110 | struct preempt_notifier preempt_notifier; |
105 | #endif | 111 | #endif |
112 | int cpu; | ||
106 | int vcpu_id; | 113 | int vcpu_id; |
107 | struct mutex mutex; | 114 | int srcu_idx; |
108 | int cpu; | 115 | int mode; |
109 | atomic_t guest_mode; | ||
110 | struct kvm_run *run; | ||
111 | unsigned long requests; | 116 | unsigned long requests; |
112 | unsigned long guest_debug; | 117 | unsigned long guest_debug; |
113 | int srcu_idx; | 118 | |
119 | struct mutex mutex; | ||
120 | struct kvm_run *run; | ||
114 | 121 | ||
115 | int fpu_active; | 122 | int fpu_active; |
116 | int guest_fpu_loaded, guest_xcr0_loaded; | 123 | int guest_fpu_loaded, guest_xcr0_loaded; |
@@ -140,6 +147,11 @@ struct kvm_vcpu { | |||
140 | struct kvm_vcpu_arch arch; | 147 | struct kvm_vcpu_arch arch; |
141 | }; | 148 | }; |
142 | 149 | ||
150 | static inline int kvm_vcpu_exiting_guest_mode(struct kvm_vcpu *vcpu) | ||
151 | { | ||
152 | return cmpxchg(&vcpu->mode, IN_GUEST_MODE, EXITING_GUEST_MODE); | ||
153 | } | ||
154 | |||
143 | /* | 155 | /* |
144 | * Some of the bitops functions do not support too long bitmaps. | 156 | * Some of the bitops functions do not support too long bitmaps. |
145 | * This number must be determined not to exceed such limits. | 157 | * This number must be determined not to exceed such limits. |