From: Avi Kivity <avi@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Gregory Haskins <ghaskins@novell.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Davide Libenzi <davidel@xmailserver.org>
Subject: Re: [KVM PATCH v9 2/2] KVM: add iosignalfd support
Date: Tue, 07 Jul 2009 14:53:18 +0300 [thread overview]
Message-ID: <4A53372E.6090509@redhat.com> (raw)
In-Reply-To: <20090707112024.GA3647@redhat.com>
(adding Davide, there's a small comment for you in the middle, search
for eventfd)
On 07/07/2009 02:20 PM, Michael S. Tsirkin wrote:
>
>> @@ -307,6 +307,19 @@ struct kvm_guest_debug {
>> struct kvm_guest_debug_arch arch;
>> };
>>
>> +#define KVM_IOSIGNALFD_FLAG_TRIGGER (1<< 0) /* trigger is valid */
>>
>
> can we rename trigger -> value?
>
Or maybe data_match?
Speaking of renames, how about IOSIGNALFD -> IOEVENTFD? I have some
vague uneasiness seeing signals all the time.
>> +#define KVM_IOSIGNALFD_FLAG_PIO (1<< 1) /* is a pio (otherwise mmio) */
>> +#define KVM_IOSIGNALFD_FLAG_DEASSIGN (1<< 2)
>> +
>> +struct kvm_iosignalfd {
>> + __u64 trigger;
>>
>
> for length<8, it's the 8*len least significant bits that are used, right?
> That's a bit ugly ... Maybe just put an 8 byte array here instead, then
> the first len bytes are valid.
>
>
We're matching the value as the guest wrote it. I think this is fine.
>> + struct kvm_io_device dev;
>> + int wildcard:1;
>>
>
> don't use bitfields
>
Yeah, bool is better.
>> + /* address-range must be precise for a hit */
>>
>
> So there's apparently no way to specify that
> you want 1,2, or 4 byte writes at address X?
>
Why would you want that?
>
>> + return false;
>> +
>> + if (p->wildcard)
>> + /* all else equal, wildcard is always a hit */
>> + return true;
>> +
>> + /* otherwise, we have to actually compare the data */
>> +
>> + BUG_ON(!IS_ALIGNED((unsigned long)val, len));
>> +
>> + switch (len) {
>> + case 1:
>> + _val = *(u8 *)val;
>> + break;
>> + case 2:
>> + _val = *(u16 *)val;
>> + break;
>> + case 4:
>> + _val = *(u32 *)val;
>> + break;
>> + case 8:
>> + _val = *(u64 *)val;
>> + break;
>> + default:
>> + return false;
>> + }
>> +
>> + return _val == p->match ? true : false;
>>
>
> Life be simpler if we use an 8 byte array for match
> and just do memcmp here.
>
My plan is to change the io_dev interface to pass a u64.
>> +
>> + eventfd = eventfd_ctx_fdget(args->fd);
>> + if (IS_ERR(eventfd))
>> + return PTR_ERR(eventfd);
>>
>
> since this eventfd is kept around indefinitely, we should keep the
> file * around as well, so that this eventfd is accounted for
> properly with # of open files limit set by the admin.
>
Won't all eventfd_ctx_get() uses suffer from that?
Davide, I think this is better handled in eventfd. Or else we can
ignore it and trust whoever holds the eventfd_ctx to limit the mount of
objects.
>> +
>> +int
>> +kvm_iosignalfd(struct kvm *kvm, struct kvm_iosignalfd *args)
>> +{
>> + if (args->flags& KVM_IOSIGNALFD_FLAG_DEASSIGN)
>> + return kvm_deassign_iosignalfd(kvm, args);
>>
>
> Better check that only known flag values are present.
> Otherwise when you add more flags things just break
> silently.
>
Good comment and something that we miss a lot.
>> + case KVM_IOSIGNALFD: {
>> + struct kvm_iosignalfd data;
>> +
>> + r = -EFAULT;
>>
>
> this trick is nice, it saves a line of code for the closing brace
> but why waste it on an empty line above then?
>
Traditionally C code separates declarations from code.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2009-07-07 11:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-06 20:33 [KVM PATCH v9 0/2] iosignalfd Gregory Haskins
2009-07-06 20:33 ` [KVM PATCH v9 1/2] KVM: make io_bus interface more robust Gregory Haskins
2009-07-07 11:20 ` Michael S. Tsirkin
2009-07-07 17:26 ` Gregory Haskins
2009-07-08 7:47 ` Michael S. Tsirkin
2009-07-08 11:40 ` Gregory Haskins
2009-07-06 20:33 ` [KVM PATCH v9 2/2] KVM: add iosignalfd support Gregory Haskins
2009-07-07 11:20 ` Michael S. Tsirkin
2009-07-07 11:53 ` Avi Kivity [this message]
2009-07-07 12:22 ` Michael S. Tsirkin
2009-07-07 12:27 ` Avi Kivity
2009-07-07 12:51 ` Michael S. Tsirkin
2009-07-07 12:56 ` Gregory Haskins
2009-07-07 13:21 ` Michael S. Tsirkin
2009-07-07 13:30 ` Gregory Haskins
2009-07-07 12:56 ` Avi Kivity
2009-07-07 13:17 ` Gregory Haskins
2009-07-07 12:15 ` Gregory Haskins
2009-07-07 12:48 ` Michael S. Tsirkin
2009-07-07 12:56 ` Avi Kivity
2009-07-07 12:58 ` Michael S. Tsirkin
2009-07-07 13:16 ` Gregory Haskins
2009-07-07 9:22 ` [KVM PATCH v9 0/2] iosignalfd 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=4A53372E.6090509@redhat.com \
--to=avi@redhat.com \
--cc=davidel@xmailserver.org \
--cc=ghaskins@novell.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@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