Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp891596ybb; Wed, 1 Apr 2020 11:32:53 -0700 (PDT) X-Google-Smtp-Source: APiQypKq2Ake2ejuOUrfY90+qSjMUiVj9StDAwG9H2/cA++qgSfeCahFzUQFIa5Q3Fb+TcEOIbol X-Received: by 2002:aca:1812:: with SMTP id h18mr4054750oih.107.1585765973002; Wed, 01 Apr 2020 11:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585765972; cv=none; d=google.com; s=arc-20160816; b=vHSmwsP9iFI+wqxNsMzc0c1w1QXYM+0dL1NheHkvWdybvVXjudmcyg5vWFSkJv9q7E fye53z3uVzi6dKJPsmNY49nNqwuZLfZzgfNq8oJG73tDaNwcKilZcMRor6xUneSf5Jhk ed1Ke6TBIrjBBkKwOHw3a6cTYiZCnFObIo3QIPQukO4c6eaAV9390XoWJrvyg9U3Px4a hfNk0k1NAJWVxXDXeT0xfFBt/bXfLvt0CyM2p5Wnh3IfH7098mWuwpEneROrIcPGyoLt PGlR/L7bsdvhQ3jn/OEzzAvVkch0TtoTJVT4KJJRsNgxhzRTtmjHGcv/hgbfkfuA0m3s Danw== 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=PqmBVtgiHSfBao6tgKiesuj5N2juuIgUhgZfY8H46q9LeD1waBGIX/73ny8N/5ULaC Yxhn1GfejYVL9q0pK8Zbqrt0KmwvJ7Ko7ctolVVqVW+FNIpnNzXdN02MU7NpBFqldUeC Nh/E16hWHf8L9l+oxB+Pcvq68YBF/O+T9jrOYU7BjfsxHAMyeYSUh95VPlrX9RAf/eiG 9w8jSVZrJF4ktwZD3ffg5bfWXBVUE/dNSUqShWlqDN2IkoVZeZITk3gTNRtHhBM3ugMS dfBPwLDqmi3xmNTCmm0wKm/wa5a2ADZCYhKgpD2IDDvIHC2naJRxRF91sqHggI2ILHbW ol1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Tw/DlC22"; 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 e24si1153613otq.2.2020.04.01.11.32.36; Wed, 01 Apr 2020 11:32:52 -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="Tw/DlC22"; 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 S1733164AbgDASbt (ORCPT + 99 others); Wed, 1 Apr 2020 14:31:49 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:24780 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733180AbgDASbs (ORCPT ); Wed, 1 Apr 2020 14:31:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585765906; 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=Tw/DlC22ilFctlQshwUp+rTc5r+cfLaY8KUvXOj9lvBWt4JMLCGnngI2BX1p7H1MyQwdSr SCOELuzcz0zmx7Ah+MUxL6zCih+h4dDNQ0NIKwgk9/441//YONxVVDU7k17VjIl5Ueka5e uBfum3OdXS6ds1CxwMr/Zvp9u8jEB+0= 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-294-wD0LsOUhPuiaObE-Kpu7jA-1; Wed, 01 Apr 2020 14:31:43 -0400 X-MC-Unique: wD0LsOUhPuiaObE-Kpu7jA-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 9835718C8C00; Wed, 1 Apr 2020 18:31:41 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-73.ams2.redhat.com [10.36.113.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DF3A96F83; Wed, 1 Apr 2020 18:31:39 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "virtualization@lists.linux-foundation.org" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Linux Next Mailing List , Stephen Rothwell , kvm list , Halil Pasic , "linux-kernel@vger.kernel.org" , Cornelia Huck , Christian Borntraeger Subject: [PATCH v4 5/7] tools/virtio: Add --batch=random option Date: Wed, 1 Apr 2020 20:31:16 +0200 Message-Id: <20200401183118.8334-6-eperezma@redhat.com> In-Reply-To: <20200401183118.8334-1-eperezma@redhat.com> References: <20200401183118.8334-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