From patchwork Wed Aug 17 13:57:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Zhi X-Patchwork-Id: 12945921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 328B6C3F6B0 for ; Wed, 17 Aug 2022 13:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239720AbiHQN6e (ORCPT ); Wed, 17 Aug 2022 09:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239788AbiHQN62 (ORCPT ); Wed, 17 Aug 2022 09:58:28 -0400 Received: from smtp236.sjtu.edu.cn (smtp236.sjtu.edu.cn [202.120.2.236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE332240BB; Wed, 17 Aug 2022 06:58:19 -0700 (PDT) Received: from proxy02.sjtu.edu.cn (smtp188.sjtu.edu.cn [202.120.2.188]) by smtp236.sjtu.edu.cn (Postfix) with ESMTPS id 7CE131008B38F; Wed, 17 Aug 2022 21:58:17 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by proxy02.sjtu.edu.cn (Postfix) with ESMTP id D36002009BEAD; Wed, 17 Aug 2022 21:58:10 +0800 (CST) X-Virus-Scanned: amavisd-new at Received: from proxy02.sjtu.edu.cn ([127.0.0.1]) by localhost (proxy02.sjtu.edu.cn [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id BeLQLT-bhQHC; Wed, 17 Aug 2022 21:58:10 +0800 (CST) Received: from localhost.localdomain (unknown [202.120.40.82]) (Authenticated sender: qtxuning1999@sjtu.edu.cn) by proxy02.sjtu.edu.cn (Postfix) with ESMTPSA id 36ED6200BFDA8; Wed, 17 Aug 2022 21:57:56 +0800 (CST) From: Guo Zhi To: eperezma@redhat.com, jasowang@redhat.com, sgarzare@redhat.com, mst@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Guo Zhi Subject: [RFC v2 3/7] vsock: batch buffers in tx Date: Wed, 17 Aug 2022 21:57:14 +0800 Message-Id: <20220817135718.2553-4-qtxuning1999@sjtu.edu.cn> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220817135718.2553-1-qtxuning1999@sjtu.edu.cn> References: <20220817135718.2553-1-qtxuning1999@sjtu.edu.cn> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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); no_more_replies: if (added) vhost_signal(&vsock->dev, vq);