Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1551998ybz; Sat, 18 Apr 2020 03:27:25 -0700 (PDT) X-Google-Smtp-Source: APiQypKEfMI4QNg9ri1Q4jLaY/K+gTf6219ehfnTW8BFwsoMNr5vOUliLhRvawOlx4c5KoBRIPnA X-Received: by 2002:aa7:d5d5:: with SMTP id d21mr6820402eds.160.1587205644859; Sat, 18 Apr 2020 03:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587205644; cv=none; d=google.com; s=arc-20160816; b=rFYx5jhCEbTlteHavamSRXqHd180ciX1LwHV8dNPT4OIGMmR3MJ+VWjc5f1+hNfRLz nAP5q1zSyID49O0dcmHLeKyqkaRbIrmndqfrQDZTjjv1OVlkr/TiJR+gx7BrFuLWgmUn E+Tgvn0RCB5z+Zp+6UwKXIutga7WlNVz3Lrkn1494HdmoK7BoJR9J6y1b/AIk9ufY0Uf jxUTPoFmC9xzD5Yqhdv3xAums451ogGhGKR/ZGqHikfkO9WSlOrk83xD9Vb7hZqEihfX 6I+K9nO2IWuqb9Q4LLFLkrEQ5/s0A7cyWFCYDCAf9itiNyE5EwHtBs5UwdsJ5oGtopUH lPvw== 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=dOYkxWJlk3XgETLm2ufXcg4tU7SLLRVhPfC9StQpMeCQ79tJL4V+Il4SImlJnNj2pK CCXe2lHWfupn8F7/d0taPXkQ7J7dEWs4V9mYzSMlZkv4J1qp2ft2JEygowJAFZRhILcY b6Yf1g1tmZrINvBmc4bFhlK7KXia8vm5wLxYs3AiL+yli09LoYSoiwlwg7IOz/xi6+qs k/fr0FBZI3IRfhGBD09MtsMnuWVkBILeQSAQMsJNZOQzb22A43nJKlvBRw4NuhMzTulP pUip9LToLhQ3gfOpdYyc51SOks6A6NY8PNYjGyPrKZWkHxzyDbjRKUpUZn2pB/bpTW+4 Df/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SxlqnuPo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id s8si16968287edj.463.2020.04.18.03.27.00; Sat, 18 Apr 2020 03:27:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SxlqnuPo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726356AbgDRKZD (ORCPT + 99 others); Sat, 18 Apr 2020 06:25:03 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:31969 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725988AbgDRKWl (ORCPT ); Sat, 18 Apr 2020 06:22:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587205360; 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=SxlqnuPor74zXwloUO7I+4Ux612gJ2T0CP/71d8EyVhXKBhcHAfOEoTXblzsbDmWyKR92C SYNXYFOf7CHBiPJsEKaNbZ1pYOA3NPXcWucJaZK7X0GfwmWEOi/uTYOyKvG2kga87Tlmdk 5XJucNXasQ6YSRmX7w3zVu5hmu0dwtI= 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-495-YYG2JwGgNn2cI4pDjP6Vww-1; Sat, 18 Apr 2020 06:22:38 -0400 X-MC-Unique: YYG2JwGgNn2cI4pDjP6Vww-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC99A8017F5; Sat, 18 Apr 2020 10:22:36 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-94.ams2.redhat.com [10.36.112.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76BCF1036D15; Sat, 18 Apr 2020 10:22:34 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , Halil Pasic , Cornelia Huck , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Christian Borntraeger , kvm list , Stephen Rothwell , Linux Next Mailing List Subject: [PATCH v3 3/8] tools/virtio: Add --batch=random option Date: Sat, 18 Apr 2020 12:22:12 +0200 Message-Id: <20200418102217.32327-4-eperezma@redhat.com> In-Reply-To: <20200418102217.32327-1-eperezma@redhat.com> References: <20200418102217.32327-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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