提交 086c9855 编写于 作者: A Alex,Shi 提交者: Avi Kivity

KVM: use this_cpu_xxx replace percpu_xxx funcs

percpu_xxx funcs are duplicated with this_cpu_xxx funcs, so replace them
for further code clean up.

And in preempt safe scenario, __this_cpu_xxx funcs has a bit better
performance since __this_cpu_xxx has no redundant preempt_disable()
Signed-off-by: NAlex Shi <alex.shi@intel.com>
Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 e37fa785
...@@ -4664,15 +4664,15 @@ static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu); ...@@ -4664,15 +4664,15 @@ static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu);
static int kvm_is_in_guest(void) static int kvm_is_in_guest(void)
{ {
return percpu_read(current_vcpu) != NULL; return __this_cpu_read(current_vcpu) != NULL;
} }
static int kvm_is_user_mode(void) static int kvm_is_user_mode(void)
{ {
int user_mode = 3; int user_mode = 3;
if (percpu_read(current_vcpu)) if (__this_cpu_read(current_vcpu))
user_mode = kvm_x86_ops->get_cpl(percpu_read(current_vcpu)); user_mode = kvm_x86_ops->get_cpl(__this_cpu_read(current_vcpu));
return user_mode != 0; return user_mode != 0;
} }
...@@ -4681,8 +4681,8 @@ static unsigned long kvm_get_guest_ip(void) ...@@ -4681,8 +4681,8 @@ static unsigned long kvm_get_guest_ip(void)
{ {
unsigned long ip = 0; unsigned long ip = 0;
if (percpu_read(current_vcpu)) if (__this_cpu_read(current_vcpu))
ip = kvm_rip_read(percpu_read(current_vcpu)); ip = kvm_rip_read(__this_cpu_read(current_vcpu));
return ip; return ip;
} }
...@@ -4695,13 +4695,13 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = { ...@@ -4695,13 +4695,13 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = {
void kvm_before_handle_nmi(struct kvm_vcpu *vcpu) void kvm_before_handle_nmi(struct kvm_vcpu *vcpu)
{ {
percpu_write(current_vcpu, vcpu); __this_cpu_write(current_vcpu, vcpu);
} }
EXPORT_SYMBOL_GPL(kvm_before_handle_nmi); EXPORT_SYMBOL_GPL(kvm_before_handle_nmi);
void kvm_after_handle_nmi(struct kvm_vcpu *vcpu) void kvm_after_handle_nmi(struct kvm_vcpu *vcpu)
{ {
percpu_write(current_vcpu, NULL); __this_cpu_write(current_vcpu, NULL);
} }
EXPORT_SYMBOL_GPL(kvm_after_handle_nmi); EXPORT_SYMBOL_GPL(kvm_after_handle_nmi);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册