From patchwork Fri Jun 17 22:28:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 892642 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5HMUnRA021503 for ; Fri, 17 Jun 2011 22:30:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758735Ab1FQWaq (ORCPT ); Fri, 17 Jun 2011 18:30:46 -0400 Received: from mail-qy0-f174.google.com ([209.85.216.174]:46119 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755449Ab1FQWap (ORCPT ); Fri, 17 Jun 2011 18:30:45 -0400 Received: by qyk29 with SMTP id 29so709317qyk.19 for ; Fri, 17 Jun 2011 15:30:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=ZAiIvCv/zdDCbE1MB3OicltgBpV9SxpVMdvU6t6+V3Q=; b=RGwlz87VWkYzSEuM8Yize+mfqSsXscAaG/vnoKqz8tWBu3WO3Fs4EsfCHcq6IHqS87 wJ36OJS2yl1ijx/GqxVb2FrQUCvGZyN9EIA2ZeHAqeTiwWpJMJbTPVNBcvVYNszBQbni VH7ml3Kpx15n/UvtxN1IHaZvfPdR3P9+zaaQk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=r7F0x7aQ4n7t0cPj2/y2efAsIhpT5BuyXafnxhUIrW/wyqgZsp92IVID4CPHGpOWzs gk1b7MjnfCsCxiQ+k5tzyf9sa2DqseZuCM4poUuyvZLb0Ecg9NwUUi9waczm1TLqrC77 UwOBqGPKw8afIDpyP+xEBqfEf+HAjq+G9MzY8= Received: by 10.229.225.208 with SMTP id it16mr2118394qcb.182.1308349844340; Fri, 17 Jun 2011 15:30:44 -0700 (PDT) Received: from localhost.localdomain (c-71-232-157-243.hsd1.ma.comcast.net [71.232.157.243]) by mx.google.com with ESMTPS id e18sm1285300qcs.41.2011.06.17.15.30.42 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Jun 2011 15:30:43 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, Sasha Levin Subject: [PATCH] kvm tools: Use ioeventfd in virtio-9p Date: Fri, 17 Jun 2011 18:28:25 -0400 Message-Id: <1308349705-23062-1-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 17 Jun 2011 22:30:50 +0000 (UTC) Use ioeventfd to receive virt queue notifications within virtio-9p. This should prevent exits on 9p commands. Signed-off-by: Sasha Levin --- tools/kvm/virtio/9p.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c index d4263d2..3158cbc 100644 --- a/tools/kvm/virtio/9p.c +++ b/tools/kvm/virtio/9p.c @@ -8,6 +8,7 @@ #include "kvm/pci.h" #include "kvm/threadpool.h" #include "kvm/irq.h" +#include "kvm/ioeventfd.h" #include #include @@ -605,12 +606,20 @@ static void virtio_p9_do_io(struct kvm *kvm, void *param) } } +static void ioevent_callback(struct kvm *kvm, void *param) +{ + struct p9_dev_job *job = param; + + thread_pool__do_job(job->job_id); +} + static bool virtio_p9_pci_io_out(struct ioport *ioport, struct kvm *kvm, u16 port, void *data, int size, u32 count) { unsigned long offset; bool ret = true; struct p9_dev *p9dev; + struct ioevent ioevent; p9dev = ioport->priv; offset = port - p9dev->base_addr; @@ -637,6 +646,19 @@ static bool virtio_p9_pci_io_out(struct ioport *ioport, struct kvm *kvm, .p9dev = p9dev, }; job->job_id = thread_pool__add_job(kvm, virtio_p9_do_io, job); + + ioevent = (struct ioevent) { + .io_addr = p9dev->base_addr + VIRTIO_PCI_QUEUE_NOTIFY, + .io_len = sizeof(u16), + .fn = ioevent_callback, + .datamatch = p9dev->queue_selector, + .fn_ptr = &p9dev->jobs[p9dev->queue_selector], + .fn_kvm = kvm, + .fd = eventfd(0, 0), + }; + + ioeventfd__add_event(&ioevent); + break; } case VIRTIO_PCI_QUEUE_SEL: @@ -644,6 +666,7 @@ static bool virtio_p9_pci_io_out(struct ioport *ioport, struct kvm *kvm, break; case VIRTIO_PCI_QUEUE_NOTIFY: { u16 queue_index; + queue_index = ioport__read16(data); thread_pool__do_job(p9dev->jobs[queue_index].job_id); break;