From: Avi Kivity <avi@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvm: optimize ISR lookups
Date: Tue, 22 May 2012 13:59:17 +0300 [thread overview]
Message-ID: <4FBB7185.6040105@redhat.com> (raw)
In-Reply-To: <alpine.LFD.2.02.1205211940030.3231@ionos>
On 05/22/2012 12:04 AM, Thomas Gleixner wrote:
> >
> > +static u8 count_vectors(void *bitmap)
> > +{
> > + u32 *word = bitmap;
> > + int word_offset;
> > + u8 count = 0;
> > + for (word_offset = 0; word_offset < MAX_APIC_VECTOR >> 5; ++word_offset)
> > + count += hweight32(word[word_offset << 2]);
> > + return count;
> > +}
>
> Why do you need to reimplement bitmap_weight()?
>
> Because your bitmap is not a bitmap, but a set of 32bit registers
> which have an offset of 4 words each. I really had to twist my brain
> around this function and the test_and_clr/set ones above just because
> the name bitmap is so horribly misleading. Add an extra bonus for
> using void pointers.
>
> Yes, I know, the existing code is full of this, but that's not an
> excuse to add more of it.
>
> This emulation is just silly. Nothing in an emulation where the access
> to the emulated hardware is implemented with vmexits is requiring a
> 1:1 memory layout. It's completely irrelevant whether the hardware has
> an ISR regs offset of 0x10 or not. Nothing prevents the emulation to
> use a consecutive bitmap for the vector bits instead of reimplementing
> a boatload of bitmap operations.
>
> The only justification for having the same layout as the actual
> hardware is when you are going to map the memory into the guest space,
> which is not the case here.
>
>
The APIC page is in fact mapped to the hardware (not the guest, but vmx
microcode does access it). Only one register, the TPR, is ever used.
It's possible to re-layout the data structure so that the TPR stays in
the same place while everything else becomes contiguous, but we'll have
to do it again if the hardware starts mapping more registers.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2012-05-22 10:59 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 [this message]
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
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=4FBB7185.6040105@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 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).