Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3737494ybb; Tue, 31 Mar 2020 11:01:27 -0700 (PDT) X-Google-Smtp-Source: APiQypKgbCjaIbBwv0Kf2OV763t/V7Ii0uEKbKBdFTPpBxvl7IopGssVGJWlRFsSj0NbKTMVe4Xa X-Received: by 2002:a54:448a:: with SMTP id v10mr43557oiv.49.1585677687183; Tue, 31 Mar 2020 11:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585677687; cv=none; d=google.com; s=arc-20160816; b=vRS4unotlaxSIkHZg4O82WA0OnXZmNi+ngb9pwUgqIw/5bbp6Ed1AaFlj2nQRTOj/v H4zhUZYr3OqyY8IYmPfRnE1ZQ2hM/ujI0dbi8BFHLwK7dB8hxubiz76YaQOuTavHVk9K 52dnUdc+CecMt3uD6FX9mA7RbZE/n9b0Bj02yCglJ+apVlbH3NBqRlI8SH6C45FrNuG/ gG0EjjxMnLR2skiQu484sPlJ316YC3TVqoCAYn5lEH8Ys25e0+YDCjsMN3HvY/etsfwt 6252a9JTx2ZlvIMGsJOlLTZANS/CcHk6FUGlO1LdXVQyzlSbik1g977yu3N2VjhiNkfQ d34A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zxTOiAZFQUIPQ7LwD9H8y4khOH4iGHG3F8Nhf2kTwbA=; b=fFRNZxEZarvo3VHBPIE0LRyymkFi6rfpY1GE9mO9tmrxhW3tF9hT8IgyxqdNEISDvQ nSqP6mIx6pm3KFDU5UKbG+RBDQKURIRq9oPx3qZyTwBqew21MPD53Jf3DQHV6YdRfofu HQ3RFiIOWIkZO3FApeGzRhf3G87ELwCrTtpfQw1J9BoHTsTM46oWkcGMw3VXc/r3G3o0 PSNjReCiy0KIO1fH3t+tl8gaIM1CZW7o8y2oHjgXXa0wSa75rHU5zTULIY9OEdNCP8GX sGF4KYO6M62qiAFaPJszy8dQHxKhjlcq94JhagkLQPiYF6jlUoYtaGFAymf7x/pGxz2I cUFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZHkMM5bM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22si7381572oib.266.2020.03.31.11.01.12; Tue, 31 Mar 2020 11:01:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZHkMM5bM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727902AbgCaSAk (ORCPT + 99 others); Tue, 31 Mar 2020 14:00:40 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:57694 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727794AbgCaSAj (ORCPT ); Tue, 31 Mar 2020 14:00:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585677638; 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=zxTOiAZFQUIPQ7LwD9H8y4khOH4iGHG3F8Nhf2kTwbA=; b=ZHkMM5bM084m4E5nAM5cNXejG69WMoxsv6zrRq1LozEGG6+ivk/jdpP0juhpokSuySqzgo xDxXBF087cmaujNKr3/i3DUuX6Zyw3WYvcgernVypnZDWHSRrFxvjOev+iCU3XczSebD36 8jTrvi2BIjVYqVfZQJQ9g+QU/Jj0I8g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-llfWp3qSN2CoYNPvxaoU0g-1; Tue, 31 Mar 2020 14:00:36 -0400 X-MC-Unique: llfWp3qSN2CoYNPvxaoU0g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B1A7DB20; Tue, 31 Mar 2020 18:00:35 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-92.ams2.redhat.com [10.36.112.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BBF898A55; Tue, 31 Mar 2020 18:00:29 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "linux-kernel@vger.kernel.org" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , kvm list , Halil Pasic , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , Cornelia Huck , Stephen Rothwell , Christian Borntraeger Subject: [PATCH v2 6/8] tools/virtio: Add --batch=random option Date: Tue, 31 Mar 2020 20:00:04 +0200 Message-Id: <20200331180006.25829-7-eperezma@redhat.com> In-Reply-To: <20200331180006.25829-1-eperezma@redhat.com> References: <20200331180006.25829-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So we can test with non-deterministic batches in flight. Signed-off-by: Eugenio P=C3=A9rez --- tools/virtio/virtio_test.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index c30de9088f3c..4a2b9d11f287 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c @@ -19,6 +19,8 @@ #include #include "../../drivers/vhost/test.h" =20 +#define RANDOM_BATCH -1 + /* Unused */ void *__kmalloc_fake, *__kfree_ignore_start, *__kfree_ignore_end; =20 @@ -161,6 +163,7 @@ static void run_test(struct vdev_info *dev, struct vq= _info *vq, int r, test =3D 1; unsigned len; long long spurious =3D 0; + const bool random_batch =3D batch =3D=3D RANDOM_BATCH; r =3D ioctl(dev->control, VHOST_TEST_RUN, &test); assert(r >=3D 0); for (;;) { @@ -168,6 +171,9 @@ static void run_test(struct vdev_info *dev, struct vq= _info *vq, completed_before =3D completed; started_before =3D started; do { + if (random_batch) + batch =3D (random() % vq->vring.num) + 1; + while (started < bufs && (started - completed) < batch) { sg_init_one(&sl, dev->buf, dev->buf_size); @@ -275,7 +281,7 @@ static void help(void) " [--no-event-idx]" " [--no-virtio-1]" " [--delayed-interrupt]" - " [--batch=3DN]" + " [--batch=3Drandom/N]" "\n"); } =20 @@ -312,9 +318,13 @@ int main(int argc, char **argv) delayed =3D true; break; case 'b': - batch =3D strtol(optarg, NULL, 10); - assert(batch > 0); - assert(batch < (long)INT_MAX + 1); + if (0 =3D=3D strcmp(optarg, "random")) { + batch =3D RANDOM_BATCH; + } else { + batch =3D strtol(optarg, NULL, 10); + assert(batch > 0); + assert(batch < (long)INT_MAX + 1); + } break; default: assert(0); --=20 2.18.1