Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3813793ybb; Tue, 31 Mar 2020 12:30:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvFUlnMr7Gpr9gBJOYl5mWAuuSKMT04YCo56D5Z0AA6Xz7meOIeQYUcfUmq9FViF1cXA0nO X-Received: by 2002:a9d:3a1:: with SMTP id f30mr13781889otf.215.1585683016154; Tue, 31 Mar 2020 12:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585683016; cv=none; d=google.com; s=arc-20160816; b=A0Wmrm/q2c2Z7hNfgVelkKxFdRZvF9qisG9Mpkvt8jEe9XNMXUfr6ZDljaFtVBTxsM onYGmBnvC5qkdVlv2LYHHW1BK4s6GVyz2YiaDXqrXgQ3pLwGYimyNx/qE78I6FwIFsdc R3m9RjlX7i0uu0iVCZ5KiyS/2AqkCYTJmnvOUkoWkE+b52f5HMkOC/DZeVgbPfKFjgXs +mL8TYqlHn8nG3QzZ8Xe/fLEvzlzFss2tL/IKPW6mezdsAGngm+nSLILl+TMzRI5MSG1 XO0RRaH7vAVYQFZkmiMNx8TIhV6Dr4lioXq3fQlINDoZpti2aFMZsqTNUjTBKxlxNhms QPKA== 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=MdcH/3aLsB5DaKn71kQYhxSyjdNXCbTThnTbtkLoDlOoXQnOZJPTcM9VBwdaRXjI1I Tz7dEqjf6DbL/Rf55dnuil7LTZJTgS7mEPdqmCR36cxIYuNzskUQQcLh9QAmYyXL6Sdh NIZV8rQh0iy2qBB26k6XV543ZkgDMnc02QjsQai/WvDqaggm9FtQShCKkuH25lH6eyJa H9iNX/Y0oRMTgWwtAwucww+13JyFZPfuwgS080yW4yxlJezgf/Id7QLNIYK9pMXhLh7m YHsguCwR7ApIPwxEd6rEEbQczqpgU2Xz9vQeSRB5UW9bsgUJGi8FGlOQyLTNnv38B4wR KiUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gwWyb3qR; 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 w24si8527017otq.131.2020.03.31.12.30.03; Tue, 31 Mar 2020 12:30:16 -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=gwWyb3qR; 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 S1731142AbgCaT2g (ORCPT + 99 others); Tue, 31 Mar 2020 15:28:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:50612 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731051AbgCaT2f (ORCPT ); Tue, 31 Mar 2020 15:28:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585682914; 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=gwWyb3qR02kdJGwK8GIoLADMwAmxu8o2dQwuxQAGBqpiZnowBHDIh9HgfTXvKmCQeRJtFJ JPVVoq2Xxq4Mn66trrji10RV7nk6KPd6zeZ2aNDZ1errX+Nopz+4db8wEFUSVE/uJVW65V hVd9J9NO8XtbrvCJ9WHuYtxXv/Zdls0= 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-339-_sS6YvP1NeOTmVVjpelVRA-1; Tue, 31 Mar 2020 15:28:32 -0400 X-MC-Unique: _sS6YvP1NeOTmVVjpelVRA-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 6F2A28024D2; Tue, 31 Mar 2020 19:28:31 +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 24A4299DE2; Tue, 31 Mar 2020 19:28:26 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "linux-kernel@vger.kernel.org" , Stephen Rothwell , kvm list , Linux Next Mailing List , "virtualization@lists.linux-foundation.org" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Christian Borntraeger , Halil Pasic , Cornelia Huck Subject: [PATCH v3 6/8] tools/virtio: Add --batch=random option Date: Tue, 31 Mar 2020 21:28:02 +0200 Message-Id: <20200331192804.6019-7-eperezma@redhat.com> In-Reply-To: <20200331192804.6019-1-eperezma@redhat.com> References: <20200331192804.6019-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