From: Gregory Haskins <ghaskins@novell.com>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: kvm@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
avi@redhat.com, mst@redhat.com, paulmck@linux.vnet.ibm.com
Subject: Re: [KVM-RFC PATCH 2/2] kvm: use POLLHUP to close an irqfd instead of an explicit ioctl
Date: Tue, 02 Jun 2009 13:42:02 -0400 [thread overview]
Message-ID: <4A25646A.8030306@novell.com> (raw)
In-Reply-To: <alpine.DEB.1.10.0906021011390.12866@makko.or.mcafeemobile.com>
[-- Attachment #1: Type: text/plain, Size: 1537 bytes --]
Davide Libenzi wrote:
> On Tue, 2 Jun 2009, Gregory Haskins wrote:
>
>
>> @@ -64,12 +101,28 @@ irqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync, void *key)
>> {
>> struct _irqfd *irqfd = container_of(wait, struct _irqfd, wait);
>>
>> - /*
>> - * The wake_up is called with interrupts disabled. Therefore we need
>> - * to defer the IRQ injection until later since we need to acquire the
>> - * kvm->lock to do so.
>> - */
>> - schedule_work(&irqfd->work);
>> + switch ((unsigned long)key) {
>> + case POLLIN:
>> + /*
>> + * The POLLIN wake_up is called with interrupts disabled.
>> + * Therefore we need to defer the IRQ injection until later
>> + * since we need to acquire the kvm->lock to do so.
>> + */
>> + schedule_work(&irqfd->inject);
>> + break;
>> + case POLLHUP:
>> + /*
>> + * The POLLHUP is called unlocked, so it theoretically should
>> + * be safe to remove ourselves from the wqh
>> + */
>> + remove_wait_queue(irqfd->wqh, &irqfd->wait);
>> + flush_work(&irqfd->inject);
>> + irqfd_disconnect(irqfd);
>> +
>> + cleanup_srcu_struct(&irqfd->srcu);
>> + kfree(irqfd);
>> + break;
>> + }
>>
>
> Since "key" is an event *bitmap*, you better be treating it as such. Do
> not assume what eventfd delivers today (event bitmaps with only one bit
> set). So this better be like:
>
> if (key & POLLIN) {
> ...
> }
> if (key & POLLHUP) {
> ...
> }
>
>
> - Davide
>
>
>
Indeed. Thanks for catching that!
-Greg
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 266 bytes --]
next prev parent reply other threads:[~2009-06-02 17:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-02 15:15 [KVM-RFC PATCH 0/2] irqfd: use POLLHUP notification for close() Gregory Haskins
2009-06-02 15:15 ` [KVM-RFC PATCH 1/2] eventfd: send POLLHUP on f_ops->release Gregory Haskins
2009-06-02 15:15 ` [KVM-RFC PATCH 2/2] kvm: use POLLHUP to close an irqfd instead of an explicit ioctl Gregory Haskins
2009-06-02 17:16 ` Davide Libenzi
2009-06-02 17:42 ` Gregory Haskins [this message]
2009-06-02 18:02 ` Paul E. McKenney
2009-06-02 18:23 ` Gregory Haskins
2009-06-02 22:01 ` Paul E. McKenney
2009-06-03 1:53 ` Gregory Haskins
2009-06-03 15:04 ` Paul E. McKenney
2009-06-03 17:27 ` Gregory Haskins
2009-06-03 17:24 ` Davide Libenzi
2009-06-02 16:04 ` [KVM-RFC PATCH 0/2] irqfd: use POLLHUP notification for close() Michael S. Tsirkin
2009-06-02 16:14 ` Gregory Haskins
2009-06-02 16:20 ` Michael S. Tsirkin
2009-06-02 16:34 ` Gregory Haskins
2009-06-02 16:59 ` Michael S. Tsirkin
2009-06-02 17:02 ` Michael S. Tsirkin
2009-06-02 17:41 ` Gregory Haskins
2009-06-03 6:39 ` Michael S. Tsirkin
2009-06-03 11:34 ` Gregory Haskins
2009-06-04 10:25 ` Avi Kivity
2009-06-04 11:43 ` Gregory Haskins
2009-06-04 11:50 ` Avi Kivity
2009-06-04 11:52 ` Gregory Haskins
2009-06-04 12:02 ` 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=4A25646A.8030306@novell.com \
--to=ghaskins@novell.com \
--cc=avi@redhat.com \
--cc=davidel@xmailserver.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=paulmck@linux.vnet.ibm.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