Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp312959rwe; Thu, 25 Aug 2022 00:10:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR77IqhXWLY95WG0pJbtyF/1VkVf4xIpf30TteUwLqz+VvyIUFrG5B8GLBTmbCvkZHunjV0A X-Received: by 2002:a05:6a00:26ca:b0:536:d168:fa59 with SMTP id p10-20020a056a0026ca00b00536d168fa59mr2592606pfw.85.1661411453191; Thu, 25 Aug 2022 00:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661411453; cv=none; d=google.com; s=arc-20160816; b=uXouEhkCHNN05BEXC+5kKITFFyXYW2yA2a6L7/oWjI/M2swtkCQGYBU+Fhg+0MQtz3 8vMYK8Q6zyb5LSF2QicrzpJSytoBBNClNKIKUdPLdA4KmdQXByZ9dZhvhVWZ8+TvMuLD eZLLVJtrN5cm2UXP2wXDwTIH44a2wjnVLJU0cQKKZeNVS3Hl2fcll4u2SV9rySoONvit ilCDu6SvWj4Y+3AZPNXxtHEzUzH8/lJ7GYTCd7d7qZdA8PVVi5/e8TMMeN4Ah5X1rqEs q/lkFKnH4HV3R9MYifWPjGjePlwtZyXcW+Lv+GSCOpRsbCJSl9dQbXFXtrHmjRAPwgj2 Bb9Q== 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=QSUsmhrntyYlE4q4EIuSMo8SwjVSMcRRvXJOMV3jSHQ=; b=sSRyOMl941xgA4eb4EhdcxW4bhWF8TEE+9xiAl8lYYJlpBG1f1pupC9l0ayDC0G2X9 Wvz1tu9oJkkwPxyykyG5RW0UYRMapc+n6zdoFJi/yoBDVohWrTL0oEx0RnkZU0bhKKy+ SLV+AUQshGZHtJjeGnQYu9uq2+T3CzvrTUmnkDupjna1hvuCsET/4LPlSZcMZZq5Wz1q qDqCqYtg2Hy2RkFrP46UEdvh029gknAt3e1wscRe8OFCKZD0MTRRiy+c34dYWsXT1I0g 5wwyymKqcuNEGw8/vW/F3m5vYLW026At2Yd19UKxGK1AdfaE9e/wh3cJIjm45OAjFNwp wgvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h1+yoEUs; 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 e12-20020a170902cf4c00b0017139f381c9si7778369plg.569.2022.08.25.00.10.42; Thu, 25 Aug 2022 00:10:53 -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=h1+yoEUs; 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 S236857AbiHYHJO (ORCPT + 99 others); Thu, 25 Aug 2022 03:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236826AbiHYHJM (ORCPT ); Thu, 25 Aug 2022 03:09:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6200F7B297 for ; Thu, 25 Aug 2022 00:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661411350; 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=QSUsmhrntyYlE4q4EIuSMo8SwjVSMcRRvXJOMV3jSHQ=; b=h1+yoEUsBO9Kaqy2UIDsTNuejubux+AuQLnGkZRh+f2ifwpxNEdenclexJ9p2SV7X+oIFD YGkGrrr40iPDalw3pZRvtkjsC+wDyvHNuJGyd/7cU2v2lSQ1UYlXsiMhhokc1RU3P0zqUD Bm/ctrA847ePAvIKY2DrS7o3TuftFYE= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-52-4XXX32hHMtKyiYQaZrzwiQ-1; Thu, 25 Aug 2022 03:09:07 -0400 X-MC-Unique: 4XXX32hHMtKyiYQaZrzwiQ-1 Received: by mail-pg1-f199.google.com with SMTP id g9-20020a636b09000000b0042a98c614f9so5683808pgc.20 for ; Thu, 25 Aug 2022 00:09:06 -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; bh=QSUsmhrntyYlE4q4EIuSMo8SwjVSMcRRvXJOMV3jSHQ=; b=EP6cOdxUN8SO5OAxG6czFPTHmPtD3Z/Liz4wPZX49nKdU7Puq6kgm26QHrIXmDnAJ4 kxgICdun4BdItHZkU43IWkQ3u3l5/tDXU0gYDL0ewrjvSF0SHUmRsXUo3SBJyZgCcvO6 F+s79LSRggzDFPkSMdAvaMe0Q49YTPUlYb6UBpUi2TR0MP8kH2BX/uoepSaU+K4NlOQX DeePzsde6+zaJrSxcKDBcDh4W6fuq8jbo27jaJNqnCM/fLw+8HoXgCv6qsG0qnkjGlqp g/KxD5G1yE1K84GXC5U10ChgrjGJ4JAaQkfv877mO4yplMUPylNXT0VBS5JMqpreM/zr i+FA== X-Gm-Message-State: ACgBeo1ZAzout5jzD3bobvOTrCGtUCJ3Vcl4Mb7+1tPKmTe26qRRlTfx R0R4S3jbCzqldcqyrbD4ZbhpGVKV0svDyeCrJSv4V7xY9vO05v5/V5NOSNhrMKij0ga+jtfmsMr SeE3MjaYKQ3Y/7HI+H1GCUWDx X-Received: by 2002:a17:902:eac3:b0:172:ff31:bb3c with SMTP id p3-20020a170902eac300b00172ff31bb3cmr2446547pld.48.1661411345718; Thu, 25 Aug 2022 00:09:05 -0700 (PDT) X-Received: by 2002:a17:902:eac3:b0:172:ff31:bb3c with SMTP id p3-20020a170902eac300b00172ff31bb3cmr2446532pld.48.1661411345488; Thu, 25 Aug 2022 00:09:05 -0700 (PDT) Received: from [10.72.12.107] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id a9-20020a62d409000000b0053645475a6dsm10698425pfh.66.2022.08.25.00.09.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Aug 2022 00:09:04 -0700 (PDT) Message-ID: <13f97c76-bc8b-1509-d854-89d0d62138fa@redhat.com> Date: Thu, 25 Aug 2022 15:08:58 +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 v2 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: <20220817135718.2553-1-qtxuning1999@sjtu.edu.cn> <20220817135718.2553-4-qtxuning1999@sjtu.edu.cn> From: Jason Wang In-Reply-To: <20220817135718.2553-4-qtxuning1999@sjtu.edu.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 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_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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/8/17 21:57, 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 | 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); I may miss something but spec said "The device then skips forward in the ring according to the size of the batch. ". I don't see how it is done here. Thanks > no_more_replies: > if (added) > vhost_signal(&vsock->dev, vq);