lkml.org 
[lkml]   [2012]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] KVM: x86: add paging gcc optimization
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



\
 
 \ /
  Last update: 2012-03-12 13:15    [W:0.109 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site