Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2303121imn; Mon, 1 Aug 2022 19:57:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/aeD6wr4i6H1ZAZbGk2Jnoc2vf6buyAVTZEqTyxSfoWttcg/ITYXJyuvZ60duKITTdCh2 X-Received: by 2002:a17:90a:a40a:b0:1f2:979:397d with SMTP id y10-20020a17090aa40a00b001f20979397dmr21704851pjp.179.1659409072293; Mon, 01 Aug 2022 19:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659409072; cv=none; d=google.com; s=arc-20160816; b=C/h79wNv43C5WqPG2zm9K4D5HG/k92yr7Aaf7ZARq27J37kx3kTsFQkEeUCm2Uf2H/ /geDUZ9G5LlWtksb99gl5OP0pHlOJYZdwFDlPoGH5U7j52tMBKkE4/GlLihzLsdJUEyd F/q9QYppClVyED8lipBO2VdTaWl8e2zkkuz3qAC5oiSBo1FWXsHcqH0OM2e2yASXISxV Mrr2CYiZuWUzlScQOvgzZ7pxQud+PgUGEN7ppkUR6LGFd8Mu7Odh/SBjOl4EIspUbO6x DnZgUr61ETU5z/hLongnOpxxo3381sEgXbKYbsS8xm5z9fplX53eB2vs0BS8cwbX5vqJ 8woA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:to:cc:in-reply-to:date:subject :mime-version:content-transfer-encoding:from; bh=7Ud0GDgiAHLwajtXYk6B7141eQ9c0ytF/UKMmgZ5+7g=; b=QCrhm4aidrjDuoOGY8wbChChRgq/QlQjCTTUOA4DrYo7+yJRUKr3jl/Xh7pFU52iet AhmOe/xSBojvVa5JNANdcu+RoTAcQe2QcU1MkRBN+7uhLT9Q03OvxT/qf0NCgQl9FwLT ce5SQTrH3nHfvMOsyIChFd4qrkhqr3MKnfcy5dgmA5N4cEb7itGandkeoOQ/LeOuBJFP 7WERWtKxbXF5C0AlZhjfzQCDq3q0zU866pG05QT/DGuVju/ft0mqSVLnWgCdj58EepC3 fEZhB4z5ZUwsuVnPB73E94/h7ZKGvZImIb2We8YEvTsAEEu4rcbBv4ImxfVDnw9ndj2J prbw== 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 140-20020a630092000000b0041bbc1428besi9571954pga.877.2022.08.01.19.57.38; Mon, 01 Aug 2022 19:57:52 -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 S235738AbiHBCrs convert rfc822-to-8bit (ORCPT + 99 others); Mon, 1 Aug 2022 22:47:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbiHBCrm (ORCPT ); Mon, 1 Aug 2022 22:47:42 -0400 Received: from smtp236.sjtu.edu.cn (smtp236.sjtu.edu.cn [202.120.2.236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF691AF28; Mon, 1 Aug 2022 19:47:34 -0700 (PDT) Received: from proxy01.sjtu.edu.cn (unknown [202.112.26.54]) by smtp236.sjtu.edu.cn (Postfix) with ESMTPS id D39291008B391; Tue, 2 Aug 2022 10:47:32 +0800 (CST) Received: from localhost (localhost [127.0.0.1]) by proxy01.sjtu.edu.cn (Postfix) with ESMTP id AC7D6203D801B; Tue, 2 Aug 2022 10:47:32 +0800 (CST) X-Virus-Scanned: amavisd-new at proxy01.sjtu.edu.cn Received: from proxy01.sjtu.edu.cn ([127.0.0.1]) by localhost (proxy01.sjtu.edu.cn [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id z8dqFZ4H9EgJ; Tue, 2 Aug 2022 10:47:32 +0800 (CST) Received: from smtpclient.apple (unknown [58.45.124.125]) (Authenticated sender: qtxuning1999@sjtu.edu.cn) by proxy01.sjtu.edu.cn (Postfix) with ESMTPSA id D593B203D8011; Tue, 2 Aug 2022 10:47:05 +0800 (CST) From: Guo Zhi Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.20.0.1.32\)) Subject: Re: [RFC 3/5] vhost_test: batch used buffer Date: Tue, 2 Aug 2022 10:47:01 +0800 In-Reply-To: Cc: jasowang , sgarzare , Michael Tsirkin , netdev , linux-kernel , kvm list , virtualization To: eperezma Message-Id: <5E347090-9EB2-4961-B435-D6783CB46CAF@sjtu.edu.cn> X-Mailer: Apple Mail (2.3693.20.0.1.32) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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: Friday, July 22, 2022 3:12:47 PM Subject: Re: [RFC 3/5] vhost_test: batch used buffer On Thu, Jul 21, 2022 at 10:44 AM Guo Zhi wrote: > > Only add to used ring when a batch a buffer have all been used. And if > in order feature negotiated, add randomness to the used buffer's order, > test the ability of vhost to reorder batched buffer. > > Signed-off-by: Guo Zhi > --- > drivers/vhost/test.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c > index bc8e7fb1e..1c9c40c11 100644 > --- a/drivers/vhost/test.c > +++ b/drivers/vhost/test.c > @@ -43,6 +43,9 @@ struct vhost_test { > static void handle_vq(struct vhost_test *n) > { > struct vhost_virtqueue *vq = &n->vqs[VHOST_TEST_VQ]; > + struct vring_used_elem *heads = kmalloc(sizeof(*heads) > + * vq->num, GFP_KERNEL); > + int batch_idx = 0; > unsigned out, in; > int head; > size_t len, total_len = 0; > @@ -84,11 +87,21 @@ static void handle_vq(struct vhost_test *n) > vq_err(vq, "Unexpected 0 len for TX\n"); > break; > } > - vhost_add_used_and_signal(&n->dev, vq, head, 0); > + heads[batch_idx].id = cpu_to_vhost32(vq, head); > + heads[batch_idx++].len = cpu_to_vhost32(vq, len); > total_len += len; > if (unlikely(vhost_exceeds_weight(vq, 0, total_len))) > break; > } > + if (batch_idx) { > + if (vhost_has_feature(vq, VIRTIO_F_IN_ORDER) && batch_idx >= 2) { Maybe to add a module parameter to test this? Instead of trusting in feature negotiation, "unorder_used=1" or something like that. vhost.c:vhost_add_used_and_signal_n should support receiving buffers in order or out of order whether F_IN_ORDER is negotiated or not. Thanks! > + vhost_add_used_and_signal_n(&n->dev, vq, &heads[batch_idx / 2], > + batch_idx - batch_idx / 2); > + vhost_add_used_and_signal_n(&n->dev, vq, heads, batch_idx / 2); > + } else { > + vhost_add_used_and_signal_n(&n->dev, vq, heads, batch_idx); > + } > + } > > mutex_unlock(&vq->mutex); > } > -- > 2.17.1