Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1470610rwb; Fri, 19 Aug 2022 04:25:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR4kud1SkR0talcwHABdX993Z+o6tt9TFlqNrl+WMbA7UNMrN0bwClD0cm4F9iPaT3J9HKX1 X-Received: by 2002:a17:907:9484:b0:73c:37bb:c4d7 with SMTP id dm4-20020a170907948400b0073c37bbc4d7mr3427068ejc.748.1660908332957; Fri, 19 Aug 2022 04:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660908332; cv=none; d=google.com; s=arc-20160816; b=nDi7sMZB+pxQ3kssdYMa+nh3HwSNp8sAnik4mqmpei/loXKhEmd/b39GXjNhe6Yri7 MtVci4ThFOkJfSiAZJ7YWhthdZWYUa4x7Y4/TgnPlSAtxSwX/ZGm5v5mC7VNiDNEPheB JbRKW7PEyxWFiSMnxK7zp5NBNxs9zY9JoBHvzdh4JofQDHVMk0Z1IjAceVmd3w6c2ve2 xslenWBn0X/MgpuOBLLBdZ80xKtT/NcNaLLN9Two3u/cuBjKTec1yKTK8k6ak7aBcZYo 0jhkyGGFrg4j74L1VsUkL9Nc/Z2Pjf2DczzWcM5ymGypwcQ48rqh5kZYtSsy/SjtBP50 +iRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=NxuNxcep4aHatBFZSAQV+WS4/9uFINJz4pQN0UPNYNs=; b=QKcTspnCls7XsANKLloiG/CNaHhc/e+BuYxDSSPIbNgKWXb2wv7QXeRRB8rBZFS3VB B5pFiGUjbbhdXubdJq0oMyVcB79qnrkQnQ8tF30Qvyt+A/Qem9IQy0x+3TNG6yAyXCJf 9CEzs4h4UVZWTo4c2ccJM241T4jfZdbB/hQc7+vfGqDTNq13OL8A+jya5Zog6szFToHv TAcHRWRBMlIJgCEZawYPOJqCKwIFGi5N8gqPTIzht7YGOXDzBNYOGtjS+7x/BljaV/zx gs6/BWiIWAU6ZE+jT4k2jRDwQT6ADovTnsIv1CxiisHYISy3gy8YLJJHqpEpBGbFjkn1 PWcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a50cd92000000b0043de558914asi2773002edi.487.2022.08.19.04.25.07; Fri, 19 Aug 2022 04:25:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348562AbiHSLE1 (ORCPT + 99 others); Fri, 19 Aug 2022 07:04:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348528AbiHSLEP (ORCPT ); Fri, 19 Aug 2022 07:04:15 -0400 Received: from smtp237.sjtu.edu.cn (smtp237.sjtu.edu.cn [202.120.2.237]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ABE9B6D72; Fri, 19 Aug 2022 04:04:03 -0700 (PDT) Received: from mta91.sjtu.edu.cn (unknown [10.118.0.91]) by smtp237.sjtu.edu.cn (Postfix) with ESMTPS id 84AD210087D60; Fri, 19 Aug 2022 19:04:00 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mta91.sjtu.edu.cn (Postfix) with ESMTP id 1330937C83F; Fri, 19 Aug 2022 19:04:00 +0800 (CST) X-Virus-Scanned: amavisd-new at Received: from mta91.sjtu.edu.cn ([127.0.0.1]) by localhost (mta91.sjtu.edu.cn [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fCjb5bGfrY6w; Fri, 19 Aug 2022 19:04:00 +0800 (CST) Received: from mstore105.sjtu.edu.cn (mstore101.sjtu.edu.cn [10.118.0.105]) by mta91.sjtu.edu.cn (Postfix) with ESMTP id D5BC437C83E; Fri, 19 Aug 2022 19:03:59 +0800 (CST) Date: Fri, 19 Aug 2022 19:03:59 +0800 (CST) From: Guo Zhi To: eperezma Cc: jasowang , sgarzare , Michael Tsirkin , netdev , linux-kernel , kvm list , virtualization Message-ID: <1521324274.8446358.1660907039791.JavaMail.zimbra@sjtu.edu.cn> In-Reply-To: References: <20220817135718.2553-1-qtxuning1999@sjtu.edu.cn> <20220817135718.2553-4-qtxuning1999@sjtu.edu.cn> Subject: Re: [RFC v2 3/7] vsock: batch buffers in tx MIME-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit X-Originating-IP: [113.222.45.197] X-Mailer: Zimbra 8.8.15_GA_4308 (ZimbraWebClient - GC103 (Mac)/8.8.15_GA_3928) Thread-Topic: vsock: batch buffers in tx Thread-Index: pT3n1m/+8XxooxgOVsVDTRQKbP5O4Q== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- Original Message ----- > From: "eperezma" > To: "Guo Zhi" > Cc: "jasowang" , "sgarzare" , "Michael Tsirkin" , "netdev" > , "linux-kernel" , "kvm list" , > "virtualization" > Sent: Thursday, August 18, 2022 2:19:29 PM > Subject: Re: [RFC v2 3/7] vsock: batch buffers in tx > On Wed, Aug 17, 2022 at 3:58 PM Guo Zhi wrote: >> >> Vsock uses buffers in order, and for tx driver doesn't have to >> know the length of the buffer. So we can do a batch for vsock if >> in order negotiated, only write one used ring for a batch of buffers >> >> Signed-off-by: Guo Zhi >> --- >> drivers/vhost/vsock.c | 9 ++++++++- >> 1 file changed, 8 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c >> index 368330417bde..b0108009c39a 100644 >> --- a/drivers/vhost/vsock.c >> +++ b/drivers/vhost/vsock.c >> @@ -500,6 +500,7 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work >> *work) >> int head, pkts = 0, total_len = 0; >> unsigned int out, in; >> bool added = false; >> + int last_head = -1; >> >> mutex_lock(&vq->mutex); >> >> @@ -551,10 +552,16 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work >> *work) >> else >> virtio_transport_free_pkt(pkt); >> >> - vhost_add_used(vq, head, 0); >> + if (!vhost_has_feature(vq, VIRTIO_F_IN_ORDER)) >> + vhost_add_used(vq, head, 0); >> + else >> + last_head = head; >> added = true; >> } while(likely(!vhost_exceeds_weight(vq, ++pkts, total_len))); >> >> + /* If in order feature negotiaged, we can do a batch to increase >> performance */ >> + if (vhost_has_feature(vq, VIRTIO_F_IN_ORDER) && last_head != -1) >> + vhost_add_used(vq, last_head, 0); > > Expanding my previous mail on patch 1, you can also use this in vsock > tx queue code. This way, no modifications to vhost.c functions are > needed. > > Thanks! As replied in patch 1, no modification to vhost is not feasible. Thanks! > >> no_more_replies: >> if (added) >> vhost_signal(&vsock->dev, vq); >> -- >> 2.17.1 >>