From patchwork Sat Apr 19 04:08:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 340462 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2D0E61400FC for ; Sat, 19 Apr 2014 14:08:46 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751206AbaDSEIU (ORCPT ); Sat, 19 Apr 2014 00:08:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46090 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751191AbaDSEIS (ORCPT ); Sat, 19 Apr 2014 00:08:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3J48Hoi016238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Apr 2014 00:08:17 -0400 Received: from localhost (vpn1-114-68.nay.redhat.com [10.66.114.68]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3J48Fjp001142; Sat, 19 Apr 2014 00:08:16 -0400 Date: Sat, 19 Apr 2014 12:08:15 +0800 From: Amos Kong To: "MichaelS.Tsirkin" , virtualization@lists.linux-foundation.org Cc: jasowang@redhat.com, netdev@vger.kernel.org Subject: RFC: sharing config interrupt between virtio devices for saving MSI Message-ID: <20140419040815.GB4681@amosk.info> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140330111427.GD24476@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi all, I'm working on this item in Upstream Networking todolist: | - Sharing config interrupts | Support more devices by sharing a single msi vector | between multiple virtio devices. | (Applies to virtio-blk too). I have this solution here, and only have draft patches of Solution 1 & 2, let's discuss if solution 3 is feasible. * We should not introduce perf regression in this change * little effect is acceptable because we are _sharing_ interrupt Solution 1: static void vp_free_vectors(struct virtio_device *vdev) ========== share one LSI interrupt for configuration change of all virtio devices. Draft patch: share_lsi_for_all_config.patch Solution 2: ========== share one MSI interrupt for configuration change of all virtio devices. Draft patch: share_msix_for_all_config.patch Solution 3: ========== dynamic adjust interrupt policy when device is added or removed Current: ------- - try to allocate a MSI to device's config - try to allocate a MSI for each vq - share one MSI for all vqs of one device - share one LSI for config & vqs of one device additional dynamic policies: --------------------------- - if there is no enough MSI, adjust interrupt allocation for returning some MSI - try to find a device that allocated one MSI for each vq, change it to share one MSI for saving the MSI - try to share one MSI for config of all virtio_pci devices - try to share one LSI for config of all devices - if device is removed, try to re-allocate freed MSI to existed devices, if they aren't in best status (one MSI for config, one MSI for each vq) - if config of all devices is sharing one LSI, try to upgrade it to MSI - if config of all devices is sharing one MSI, try to allocate one MSI for configuration change of each device - try to find a device that is sharing one MSI for all vqs, try to allocate one MSI for each vq BTW, I saw we still notify all vqs even VIRTIO_PCI_ISR_CONFIG bit of isr is set, is it necessary? diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index 101db3f..176aabc 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c @@ -259,9 +259,9 @@ static irqreturn_t vp_interrupt(int irq, void *opaque) /* Configuration change? Tell driver if it wants to know. */ if (isr & VIRTIO_PCI_ISR_CONFIG) - vp_config_changed(irq, opaque); - - return vp_vring_interrupt(irq, opaque); + return vp_config_changed(irq, opaque); + else + return vp_vring_interrupt(irq, opaque); }