Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5202003rwb; Tue, 6 Sep 2022 21:39:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR77G6fGb9zKunylL/QcNIhJIX54u+hRQWGwC5nM895FeMmwRTb860nPaVUuuov2vqzPetNX X-Received: by 2002:a17:903:41d0:b0:174:d8e0:b0f1 with SMTP id u16-20020a17090341d000b00174d8e0b0f1mr1909221ple.74.1662525556969; Tue, 06 Sep 2022 21:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662525556; cv=none; d=google.com; s=arc-20160816; b=l1aggjRbuFdQZ556Ga1ZwfrJz6nvEc4qkTOxw7sF9B+M3YpFrcXgZ+tu8pBssZrU0j xYRyrDay7fQkcoTWD5Ca12Qhu37+XTLzCVpeh4J4zkXfUgyJJCfYxm6skglKmgboa42x KbM3b+FkPKDyX9aauGu3dSf38CZEdEez1SlYuw5IE5M+xJABt6UPKo9ksUCIQIG1gMbX RLGG0+d4zjp+TK3sGT7DUi2mDuix89HlBPMo2wAoE95CDn0w71xJZETjntPAcB0bFrr1 wkxWraoMVxobDJYlFrv3JsyyOQy9vM4DNgz+4RIbX9GCfiCIZSakw8bx6bQCjwBBssqe sy2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=4j6Q+BCgruPfdfNoIE3/wZJYX17HQyjtjOota9ARPcM=; b=zGXEGswB/T7VVELJXMiOvDwM1qkB0AWk/Iv/6w9o7wwgqsmRZR7LbVNPjhIK9poZan UX5/vRza/AsGA1PbN7TpgssIZuOrayqmI0dI/p6BDU8weZvo3suNP9aM54s43UYjR4AU PV855wp2KM2kCaj3WZojf7I3rxsGt1RvZGWPd1gP+FsfnMkDos9KMq1Oy3qtb0FQ6d70 oelefH11qDxtPw3tdFmHRNsF+rM90nvEarsr74EAtIIePEj8l/2E33H+uxndgD0n8J2D UPaQ8+7YnAAe68sc2Ca/5O+xt14yCpvqQtrEJ3XJSuUwEceIKcEEoz+zad+t2+epKL5u VzCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="V+KAm/as"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h190-20020a6383c7000000b004301e6b2e94si10850646pge.602.2022.09.06.21.39.05; Tue, 06 Sep 2022 21:39:16 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="V+KAm/as"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbiIGE2K (ORCPT + 99 others); Wed, 7 Sep 2022 00:28:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbiIGE17 (ORCPT ); Wed, 7 Sep 2022 00:27:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AFD9901BC for ; Tue, 6 Sep 2022 21:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662524876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4j6Q+BCgruPfdfNoIE3/wZJYX17HQyjtjOota9ARPcM=; b=V+KAm/asuIDImGIgApI9YQgU4hIKkKJV98/wMi18UBxbIDtIt7vdjJKOPExAQRmzk0hSO/ W83sxJ//sjymxv+V25jnA+sEBG9uf9cU5Ig0V4BnNe0Tpd772avFHM5ufvCNGMLeurI6q9 WWicbQrQNla8dV2jZC7B/tvNbfMRirk= Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-333-jnfOZbulObC3EQ0GsUd_zQ-1; Wed, 07 Sep 2022 00:27:55 -0400 X-MC-Unique: jnfOZbulObC3EQ0GsUd_zQ-1 Received: by mail-pf1-f199.google.com with SMTP id a21-20020a62bd15000000b005360da6b25aso6934988pff.23 for ; Tue, 06 Sep 2022 21:27:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=4j6Q+BCgruPfdfNoIE3/wZJYX17HQyjtjOota9ARPcM=; b=JOVzhRb0eCUgZqKyP7ga+LSBzKg1k4rRIT/QPR3iAEM0VQkUeDqx6VjtKpSbgkj7PG c/NHLNDqSAKxxnOKVw8lXfsosTXgKnzkisgMnzH+YeugQOUZHp3hiWRpvcElO8j79sxY VMvJo2X1OOIhLh138miPzeTufhQM07EuX0+M9nAKBz8wTuM5rAabEb64I4g8MUvVpawo 4PxEE3ZnNlzhOGTvLTEsjDMVgpXhhRw+fhOs++M8D4aBGm1Kfq26ThGA3WsIumT3GTdc ts194+cfvQWCn8Y8wiYI42LvGdRAo4oN3i9WbSogAXUH8E133BOiS/O2lp6cwr6EyI7s gwwA== X-Gm-Message-State: ACgBeo0W2sEHlfl8CaKOiZTWI6c9w/uIRbX8rlRb7fOuhunHGnwUBQFK qRi6zXCQpEj98A2AIqh4R6zh1X8JWNy5Mvlhs78/LShLcoyQ4xG4r2GWIobslxKOHSfOfXnTUh3 gSylqf9VU6hMQUf97plWVim75 X-Received: by 2002:a05:6a00:ad1:b0:530:2cb7:84de with SMTP id c17-20020a056a000ad100b005302cb784demr1905273pfl.3.1662524874247; Tue, 06 Sep 2022 21:27:54 -0700 (PDT) X-Received: by 2002:a05:6a00:ad1:b0:530:2cb7:84de with SMTP id c17-20020a056a000ad100b005302cb784demr1905253pfl.3.1662524873918; Tue, 06 Sep 2022 21:27:53 -0700 (PDT) Received: from [10.72.13.171] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id u1-20020a632341000000b0042a6dde1d66sm7922152pgm.43.2022.09.06.21.27.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Sep 2022 21:27:53 -0700 (PDT) Message-ID: Date: Wed, 7 Sep 2022 12:27:40 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [RFC v3 3/7] vsock: batch buffers in tx Content-Language: en-US To: Guo Zhi , eperezma@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 References: <20220901055434.824-1-qtxuning1999@sjtu.edu.cn> <20220901055434.824-4-qtxuning1999@sjtu.edu.cn> From: Jason Wang In-Reply-To: <20220901055434.824-4-qtxuning1999@sjtu.edu.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,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 在 2022/9/1 13:54, Guo Zhi 写道: > 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 | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c > index 368330417bde..e08fbbb5439e 100644 > --- a/drivers/vhost/vsock.c > +++ b/drivers/vhost/vsock.c > @@ -497,7 +497,7 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) > struct vhost_vsock *vsock = container_of(vq->dev, struct vhost_vsock, > dev); > struct virtio_vsock_pkt *pkt; > - int head, pkts = 0, total_len = 0; > + int head, pkts = 0, total_len = 0, add = 0; > unsigned int out, in; > bool added = false; > > @@ -551,10 +551,18 @@ 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); I'd do this step by step. 1) switch to use vhost_add_used_n() for vsock, less copy_to_user() better performance 2) do in-order on top > + } else { > + vq->heads[add].id = head; > + vq->heads[add++].len = 0; How can we guarantee that we are in the boundary of the heads array? Btw in the case of in-order we don't need to record the heads, instead we just need to know the head of the last buffer, it reduces the stress on the cache. Thanks > + } > 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) && added) > + vhost_add_used_n(vq, vq->heads, add); > no_more_replies: > if (added) > vhost_signal(&vsock->dev, vq);