Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1127604imw; Fri, 8 Jul 2022 19:55:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sTHfGFRf7n6qefb95FlMDQVB82EJomXz9WSDoEyXwXaauBQsOKaZoVnMfksjPw4+FTFhs1 X-Received: by 2002:a17:907:c0a:b0:726:22b1:9734 with SMTP id ga10-20020a1709070c0a00b0072622b19734mr6789406ejc.195.1657335314356; Fri, 08 Jul 2022 19:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657335314; cv=none; d=google.com; s=arc-20160816; b=Rhk5RtE6Pa5NkVBIcuKuDncR/pplToLMiHTdabNJH1sh3RI6UCpYVo2YuJ5NMrU3C6 ZBj5yxOXwyka0IFIZ/pxwGVadrwnb2M3K2WG3btjutoxWCHtZ4cZWZoTKF5lf5RoyUEN XmyPOgvlxRXHGKDcfY2ENdrHUmmM8YE3snLA5H1d02kFziexeOCaxAVutA9A3n0PL1qj wXXRHqeN7iGQUszZUuG2zxwSYt7stHyskXScE9SIfAgsdU7EKs+E2o37PngJpRqgIG0G aQ6tkIqzy7c99mnJORiIjSIKuHCJ+qMvDV8h6W9A8Egw9LUpaQ33LUb9UW3aOsOIEOar jKkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Ole99MXqfK8YqYUpST1S3AwNtuq1PYZzRYg+n5mZnlM=; b=gIOq4NDTfXWJvNsonlwyozmxZYb0t21A8eOjgemROKj43EAZd8IGrCGVvtJn2LTxVY nCxAjjOQdmk2JD/XWsXQPpATx19f6lueWMBl7le+5m26g7gKHiGe4K6zoMiHLuDojwMU LFfyS+9YnQhga03PeMBkgjJwe+92oSR6AbIJG4GbGyl74+NwEUCMw1aEd2mDrFKhI+vR QkFeWqE0lKtBTCGH5q6D98ulsgW5xBI4tBHJqyyV9BPkQnIJMw19nUs8WgUudcWE76aG ml0R76r+WDmj82kyEoCJePByoAPS3ZTJwNyzM+kCKYRplaMAa65ad84RwY1JmJb3UAZ3 p0sA== 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 b11-20020a056402278b00b0042b0a1bfd4esi679444ede.343.2022.07.08.19.54.46; Fri, 08 Jul 2022 19:55:14 -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 S229629AbiGIC22 (ORCPT + 99 others); Fri, 8 Jul 2022 22:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbiGIC21 (ORCPT ); Fri, 8 Jul 2022 22:28:27 -0400 Received: from smtp236.sjtu.edu.cn (smtp236.sjtu.edu.cn [202.120.2.236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E3C255 for ; Fri, 8 Jul 2022 19:28:26 -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 40C141008B389; Sat, 9 Jul 2022 10:28:16 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by proxy02.sjtu.edu.cn (Postfix) with ESMTP id 79B272009BEC5; Sat, 9 Jul 2022 10:28: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 9XYm2DB9fy6l; Sat, 9 Jul 2022 10:28: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 B88C5200C91EC; Sat, 9 Jul 2022 10:28:03 +0800 (CST) From: Guo Zhi To: jasowang@redhat.com, mst@redhat.com Cc: eperezma@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, sgarzare@redhat.com, Guo Zhi Subject: [PATCH v3 2/4] virtio_test: use random length scatterlists to test descriptor chain Date: Sat, 9 Jul 2022 10:27:43 +0800 Message-Id: <20220709022745.21020-3-qtxuning1999@sjtu.edu.cn> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220709022745.21020-1-qtxuning1999@sjtu.edu.cn> References: <20220709022745.21020-1-qtxuning1999@sjtu.edu.cn> X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,RCVD_IN_SORBS_WEB, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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; + 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