From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 740A9C4CECE for ; Sun, 13 Oct 2019 11:42:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5398D207FF for ; Sun, 13 Oct 2019 11:42:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729356AbfJMLmZ (ORCPT ); Sun, 13 Oct 2019 07:42:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52006 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729315AbfJMLmX (ORCPT ); Sun, 13 Oct 2019 07:42:23 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00F6085546 for ; Sun, 13 Oct 2019 11:42:23 +0000 (UTC) Received: by mail-qt1-f199.google.com with SMTP id h20so14846804qto.7 for ; Sun, 13 Oct 2019 04:42:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3CYitd93iDHtPl2boSl3Eyofj0PvtzXYhyw7uXbmPmo=; b=M26avYoKXLsd+hBly7ohOdYmrRR/O03y+X925qO1PhH1GcdBkYserc6+WaZTaRbPr6 2s9PXqjGGF/xyinRy19V5vPZPRDzNPuWIFQ753sdiWjp96C9MqBq2C0jb4HmV1pJmXNy 1vZof/pfKxi9jPw4GeMLvEWkO7dBYoO73alKL7IQzEsES74R5UEx6TpQq8vWQSZAFDp5 t3ZxBTFg5f1EiKysLDyHQTmLlEfn+k9qWovmqUv5baMT+p0xosFHf87iSj1uif2g2m5G qtNA3CSk8aqczPf4m5RQXHNQoCG4H0JO6Fo3x4wVq78r/vVPdfkEWY3ti1Te+sbs7BOA cQlA== X-Gm-Message-State: APjAAAUYQPBJYi7X8kEWygQoXGt9ANk/tkBoAGz5uwMan9H5IgIFzznm Ik2IgbUPgmaKj3WGIlgNE8ee8RIw3D+OfkC7Zrc2wS/9T/kVqDWZARFn2GWdWTtweQCMij1IPUr lk5hHlSuAVwnBd1H+Jb9bc3a/ X-Received: by 2002:aed:35a7:: with SMTP id c36mr27529126qte.200.1570966942034; Sun, 13 Oct 2019 04:42:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4LMbkCfrdcYhEI8OeObeDJu5LuXPSdwMN3Yqhx4D0fr8hIGkuB2w8tDSXR79T7N+Kluf9Qg== X-Received: by 2002:aed:35a7:: with SMTP id c36mr27529117qte.200.1570966941851; Sun, 13 Oct 2019 04:42:21 -0700 (PDT) Received: from redhat.com (bzq-79-176-10-77.red.bezeqint.net. [79.176.10.77]) by smtp.gmail.com with ESMTPSA id e42sm10005404qte.26.2019.10.13.04.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2019 04:42:21 -0700 (PDT) Date: Sun, 13 Oct 2019 07:42:17 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Jason Wang Subject: [PATCH RFC v4 4/5] vhost/net: add an option to test new code Message-ID: <20191013113940.2863-5-mst@redhat.com> References: <20191013113940.2863-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191013113940.2863-1-mst@redhat.com> X-Mailer: git-send-email 2.22.0.678.g13338e74b8 X-Mutt-Fcc: =sent Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a writeable module parameter that tests the new code. Note: no effort was made to ensure things work correctly if the parameter is changed while the device is open. Make sure to close the device before changing its value. Signed-off-by: Michael S. Tsirkin --- drivers/vhost/net.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 1a2dd53caade..122b666ec1f2 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -35,6 +35,9 @@ #include "vhost.h" +static int newcode = 0; +module_param(newcode, int, 0644); + static int experimental_zcopytx = 0; module_param(experimental_zcopytx, int, 0444); MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;" @@ -565,8 +568,14 @@ static int vhost_net_tx_get_vq_desc(struct vhost_net *net, struct vhost_virtqueue *rvq = &rnvq->vq; struct vhost_virtqueue *tvq = &tnvq->vq; - int r = vhost_get_vq_desc(tvq, tvq->iov, ARRAY_SIZE(tvq->iov), - out_num, in_num, NULL, NULL); + int r; + + if (newcode) + r = vhost_get_vq_desc_batch(tvq, tvq->iov, ARRAY_SIZE(tvq->iov), + out_num, in_num, NULL, NULL); + else + r = vhost_get_vq_desc(tvq, tvq->iov, ARRAY_SIZE(tvq->iov), + out_num, in_num, NULL, NULL); if (r == tvq->num && tvq->busyloop_timeout) { /* Flush batched packets first */ @@ -575,8 +584,12 @@ static int vhost_net_tx_get_vq_desc(struct vhost_net *net, vhost_net_busy_poll(net, rvq, tvq, busyloop_intr, false); - r = vhost_get_vq_desc(tvq, tvq->iov, ARRAY_SIZE(tvq->iov), - out_num, in_num, NULL, NULL); + if (newcode) + r = vhost_get_vq_desc_batch(tvq, tvq->iov, ARRAY_SIZE(tvq->iov), + out_num, in_num, NULL, NULL); + else + r = vhost_get_vq_desc(tvq, tvq->iov, ARRAY_SIZE(tvq->iov), + out_num, in_num, NULL, NULL); } return r; @@ -1046,9 +1059,14 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, r = -ENOBUFS; goto err; } - r = vhost_get_vq_desc(vq, vq->iov + seg, - ARRAY_SIZE(vq->iov) - seg, &out, - &in, log, log_num); + if (newcode) + r = vhost_get_vq_desc_batch(vq, vq->iov + seg, + ARRAY_SIZE(vq->iov) - seg, &out, + &in, log, log_num); + else + r = vhost_get_vq_desc(vq, vq->iov + seg, + ARRAY_SIZE(vq->iov) - seg, &out, + &in, log, log_num); if (unlikely(r < 0)) goto err; -- MST