linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alex,Shi" <alex.shi@intel.com>
To: Avi Kivity <avi@redhat.com>
Cc: Christoph Lameter <cl@gentwo.org>,
	"tj@kernel.org" <tj@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"eric.dumazet@gmail.com" <eric.dumazet@gmail.com>,
	"Huang, Ying" <ying.huang@intel.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"kaber@trash.net" <kaber@trash.net>,
	"a.p.zijlstra@chello.nl" <a.p.zijlstra@chello.nl>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"jeremy@xensource.com" <jeremy@xensource.com>
Subject: Re: [PATCH 2/3] kvm: use this_cpu_xxx replace percpu_xxx funcs
Date: Mon, 24 Oct 2011 10:50:08 +0800	[thread overview]
Message-ID: <1319424608.5061.25.camel@debian> (raw)
In-Reply-To: <1319096041.23426.182.camel@debian>

On Thu, 2011-10-20 at 15:34 +0800, Alex,Shi wrote:
> 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()
> 

Avi: 
Would you like to give some comments of this? 

> Signed-off-by: Alex Shi <alex.shi@intel.com>
> ---
>  arch/x86/kvm/x86.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 84a28ea..432c4bc 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -5024,15 +5024,15 @@ static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu);
>  
>  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)
>  {
>  	int user_mode = 3;
>  
> -	if (percpu_read(current_vcpu))
> -		user_mode = kvm_x86_ops->get_cpl(percpu_read(current_vcpu));
> +	if (__this_cpu_read(current_vcpu))
> +		user_mode = kvm_x86_ops->get_cpl(__this_cpu_read(current_vcpu));
>  
>  	return user_mode != 0;
>  }
> @@ -5041,8 +5041,8 @@ static unsigned long kvm_get_guest_ip(void)
>  {
>  	unsigned long ip = 0;
>  
> -	if (percpu_read(current_vcpu))
> -		ip = kvm_rip_read(percpu_read(current_vcpu));
> +	if (__this_cpu_read(current_vcpu))
> +		ip = kvm_rip_read(__this_cpu_read(current_vcpu));
>  
>  	return ip;
>  }
> @@ -5055,13 +5055,13 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = {
>  
>  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);
>  
>  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);
>  



  reply	other threads:[~2011-10-24  2:47 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10  9:10 [PATCH] Code clean up for percpu_xxx() functions Alex,Shi
2011-10-10 17:08 ` Christoph Lameter
2011-10-11  9:19   ` Alex,Shi
2011-10-11 14:13     ` Christoph Lameter
2011-10-12  1:29       ` Alex,Shi
2011-10-12 13:59         ` Christoph Lameter
2011-10-12 14:11         ` Alex,Shi
2011-10-12 14:11           ` Christoph Lameter
2011-10-18  3:21             ` Alex,Shi
2011-10-18 14:33               ` Christoph Lameter
2011-10-19  9:23                 ` Alex,Shi
2011-10-19  9:26                   ` Avi Kivity
2011-10-20  2:45                     ` Alex,Shi
2011-10-20  7:34                     ` [PATCH 2/3] kvm: use this_cpu_xxx replace percpu_xxx funcs Alex,Shi
2011-10-24  2:50                       ` Alex,Shi [this message]
2011-10-24 11:05                         ` Avi Kivity
2011-11-21  9:02                           ` Alex,Shi
2011-11-21  9:20                             ` Avi Kivity
2011-11-21  9:52                               ` Alex,Shi
2012-01-11  8:48                               ` Alex,Shi
2011-10-19 15:34                   ` [PATCH] Code clean up for percpu_xxx() functions Christoph Lameter
2011-10-20  2:44                     ` Alex,Shi
2011-10-20  5:08                       ` Eric Dumazet
2011-10-20  6:04                         ` Alex,Shi
2011-10-20  6:13                           ` Alex,Shi
2011-10-20  6:04                         ` Alex,Shi
2011-10-20  7:20                         ` [PATCH 0/3] code clean and optimzed for percpu_xxx serials funcs Alex,Shi
2011-10-20  7:32                         ` [PATCH 1/3] net: use this_cpu_xxx replace percpu_xxx funcs Alex,Shi
2011-10-20  8:38                           ` Eric Dumazet
2011-11-21  9:00                             ` Alex,Shi
2011-12-02  2:33                               ` Alex,Shi
2011-12-02 11:56                                 ` Patrick McHardy
2012-01-11  8:45                                   ` Alex,Shi
2012-01-11  9:03                                     ` David Miller
2012-01-11  9:10                                       ` Alex,Shi
2011-10-20  7:35                     ` [PATCH 3/3] Code clean up for percpu_xxx() functions Alex,Shi
2011-11-21  9:10                       ` Alex,Shi
2011-11-22  0:06                         ` tj
2012-01-11  9:08                           ` Alex,Shi
2012-01-11 17:19                             ` tj
2012-01-12  0:44                               ` H. Peter Anvin
2012-01-12  2:05                                 ` Alex,Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1319424608.5061.25.camel@debian \
    --to=alex.shi@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=avi@redhat.com \
    --cc=cl@gentwo.org \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=jeremy@xensource.com \
    --cc=kaber@trash.net \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).