All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvm: optimize ISR lookups
Date: Wed, 30 May 2012 17:18:27 +0300	[thread overview]
Message-ID: <4FC62C33.7080509@redhat.com> (raw)
In-Reply-To: <alpine.LFD.2.02.1205232210440.3231@ionos>

On 05/24/2012 01:00 AM, Thomas Gleixner wrote:

> Thought more about that.
> 
> We have a clear distinction between HW accessed data and software
> accessed data.
> 
> If I look at TPR then it is special cased already and it does:
> 
>    case APIC_TASKPRI:
>                 report_tpr_access(apic, false|true);
>                 /* fall thru */
> 
> And the fall through is using the general accessor for all not special
> cased registers.
> 
> So all you have to do is 
> 
>    case APIC_TASKPRI:
>                 report_tpr_access(apic, false|true);
> +		return access_mapped_reg(...);
> 
> Instead of the fall through.
> 
> So there is no synchronizing back and forth problem simply because you
> already have a special case for that register.
> 
> I know you'll argue that the tpr reporting is a special hack for
> windows guests, at least that's what the changelog tells.
> 
> But even if we have a few more registers accessed by hardware and if
> they do not require a special casing, I really doubt that the overhead
> of special casing those few regs will be worse than not having the
> obvious optimization in place.
> 
> And looking deeper it's a total non issue. The apic mapping is 4k. The
> register stride is strictly 0x10. That makes a total of 256 possible
> registers.
> 
> So now you have two possibilites:
> 
> 1) Create a 256 bit == 64byte bitfield to select the one or the other
>    representation.
> 
>    The overhead of checking the bit is not going to be observable.
> 
> 2) Create a 256 function pointer array == 2k resp. 1k (64 / 32bit)
> 
>    That's not a lot of memory even if you have to maintain two
>    separate variants for read and write, but it allows you to get rid
>    of the already horribly compiled switch case in apic_read/write and
>    you'll get the optional stuff like report_tpr_access() w/o extra
>    conditionals just for free.
> 
>    An extra goodie is that you can catch any access to a non existing
>    register which you now just silently ignore.  And that allows you
>    to react on any future hardware oddities without adding a single
>    runtime conditional.
> 
>    This is stricly x86 and x86 is way better at dealing with indirect
>    calls than with the mess gcc creates compiling those switch case
>    constructs.
> 
>    So I'd go for that and rather spend the memory and the time in
>    setting up the function pointers on init/ioctl than dealing with
>    the inconsistency of HW/SW representation with magic hacks.
> 

I like the bitmap version, it seems very lightweight.  But by itself it
doesn't allow us to use bitmap_weight (or the other bitmap accessors),
unless you assume beforehand that those registers will never be in the
hardware-layout region.

(you also need extra code for copying the APIC state to and from
userspace; right now we just memcpy the APIC page)


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

      reply	other threads:[~2012-05-30 14:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 16:37 [PATCH] kvm: optimize ISR lookups Michael S. Tsirkin
2012-05-21 18:44 ` Michael S. Tsirkin
2012-05-21 21:04 ` Thomas Gleixner
2012-05-21 21:51   ` Michael S. Tsirkin
2012-05-21 22:14     ` Thomas Gleixner
2012-05-21 22:24       ` Michael S. Tsirkin
2012-05-21 22:44         ` Thomas Gleixner
2012-05-21 22:50           ` Michael S. Tsirkin
2012-05-21 23:01         ` Thomas Gleixner
2012-05-22 10:46           ` Avi Kivity
2012-05-23 14:48             ` Ingo Molnar
2012-05-23 15:03               ` Avi Kivity
2012-05-23 20:10                 ` Thomas Gleixner
2012-05-23 20:46                   ` Michael S. Tsirkin
2012-05-23 23:02                     ` Thomas Gleixner
2012-05-23 15:14               ` Michael S. Tsirkin
2012-05-23 19:22                 ` H. Peter Anvin
2012-05-21 23:11         ` Thomas Gleixner
2012-05-21 23:06   ` Michael S. Tsirkin
2012-05-21 23:12     ` H. Peter Anvin
2012-05-21 23:36     ` Thomas Gleixner
2012-05-22 10:59   ` Avi Kivity
2012-05-22 17:26     ` Thomas Gleixner
2012-05-23 15:10       ` Avi Kivity
2012-05-23 18:37         ` Thomas Gleixner
2012-05-23 19:25           ` H. Peter Anvin
2012-05-23 22:00             ` Thomas Gleixner
2012-05-30 14:18               ` Avi Kivity [this message]

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=4FC62C33.7080509@redhat.com \
    --to=avi@redhat.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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.