From patchwork Wed Feb 13 14:51:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 10810093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B5A2139A for ; Wed, 13 Feb 2019 14:53:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A06F2D63D for ; Wed, 13 Feb 2019 14:53:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 484AB2D652; Wed, 13 Feb 2019 14:53:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE5A82D62C for ; Wed, 13 Feb 2019 14:53:09 +0000 (UTC) Received: from localhost ([127.0.0.1]:58037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtvuP-0004VW-0m for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Feb 2019 09:53:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtvst-0003MO-2r for qemu-devel@nongnu.org; Wed, 13 Feb 2019 09:51:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtvsq-0007h8-Ug for qemu-devel@nongnu.org; Wed, 13 Feb 2019 09:51:34 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35225) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtvso-0007Yu-U5 for qemu-devel@nongnu.org; Wed, 13 Feb 2019 09:51:31 -0500 Received: by mail-wm1-x343.google.com with SMTP id t200so2734029wmt.0 for ; Wed, 13 Feb 2019 06:51:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=KYhVMytvJS9pR4WoPs1zxZ/26hFqkdO43UG1tCRLcK0=; b=PMxFuIeodJioh8YZGGde0BELUL7HGL/iQy12bzwf6wqVfnb6WYmFzOlwhfwTpHImlo 56qDr2BNxBIFnD88goC/xi8HgqoDTqqGzSILmhk3+IMzLqMEGZ0hRQFQO/p9KWSQ0OGZ EWA9UcUBALFC7869r3mMTXnjb8e8NlRvmXs9yxdWO5gfRxAZuGLJ90Exs5XzL9UTBUli Ij6a19VU20VAHy0s9CcqR0Pe3AFeWCIwbxNPo2Z16Q1y67GfJiNLwCL0YfrextUMOpTT V0ssb68oplc2l0EKw0OCRYdP0s9us/21uy/+YzsxfS3BTlLsoPt0qSvjBKWql1H6jHvr Im6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=KYhVMytvJS9pR4WoPs1zxZ/26hFqkdO43UG1tCRLcK0=; b=b0Wj8KJvvlHchbSEiZD1W8jUx1uwAEvlQ5j6uo8SDlvfquIXGEQejXkCy7qRSL07Ng xAhx1Q4IMuvhqqc8daYW4vCkjsCeR1OqcGmtq70SuBkq8majmj/eVnbsx5syNf/Jefvz WgIU4p7tTjjQgWrG6QViMktX/T1vKwUwBtnwnHwL/hNAZKZM6VA7e1aDozLnkuYIoM+U GNv32L0VEu9DZY8eeCSWpHzMUbLKWFs02ameqVp7/y9ULiHdqMYxcdVUNuhf/jIigah5 39+bAQL5APqfJvrGnX/HoGo8M0eet+1frqNKHiYt9wMiHTShQmL4IuCDIeWj6MpNibu8 ClCw== X-Gm-Message-State: AHQUAubc9uD6E73K9Tqmijb9IJpxm7cVsMGT1xPIR6xuCwLe2b/I/9Kv 4QQH60Wc7CwYPRWcpsalIjlC+k1X/R8= X-Google-Smtp-Source: AHgI3Ib+4nTixd0Q1BpVPWsrkWl9nzGg9COZqf0O6cgJASZJs+9kzM4gb/epAOV6K6+U4rh54bcHog== X-Received: by 2002:a7b:c7c1:: with SMTP id z1mr597490wmk.77.1550069483032; Wed, 13 Feb 2019 06:51:23 -0800 (PST) Received: from f2.Home (bzq-79-183-30-103.red.bezeqint.net. [79.183.30.103]) by smtp.gmail.com with ESMTPSA id x21sm7340754wmi.28.2019.02.13.06.51.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 06:51:22 -0800 (PST) From: Yuri Benditovich To: qemu-devel@nongnu.org, Jason Wang , "Michael S . Tsirkin" , yan@daynix.com Date: Wed, 13 Feb 2019 16:51:16 +0200 Message-Id: <20190213145116.20654-1-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH] virtio-net: do not start queues that are not enabled by the guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP https://bugzilla.redhat.com/show_bug.cgi?id=1608226 On startup/link-up in multiqueue configuration the virtio-net tries to starts all the queues, including those that the guest will not enable by VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET. If the guest driver does not allocate queues that it will not use (for example, Windows driver does not) and number of actually used queues is less that maximal number supported by the device, this causes vhost_net_start to fail and actually disables vhost for all the queues, reducing the performance. Current commit fixes this: initially only first queue is started, upon VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET started all the queues requested by the guest. Signed-off-by: Yuri Benditovich --- hw/net/virtio-net.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3f319ef723..d3b1ac6d3a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -174,7 +174,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) { VirtIODevice *vdev = VIRTIO_DEVICE(n); NetClientState *nc = qemu_get_queue(n->nic); - int queues = n->multiqueue ? n->max_queues : 1; + int queues = n->multiqueue ? n->curr_queues : 1; if (!get_vhost_net(nc->peer)) { return; @@ -1016,9 +1016,12 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd, return VIRTIO_NET_ERR; } - n->curr_queues = queues; /* stop the backend before changing the number of queues to avoid handling a * disabled queue */ + virtio_net_set_status(vdev, 0); + + n->curr_queues = queues; + virtio_net_set_status(vdev, vdev->status); virtio_net_set_queues(n);