All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Davidlohr Bueso <dave@gnu.org>,
	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: Mon, 12 Mar 2012 14:12:59 +0200	[thread overview]
Message-ID: <4F5DE84B.8050606@redhat.com> (raw)
In-Reply-To: <4F58D48F.8050807@de.ibm.com>

On 03/08/2012 05:47 PM, 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.

Agree.

> Is that the case here? This patch  might cause a mis-prediction for non-paging guests all 
> the time. 
>
> 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".

In fact this is a classic example.  Almost no guests use real mode (the
last guests to use real mode extensively was DOS; I think Win9x switches
to real mode pretty often).  As it's a user-controlled setting, we're
penalizing users who do things differently.

However the majority if is_paging() == true guests is so huge, and since
non-paging guests don't really expect 2012 performance levels anyway
(being so old) that I think in practice this is a good optimization here.

-- 
error compiling committee.c: too many arguments to function

  parent reply	other threads:[~2012-03-12 12:12 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
2012-03-12 12:12   ` Avi Kivity [this message]
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=4F5DE84B.8050606@redhat.com \
    --to=avi@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=dave@gnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.