From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Gregory Haskins <ghaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH] Add irqdevice interface + userint implementation
Date: Tue, 10 Apr 2007 17:46:59 +0300 [thread overview]
Message-ID: <461BA363.5080308@qumranet.com> (raw)
In-Reply-To: <461B64E4.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
Gregory Haskins wrote:
>>>> On Tue, Apr 10, 2007 at 8:01 AM, in message <461B7C81.7040102-atKUWr5tajBWk0Htik3J/w@public.gmane.org>,
>>>>
> Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
>
>> Gregory Haskins wrote:
>>
>>> And if we replace read_vector() with ack(), how do we learn of the vector in
>>>
>> the first place? I am guessing that you are thinking that both pending and
>> read_vector return a vector and thus the confusion. Otherwise, I am missing
>> your point completely :) Could you elaborate?
>>
>>>
>>>
>> That's what I thought, but it doesn't really matter: what's important
>> is that accepting an interrupt has several stages, and that they must
>> act as a transaction.
>>
>> The stages are:
>> 1. determine which interrupt is to be injected (if not, abort)
>> 2. check if IF and tpr allow injection
>> 3. one of
>> - inject the interrupt and mark it as in- service
>> - request an exit on IF and/or tpr threshold
>>
>> Simply indicating that an interrupt may be pending is already performed
>> by the irq_sink callback.
>>
>
> Yes, but the operative words here are "may be". INTR tells the system that an interrupt *may be* pending, but we don't yet actually know which vector (if any) will be eligible for injection. Thinking down the road when we will have SMP/PV, we must assume that the CPU could be actually running concurrently. If so, it must be stopped first before we can evaluate the state (e.g., IF, TPR, etc.) to know which vector (if any) can be dispatched. The eligibility of a vector (or the vector itself if a new, higher-pri line is raised in between) may change up until the point the EXIT actually occurs.
>
> This is analogous to how the 8259 INTR/INTA cycle works, IIUC. The INTR line is raised to get the CPUs attention asynchronously independent of CPU state, but its the processor controlled INTA cycle that retrieves the vector to use. IMHO, we want to do the same thing here. The thread that invokes the set_pin and thus indirectly the INTR is one context. You can think of this as the PIC. The thread that is running the guest and VMEXITs is another context. You can think of this as the processor. The PIC signals the processor that it needs attention, but the vector is conveyed on the processor's terms when its ready. In cases where there is no parallelism (e.g., todays sync design, or of the vcpu happens to not be executing), the INTR is a no-op.
>
> Now as far as the rest of the API is concerned, pending() tells us definitively (and efficiently) after we have stopped that there really is something pending given the current state of the system. read_vector() tells us what that vector actually is. Really, read_vector() is the authoritative source of data and acts like our processor controlled INTA cycle. The important thing is that this read_vector() method is called in the same context as the guest CPU thread. The other two (irq_sink, pending) are just helpers to get us to that point.
>
> Where I really think we need to have a critical section is between the vcpu-INTR callback, and the part of the vcpu logic that evaluates whether interrupts are pending (to avoid missing a newly injected interrupt while we are processing). However, I really see this as an vcpu issue more than an issue against the irqdevice interface. Does this make sense?
>
Both the vcpu and the irqdevice are involved in the decision:
- the vcpu holds the IF (or rather, the "interrupt window")
- the lapic holds the tpr
- but the vcpu contains the controls that allow exiting on tpr
modification (on 64-bit and with next-gen Intel processors)
IIUC, you are suggesting (pseudocode):
spin_lock(vcpu->irq_lock)
nmi = !irq_window_open(vcpu)
if (vcpu->irq->pending(nmi))
inject(vcpu, vcpu->irq->read_vector(nmi))
spin_unlock(vcpu->irq_lock)
where ->pending() has to program a tpr exit if current tpr masks an
interrupt.
The alternative I'm suggesting is to move all this mess into the
irqdevice code in a single callback. While this has less reuse
potential, in fact the hardware itself is messy and attempts to
generalize it may turn into a mess as well.
> I will put together a follow-on patch that implements my thinking to help illustrate the concept.
>
That will be best. After all, we're not trying to design a generic
interface, we have a know an limited set of users. Seeing the users
will help evaluate the API.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
next prev parent reply other threads:[~2007-04-10 14:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-05 18:53 [PATCH] Add irqdevice interface + userint implementation Gregory Haskins
2007-04-05 21:38 ` Fwd: " Gregory Haskins
[not found] ` <4614FF5C.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-08 6:47 ` Avi Kivity
[not found] ` <46189005.2090609-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-09 18:36 ` Gregory Haskins
[not found] ` <461A415C.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-10 7:52 ` Avi Kivity
[not found] ` <461B4241.5030101-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-10 11:36 ` Gregory Haskins
[not found] ` <461B3E61.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-10 12:01 ` Avi Kivity
[not found] ` <461B7C81.7040102-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-10 14:20 ` Gregory Haskins
[not found] ` <461B64E4.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-10 14:46 ` Avi Kivity [this message]
[not found] ` <461BA363.5080308-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-10 15:39 ` Gregory Haskins
2007-04-10 15:53 ` Fwd: " Gregory Haskins
[not found] ` <461B7AC6.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-10 16:11 ` Avi Kivity
[not found] ` <461BB738.7040206-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-10 17:58 ` Gregory Haskins
[not found] ` <461B7755.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-10 16:08 ` Avi Kivity
2007-04-08 9:58 ` Christoph Hellwig
[not found] ` <20070408095853.GA31284-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2007-04-08 10:23 ` Avi Kivity
[not found] ` <4618C293.8030902-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-08 10:33 ` Christoph Hellwig
2007-04-09 14:53 ` Gregory Haskins
-- strict thread matches above, loose matches on Subject: below --
2007-04-09 20:27 Gregory Haskins
[not found] ` <461A5B6C.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-10 7:33 ` Avi Kivity
2007-04-10 8:23 ` Christoph Hellwig
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=461BA363.5080308@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=ghaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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