kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com
Subject: Re: [PATCH 5/8] KVM: use jump label to optimize checking for HW enabled APIC in APIC_BASE MSR.
Date: Sun, 5 Aug 2012 17:55:38 +0300	[thread overview]
Message-ID: <20120805145538.GS27579@redhat.com> (raw)
In-Reply-To: <501E87CA.8020302@redhat.com>

On Sun, Aug 05, 2012 at 05:48:42PM +0300, Avi Kivity wrote:
> On 08/05/2012 05:42 PM, Gleb Natapov wrote:
> > On Sun, Aug 05, 2012 at 05:35:21PM +0300, Avi Kivity wrote:
> >> On 08/05/2012 03:58 PM, Gleb Natapov wrote:
> >> > Usually all APICs are HW enabled so the check can be optimized out.
> >> > 
> >> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> >> > ---
> >> >  arch/x86/kvm/lapic.c |   29 ++++++++++++++++++++++++++++-
> >> >  arch/x86/kvm/lapic.h |    1 +
> >> >  arch/x86/kvm/x86.c   |    1 +
> >> >  3 files changed, 30 insertions(+), 1 deletion(-)
> >> > 
> >> > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> >> > index c3f14fe..1aa5528 100644
> >> > --- a/arch/x86/kvm/lapic.c
> >> > +++ b/arch/x86/kvm/lapic.c
> >> > @@ -34,6 +34,7 @@
> >> >  #include <asm/current.h>
> >> >  #include <asm/apicdef.h>
> >> >  #include <linux/atomic.h>
> >> > +#include <linux/jump_label.h>
> >> >  #include "kvm_cache_regs.h"
> >> >  #include "irq.h"
> >> >  #include "trace.h"
> >> > @@ -117,9 +118,13 @@ static inline int __apic_test_and_clear_vector(int vec, void *bitmap)
> >> >  	return __test_and_clear_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
> >> >  }
> >> >  
> >> > +struct static_key_deferred apic_hw_disabled __read_mostly;
> >> 
> >> On top of file please.  Add all_ to the name to make it clear we're
> >> talking about all apics.
> >> 
> > This is count of disabled apics really. So I think all_apic_hw_disabled
> > is misleading.
> > 
> >> > +
> >> >  static inline int apic_hw_enabled(struct kvm_lapic *apic)
> >> >  {
> >> > -	return (apic)->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE;
> >> > +	if (static_key_false(&apic_hw_disabled.key))
> >> > +		return apic->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE;
> >> 
> >> Hm, for the test to be readable, it needs to be
> >> 
> >>    if (static_key_false(&all_apics_hw_enabled))
> >> 
> > Exactly. all_ makes it so because apic_hw_disabled is a counter that
> > counts disabled apics. So may be call it global_hw_disabled_apic_counter?
> > 
> 
> The problem is how static_key_false() is defined.  It returns true if
> the count > 0, opposite from what I'd expect.  So anything with counter
> semantics will be confusing.  I guess we need to pick a neutral name
> (apic_disabled_key or apic_disabled_slowpath or such) to force the
> reader to look at the definitions.
> 
There was a long thread about readability of static_key_true/false and
this is the result of it :( I read it this way: drop static_key_(true|false)
and read the if() to understand its meaning. Now look at static_key_(true|false)
to see what fast path will be in asm code.

--
			Gleb.

  reply	other threads:[~2012-08-05 14:55 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-05 12:58 [PATCH 0/8] use jump labels to streamline common APIC configuration Gleb Natapov
2012-08-05 12:58 ` [PATCH 1/8] KVM: clean up kvm_(set|get)_apic_base Gleb Natapov
2012-08-05 12:58 ` [PATCH 2/8] KVM: use kvm_lapic_set_base() to change apic_base Gleb Natapov
2012-08-05 12:58 ` [PATCH 3/8] KVM: mark apic enabled on start up Gleb Natapov
2012-08-05 14:14   ` Avi Kivity
2012-08-05 14:17     ` Gleb Natapov
2012-08-05 14:39       ` Avi Kivity
2012-08-05 14:43         ` Gleb Natapov
2012-08-05 12:58 ` [PATCH 4/8] Export jump_label_rate_limit() Gleb Natapov
2012-08-05 14:16   ` Avi Kivity
2012-08-06 12:37     ` Jason Baron
2012-08-05 12:58 ` [PATCH 5/8] KVM: use jump label to optimize checking for HW enabled APIC in APIC_BASE MSR Gleb Natapov
2012-08-05 14:35   ` Avi Kivity
2012-08-05 14:42     ` Gleb Natapov
2012-08-05 14:48       ` Avi Kivity
2012-08-05 14:55         ` Gleb Natapov [this message]
2012-08-05 12:58 ` [PATCH 6/8] KVM: use jump label to optimize checking for SW enabled apic in spurious interrupt register Gleb Natapov
2012-08-05 12:58 ` [PATCH 7/8] KVM: use jump label to optimize checking for in kernel local apic presence Gleb Natapov
2012-08-05 12:58 ` [PATCH 8/8] KVM: inline kvm_apic_present() and kvm_lapic_enabled() Gleb Natapov
2012-08-05 13:33 ` [PATCH 0/8] use jump labels to streamline common APIC configuration Avi Kivity
2012-08-05 13:35   ` Gleb Natapov
2012-08-05 13:42     ` Avi Kivity
2012-08-05 13:48       ` Gleb Natapov
2012-08-05 14:00         ` Avi Kivity
2012-08-05 14:03           ` Gleb Natapov
2012-08-14 14:00             ` Jan Kiszka
2012-08-14 14:03               ` Gleb Natapov
2012-08-14 14:20                 ` Jan Kiszka
2012-08-14 14:37                   ` Gleb Natapov
2012-08-14 14:58                     ` Jan Kiszka
2012-08-14 16:21                       ` Avi Kivity
2012-08-14 16:38                         ` Jan Kiszka
2012-08-14 17:00                           ` Avi Kivity
2012-08-14 17:16                             ` Jan Kiszka
2012-08-14 14:04               ` Avi Kivity
2012-08-14 14:05                 ` Jan Kiszka
2012-08-14 14:08                   ` Gleb Natapov
2012-08-14 14:07                 ` Gleb Natapov
2012-08-14 14:13                   ` Jan Kiszka
2012-08-14 14:44                     ` Gleb Natapov
2012-08-14 15:09                       ` Jan Kiszka
2012-08-05 19:30 ` Eric Northup
2012-08-06  8:35   ` Avi Kivity
2012-08-06  8:52   ` Gleb Natapov
2012-08-06 13:23 ` 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=20120805145538.GS27579@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@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;
as well as URLs for NNTP newsgroup(s).