From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gregory Haskins 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 Message-ID: <4A25646A.8030306@novell.com> References: <20090602151135.29746.91320.stgit@dev.haskins.net> <20090602151538.29746.40356.stgit@dev.haskins.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig9D1DE861ACDE5FDDBCD17FCF" Cc: kvm@vger.kernel.org, Linux Kernel Mailing List , avi@redhat.com, mst@redhat.com, paulmck@linux.vnet.ibm.com To: Davide Libenzi Return-path: Received: from victor.provo.novell.com ([137.65.250.26]:55127 "EHLO victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756477AbZFBRmD (ORCPT ); Tue, 2 Jun 2009 13:42:03 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig9D1DE861ACDE5FDDBCD17FCF Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Davide Libenzi wrote: > On Tue, 2 Jun 2009, Gregory Haskins wrote: > > =20 >> @@ -64,12 +101,28 @@ irqfd_wakeup(wait_queue_t *wait, unsigned mode, i= nt sync, void *key) >> { >> struct _irqfd *irqfd =3D container_of(wait, struct _irqfd, wait); >> =20 >> - /* >> - * The wake_up is called with interrupts disabled. Therefore we nee= d >> - * to defer the IRQ injection until later since we need to acquire t= he >> - * 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; >> + } >> =20 > > Since "key" is an event *bitmap*, you better be treating it as such. Do= =20 > not assume what eventfd delivers today (event bitmaps with only one bit= =20 > set). So this better be like: > > if (key & POLLIN) { > ... > } > if (key & POLLHUP) { > ... > } > > > - Davide > > > =20 Indeed. Thanks for catching that! -Greg --------------enig9D1DE861ACDE5FDDBCD17FCF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkolZGoACgkQlOSOBdgZUxm40wCcCC4XfV8fNcFhPeuRsMj3KyEm sKwAmgJ97SAp4krbB4aKRgQdvpZtsT7K =mSmg -----END PGP SIGNATURE----- --------------enig9D1DE861ACDE5FDDBCD17FCF--