public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@gnu.org>
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>, KVM <kvm@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] KVM: x86: add paging gcc optimization
Date: Thu, 08 Mar 2012 22:27:59 +0100	[thread overview]
Message-ID: <1331242079.2592.4.camel@offbook> (raw)
In-Reply-To: <4F58D48F.8050807@de.ibm.com>

On Thu, 2012-03-08 at 16:47 +0100, Christian Borntraeger wrote:
> On 08/03/12 12:45, Davidlohr Bueso wrote:
> > From: Davidlohr Bueso <dave@gnu.org>
> > 
> > Since most guests will have paging enabled for memory management, add likely() optimization
> > around CR0.PG checks.
> 
> >  {
> > -	return kvm_read_cr0_bits(vcpu, X86_CR0_PG);
> > +	return likely(kvm_read_cr0_bits(vcpu, X86_CR0_PG));
> 
> 
> IMHO likely/unlikely should be considered more as fast-path/slow-path and not as often/less often.
> Is that the case here? This patch  might cause a mis-prediction for non-paging guests all 
> the time. 

Branch predictions are all about probability of occurrence, and I cannot
imagine guests having paging disabled and mapping gva->gpa directly, so
for most of the cases it would be beneficial. For those peculiar users
that actually don't use paging, then yes, mispredictions would occur.

- Davidlohr

> 
> Non-paging might be really irrelevant, so I am just making a point, since
> likely/unlikely is mis-used too often especially for "most users do it that way".
> 
> 
> Christian
> 
> 



  reply	other threads:[~2012-03-08 21:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-08 11:45 [PATCH v2] KVM: x86: add paging gcc optimization Davidlohr Bueso
2012-03-08 15:47 ` Christian Borntraeger
2012-03-08 21:27   ` Davidlohr Bueso [this message]
2012-03-12 12:12   ` Avi Kivity
2012-03-23 21:51     ` Davidlohr Bueso
2012-03-28 16:36       ` Avi Kivity

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=1331242079.2592.4.camel@offbook \
    --to=dave@gnu.org \
    --cc=avi@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.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