From: Gregory Haskins <gregory.haskins@gmail.com>
To: Mark McLoughlin <markmc@redhat.com>
Cc: Gregory Haskins <ghaskins@novell.com>,
Avi Kivity <avi@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Davide Libenzi <davidel@xmailserver.org>,
mtosatti@redhat.com
Subject: Re: [KVM PATCH v4 3/3] kvm: add iosignalfd support
Date: Wed, 03 Jun 2009 18:04:14 -0400 [thread overview]
Message-ID: <4A26F35E.1090307@gmail.com> (raw)
In-Reply-To: <1243446484.4852.13.camel@blaa>
[-- Attachment #1: Type: text/plain, Size: 4683 bytes --]
Mark McLoughlin wrote:
> On Wed, 2009-05-27 at 13:40 -0400, Gregory Haskins wrote:
>
>> Mark McLoughlin wrote:
>>
>>> On Wed, 2009-05-27 at 15:11 +0300, Avi Kivity wrote:
>>>
>>>
>>>
>>>> Multiple cookies on the same address are required by virtio. You can't
>>>> mux since the data doesn't go anywhere.
>>>>
>>>> Virtio can survive by checking all rings on a notify, and we can later
>>>> add a mechanism that has a distinct address for each ring, but let's see
>>>> if we can cope with multiple cookies. Mark?
>>>>
>>>>
>>> Trying to catch up, but you're talking about replacing virtio-pci
>>> QUEUE_NOTIFY handling with iosignalfd ?
>>>
>>> For a perfect replacement, what you really need is to be able to
>>> register multiple cookies per address range, but only have them trigger
>>> if the written data matches a provided value.
>>>
>>>
>> Hmm..thats an interesting idea. To date, the "cookie" has really been
>> for identifying the proper range selected for deassignment. I never
>> thought of using it as an actual trigger value at run-time.
>>
>>
>>> If the data is lost, virtio has no way of knowing which queue is being
>>> notified, so we either end up with per-device, rather than per-queue,
>>> notifications (probably not too bad for net, at least) or a different
>>> notify address per queue (limiting the number of queues per device).
>>>
>>>
>> The addr-per-queue is how I was envisioning it, but the trigger value
>> concept hadn't occurred to me. I could make this an option during
>> assignment (e.g. "COOKIE" flag means only trigger on writes of the
>> provided cookie, otherwise trigger on any write). Sound good?
>>
>
> Ah, I'd been thinking of the trigger data being provided separately to
> the cookie.
>
> The virtio ABI is fixed, so we couldn't e.g. have the guest use a cookie
> to identify a queue - it's just going to continue using a per-device
> queue number. So, if the cookie was also the trigger, we'd need an
> eventfd per device.
>
> And if this was a device where the guest writes similar values to
> multiple addresses, you'd need an eventfd per address.
>
>
Hi Mark,
So with the v5 release of iosignalfd, we now have the notion of a
"trigger", the API of which is as follows:
-----------------------
/*!
* \brief Assign an eventfd to an IO port (PIO or MMIO)
*
* Assigns an eventfd based file-descriptor to a specific PIO or MMIO
* address range. Any guest writes to the specified range will generate
* an eventfd signal.
*
* A data-match pointer can be optionally provided in "trigger" and only
* writes which match this value exactly will generate an event. The length
* of the trigger is established by the length of the overall IO range, and
* therefore must be in a natural byte-width for the IO routines of your
* particular architecture (e.g. 1, 2, 4, or 8 bytes on x86_64).
*
* \param kvm Pointer to the current kvm_context
* \param addr The IO address
* \param len The length of the IO region at the address
* \param fd The eventfd file-descriptor
* \param trigger A optional pointer providing data-match token
* \param flags FLAG_PIO: PIO, else MMIO
*/
int kvm_assign_iosignalfd(kvm_context_t kvm, unsigned long addr, size_t len,
int fd, void *trigger, int flags);
-----------------
in the kvm-eventfd test harness, I create three unique eventfd handles,
and do the following:
-------------------
unsigned char matchA = 0xa5, matchB = 0x42;
kvm_assign_iosignalfd(kvm_context, addr, 1, fd[0], NULL, 0);
kvm_assign_iosignalfd(kvm_context, addr, 1, fd[1], &matchA, 0);
kvm_assign_iosignalfd(kvm_context, addr, 1, fd[2], &matchB, 0);
-------------------
In otherwords, I register a "NULL" trigger (wildcarded) on the first
fd. The second has a data-match trigger of 0xa5, and the third has
0x42. All three of these eventfd's map to the same mmio address with a
width of 1 byte.
I also fork a task which selects all three fds, and will print out the
eventfd "count" value when tripped.
Then, in the guest, I do:
----------------------
iowrite8(0, iosignalfd_mmio);
iowrite8(0xa5, iosignalfd_mmio);
iowrite8(0x42, iosignalfd_mmio);
-------------------
The result of which is:
IOSIGNALFD 0: event triggered with val 3
IOSIGNALFD 1: event triggered with val 1
IOSIGNALFD 2: event triggered with val 1
on the host, which is my expected outcome. Let me know if you do not
think this is sufficient to implement a solution to your virtio-pci design.
-Greg
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 266 bytes --]
next prev parent reply other threads:[~2009-06-03 22:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-26 19:15 [KVM PATCH v4 0/3] iosignalfd Gregory Haskins
2009-05-26 19:15 ` [KVM PATCH v4 1/3] eventfd: export eventfd interfaces for module use Gregory Haskins
2009-05-27 8:57 ` Avi Kivity
2009-05-27 11:53 ` Gregory Haskins
2009-05-26 19:15 ` [KVM PATCH v4 2/3] kvm: make io_bus interface more robust Gregory Haskins
2009-05-27 8:54 ` Avi Kivity
2009-05-27 11:26 ` Gregory Haskins
2009-05-26 19:15 ` [KVM PATCH v4 3/3] kvm: add iosignalfd support Gregory Haskins
2009-05-27 9:03 ` Avi Kivity
2009-05-27 11:47 ` Gregory Haskins
2009-05-27 12:11 ` Avi Kivity
2009-05-27 12:54 ` Gregory Haskins
2009-05-27 17:25 ` Mark McLoughlin
2009-05-27 17:40 ` Gregory Haskins
2009-05-27 17:48 ` Mark McLoughlin
2009-05-27 20:45 ` Gregory Haskins
2009-05-28 9:09 ` Mark McLoughlin
2009-05-28 12:12 ` Gregory Haskins
2009-05-31 9:11 ` Avi Kivity
2009-06-01 12:14 ` Gregory Haskins
2009-06-03 22:04 ` Gregory Haskins [this message]
2009-06-04 13:20 ` Mark McLoughlin
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=4A26F35E.1090307@gmail.com \
--to=gregory.haskins@gmail.com \
--cc=avi@redhat.com \
--cc=davidel@xmailserver.org \
--cc=ghaskins@novell.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markmc@redhat.com \
--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