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




\
 
 \ /
  Last update: 2012-03-08 22:31    [W:0.070 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site