Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2257819imw; Sun, 17 Jul 2022 05:07:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vBOcIHEidUgabDIMD1HWyC5IhyPcb8Eh4UQrOuMFLmxiG+eO6bD83zXjDM3yVJr65cHFHg X-Received: by 2002:a05:6808:f02:b0:33a:59d2:ec2e with SMTP id m2-20020a0568080f0200b0033a59d2ec2emr4380765oiw.273.1658059638369; Sun, 17 Jul 2022 05:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658059638; cv=none; d=google.com; s=arc-20160816; b=IP4tisg7l68hPR6Huw1PCM996EDwdLFQ04qpDtMxbe2bxV6hVhDN801IrbkRAD4NDK z8o/yuDKHQD57V4jI+tiaIZ9bM9NGu3omxnFz1JJyqqZ+lyHkCtsh5/S4yVi3vtjXmLv RZ3fcqmMJdPnitMa9hFi9YCTfBEo10Pd/bE2KJZwHbB9rgeBKq98DLASVpN1PZPX18S0 qwlB4iACNznZRLFLMdve0s+aZZj7AMvGoD++2iUHYphPv6l0g/U11+u4X/o1e8w5NlLh KjyvtdWpxViYHj+ldMcXixbBy+hoYsKGYU+rM/9GoulsmQnPxvb1dfmUtXPYlYO2qsKu nsIQ== 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; bh=HCGzWXFHK2eZ+8jhCyF5H9EK8AmqMAam2Jj4Sd06gWA=; b=bm6qRBBCHxiHQj+8dcjEuj4kApSmr8gh17BTRvnxLFchtAVjc2eecN4IbIPdHbIX1l D6hGFLgeqLdZyID0RfTZak/u5aWpQpSyIQiaRQzLXKanxBjgKXes4pzDLRH0OwVrsvhN xogO6cgQOtBfopEfPizUuJUOwYLE+eEJanYWgNIda1uSzJpnuIOUltN1fPVSGSGZ5m5a uk6B/JB60erbIZ37r44tHqtod7GTmFthZS9X6gb1SKcI33nF2APuem6grwoxKnB6DpfQ v2C4RqbsHiakq9kiA6/Ry4LYlABSS5qRaKXDUwUVHsPi8D+kxFRtwrlrep3S/ZuHL3FS CZqw== 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 g63-20020a9d2dc5000000b0061c736f8d58si4486995otb.318.2022.07.17.05.07.03; Sun, 17 Jul 2022 05:07:18 -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 S231534AbiGQLdw (ORCPT + 99 others); Sun, 17 Jul 2022 07:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbiGQLdv (ORCPT ); Sun, 17 Jul 2022 07:33:51 -0400 Received: from smtp236.sjtu.edu.cn (smtp236.sjtu.edu.cn [202.120.2.236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EDA8DD0 for ; Sun, 17 Jul 2022 04:33:49 -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 286C01008B388; Sun, 17 Jul 2022 19:33:45 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by proxy02.sjtu.edu.cn (Postfix) with ESMTP id 1729A2007EB67; Sun, 17 Jul 2022 19:33:45 +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 seTJFmOmQv6T; Sun, 17 Jul 2022 19:33:45 +0800 (CST) Received: from [192.168.24.189] (unknown [202.120.40.82]) (Authenticated sender: qtxuning1999@sjtu.edu.cn) by proxy02.sjtu.edu.cn (Postfix) with ESMTPSA id 3768B200BFDA8; Sun, 17 Jul 2022 19:33:37 +0800 (CST) Message-ID: <47372b7c-15bf-ba9f-083c-e16bd4d1df04@sjtu.edu.cn> Date: Sun, 17 Jul 2022 19:33:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3 2/4] virtio_test: use random length scatterlists to test descriptor chain Content-Language: en-US To: Eugenio Perez Martin Cc: Jason Wang , Michael Tsirkin , virtualization , linux-kernel , Stefano Garzarella References: <20220709022745.21020-1-qtxuning1999@sjtu.edu.cn> <20220709022745.21020-3-qtxuning1999@sjtu.edu.cn> From: Guo Zhi In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On 2022/7/11 23:35, Eugenio Perez Martin wrote: > On Sat, Jul 9, 2022 at 4:28 AM Guo Zhi wrote: >> Prior implementation only use one descriptor for each io event, which >> does't test code of descriptor chain. More importantly, one descriptor >> will not use indirect feature even indirect feature is specified. Use >> random length scatterlists here to test descriptor chain. >> >> Signed-off-by: Guo Zhi >> --- >> v3: >> - drop fda270fcd virtio_test: move magic number in code as defined constant >> --- >> tools/virtio/virtio_test.c | 11 ++++++++--- >> 1 file changed, 8 insertions(+), 3 deletions(-) >> >> diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c >> index 95f78b311..1408a4a20 100644 >> --- a/tools/virtio/virtio_test.c >> +++ b/tools/virtio/virtio_test.c >> @@ -20,6 +20,7 @@ >> #include "../../drivers/vhost/test.h" >> >> #define RANDOM_BATCH -1 >> +#define MAX_SG_FRAGS 8UL >> >> /* Unused */ >> void *__kmalloc_fake, *__kfree_ignore_start, *__kfree_ignore_end; >> @@ -169,7 +170,8 @@ static void wait_for_interrupt(struct vdev_info *dev) >> static void run_test(struct vdev_info *dev, struct vq_info *vq, >> bool delayed, int batch, int reset_n, int bufs) >> { >> - struct scatterlist sl; >> + struct scatterlist sg[MAX_SG_FRAGS]; >> + int sg_size = 0; >> long started = 0, completed = 0, next_reset = reset_n; >> long completed_before, started_before; >> int r, test = 1; >> @@ -194,8 +196,11 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, >> >> while (started < bufs && >> (started - completed) < batch) { >> - sg_init_one(&sl, dev->buf, dev->buf_size); >> - r = virtqueue_add_outbuf(vq->vq, &sl, 1, >> + sg_size = random() % (MAX_SG_FRAGS - 1) + 1; > I'm wondering if it would be simpler to reuse batch randomness here, > and make sg_size = MIN(started - completed, MAX_SG_FRAGS). Vhost test > should go faster because the longer chains, and I guess we should hit > a good range of chain lengths with the batch tail anyway. > > Thanks! IMHO, if we reuse batch randomness here, the random length of scatterlist only appears when --batch=random selected. Otherwise, when we have to specify the batch size(eg, 256), the scatterlist( as well as the descriptor chain len) will not be randomed. So I propose decouple the randomness of batch size and descriptor chain length. If we have to achive better performance for vhost_test, just enlarge the MAX_SG_FRAGS is ok. >> + sg_init_table(sg, sg_size); >> + for (int i = 0; i < sg_size; ++i) >> + sg_set_buf(&sg[i], dev->buf + i, 0x1); >> + r = virtqueue_add_outbuf(vq->vq, sg, sg_size, >> dev->buf + started, >> GFP_ATOMIC); >> if (unlikely(r != 0)) { >> -- >> 2.17.1 >>