From patchwork Mon Jul 6 14:56:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Haskins X-Patchwork-Id: 34253 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 n66EuUsI019171 for ; Mon, 6 Jul 2009 14:56:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754978AbZGFO4Y (ORCPT ); Mon, 6 Jul 2009 10:56:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754829AbZGFO4Y (ORCPT ); Mon, 6 Jul 2009 10:56:24 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:33338 "EHLO victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754145AbZGFO4X (ORCPT ); Mon, 6 Jul 2009 10:56:23 -0400 Received: from Greg.laurelwood.net (prv-ext-foundry1.gns.novell.com [137.65.251.240]) by victor.provo.novell.com with ESMTP (TLS encrypted); Mon, 06 Jul 2009 08:56:07 -0600 Message-ID: <4A521082.40209@novell.com> Date: Mon, 06 Jul 2009 10:56:02 -0400 From: Gregory Haskins User-Agent: Thunderbird 2.0.0.22 (Macintosh/20090605) MIME-Version: 1.0 To: Avi Kivity CC: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, mst@redhat.com, davidel@xmailserver.org Subject: Re: [KVM PATCH v9 0/5] irqfd fixes and enhancements References: <20090702153454.20186.99191.stgit@dev.haskins.net> <4A4CD729.6050300@redhat.com> <4A50723E.6030305@redhat.com> In-Reply-To: <4A50723E.6030305@redhat.com> X-Enigmail-Version: 0.95.7 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Avi Kivity wrote: > On 07/02/2009 06:50 PM, Avi Kivity wrote: >> On 07/02/2009 06:37 PM, Gregory Haskins wrote: >>> (Applies to kvm.git/master:1f9050fd) >>> >>> The following is the latest attempt to fix the races in >>> irqfd/eventfd, as >>> well as restore DEASSIGN support. For more details, please read the >>> patch >>> headers. >>> >>> As always, this series has been tested against the kvm-eventfd unit >>> test >>> and everything appears to be functioning properly. You can download >>> this >>> test here: >> >> Applied, thanks. >> > > ... and unapplied. There's a refcounting mismatch in irqfd_cleanup: a > reference is taken for each irqfd, but dropped for each guest. This > causes an oops if a guest with no irqfds is created and destroyed: I was able to reproduce this issue. The problem turned out to be that I inadvertently always did a flush_workqueue(), even if the work-queue was never initialized. The following interdiff applied to the reverted patch has been confirmed to fix the issue: ------------------- --------------------- You can pick up this fix folded into the original v9:5/5 patch here: git pull git://git.kernel.org/pub/scm/linux/kernel/git/ghaskins/linux-2.6-hacks.git for-avi Sorry for the sloppy patch in v9. :( Will strive to do better next time. Regards, -Greg diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index fcc3469..52b0e04 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -318,6 +318,9 @@ kvm_irqfd_deassign(struct kvm *kvm, int fd, int gsi) struct _irqfd *irqfd, *tmp; struct eventfd_ctx *eventfd; + if (!kvm->irqfds.init) + return -ENOENT; + eventfd = eventfd_ctx_fdget(fd); if (IS_ERR(eventfd)) return PTR_ERR(eventfd); @@ -360,6 +363,9 @@ kvm_irqfd_release(struct kvm *kvm) { struct _irqfd *irqfd, *tmp; + if (!kvm->irqfds.init) + return; + spin_lock_irq(&kvm->irqfds.lock); list_for_each_entry_safe(irqfd, tmp, &kvm->irqfds.items, list)