From patchwork Sat Apr 18 10:22:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 11496503 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0995F13B2 for ; Sat, 18 Apr 2020 10:25:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E606E21D7E for ; Sat, 18 Apr 2020 10:24:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BaVOyObU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726326AbgDRKYn (ORCPT ); Sat, 18 Apr 2020 06:24:43 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44804 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726006AbgDRKWn (ORCPT ); Sat, 18 Apr 2020 06:22:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587205362; 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=BaVOyObUDBNuOLPHZHqZ0HGU1NA7mZzSjqMxlSOdkfsIym/LgHDDiVMpHRW0ApO10RvZI/ M5BFmoRdDnO2LOU90pIUh2JMYzfvOcGixA+pap1Ay3x+aSoMJKmoKdisLhw7mP1fxX3bXo wKHakSwRnC9mpBhUloLdqcGLbZHxTHQ= 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_P=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_P=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 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org So we can test with non-deterministic batches in flight. Signed-off-by: Eugenio PĂ©rez --- 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" +#define RANDOM_BATCH -1 + /* Unused */ void *__kmalloc_fake, *__kfree_ignore_start, *__kfree_ignore_end; @@ -161,6 +163,7 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, int r, test = 1; unsigned len; long long spurious = 0; + const bool random_batch = batch == RANDOM_BATCH; r = ioctl(dev->control, VHOST_TEST_RUN, &test); assert(r >= 0); for (;;) { @@ -168,6 +171,9 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, completed_before = completed; started_before = started; do { + if (random_batch) + batch = (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=N]" + " [--batch=random/N]" "\n"); } @@ -312,9 +318,13 @@ int main(int argc, char **argv) delayed = true; break; case 'b': - batch = strtol(optarg, NULL, 10); - assert(batch > 0); - assert(batch < (long)INT_MAX + 1); + if (0 == strcmp(optarg, "random")) { + batch = RANDOM_BATCH; + } else { + batch = strtol(optarg, NULL, 10); + assert(batch > 0); + assert(batch < (long)INT_MAX + 1); + } break; default: assert(0);