From patchwork Tue May 26 16:42:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 26053 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4QGi1hc001311 for ; Tue, 26 May 2009 16:44:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755176AbZEZQm7 (ORCPT ); Tue, 26 May 2009 12:42:59 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756320AbZEZQm6 (ORCPT ); Tue, 26 May 2009 12:42:58 -0400 Received: from mx2.redhat.com ([66.187.237.31]:47054 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756630AbZEZQm5 (ORCPT ); Tue, 26 May 2009 12:42:57 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4QGgxBQ020245; Tue, 26 May 2009 12:42:59 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4QGgwet002326; Tue, 26 May 2009 12:42:58 -0400 Received: from redhat.com (dhcp-0-223.tlv.redhat.com [10.35.0.223]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n4QGgtUN031392; Tue, 26 May 2009 12:42:56 -0400 Date: Tue, 26 May 2009 19:42:01 +0300 From: "Michael S. Tsirkin" To: Gregory Haskins Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, avi@redhat.com, davidel@xmailserver.org, mtosatti@redhat.com Subject: Re: [KVM PATCH v10] kvm: add support for irqfd Message-ID: <20090526164201.GD9842@redhat.com> References: <20090520142234.22285.72274.stgit@dev.haskins.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20090520142234.22285.72274.stgit@dev.haskins.net> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Wed, May 20, 2009 at 10:30:49AM -0400, Gregory Haskins wrote: > +static int > +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); > + > + return 0; > +} This schedule_work is there just to work around the spinlock in eventfd_signal, which we don't really need. Isn't this right? And this is on each interrupt. Seems like a pity. How about a flag in eventfd that would convert it from waking up someone to a plain function call? Davide, could we add something like diff --git a/fs/eventfd.c b/fs/eventfd.c index 2a701d5..8bfa308 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -29,6 +29,7 @@ struct eventfd_ctx { */ __u64 count; unsigned int flags; + int nolock; }; /* @@ -46,6 +47,12 @@ int eventfd_signal(struct file *file, int n) if (n < 0) return -EINVAL; + if (ctx->nolock) { + /* Whoever set nolock + better set wqh.func as well. */ + ctx->wqh.func(&ctx->wqh, 0, 0, NULL); + return 0; + } spin_lock_irqsave(&ctx->wqh.lock, flags); if (ULLONG_MAX - ctx->count < n) n = (int) (ULLONG_MAX - ctx->count);