Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp252373ybz; Fri, 17 Apr 2020 00:06:39 -0700 (PDT) X-Google-Smtp-Source: APiQypIQcj/gIHDgGcXVm2ZC0YHAtWlVq6v1uy24MIOXaEDcAJiQU9aSSsRdi7EKOcMvOeb1od3E X-Received: by 2002:a17:906:d14b:: with SMTP id br11mr1697490ejb.213.1587107199114; Fri, 17 Apr 2020 00:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587107199; cv=none; d=google.com; s=arc-20160816; b=CiiN6PsYE5esjMX0NJKvHUu/LtPWSWEAZ+2sm+DMy8+SVVHAY8cA9rWw27liKmMur+ GxjYt/r0uQXc4qISOsBnPfeyrS67w/OwM47C3WgL10DbAEQcxHo4O4kG5bal16dZcxPS oT87ZO/CYr97SnsXjfjKQUadir0IXb4y6sFJdP/O+1ae5gbz13nxcOxuD+P2vM3elGpo XWDSWww15eixmNEa8EwyswXVmUgSHPnH9zjMGnwjkthQFbiEX4aEN8cxY0AJIJspK0WJ i/bKn5IcfnkeYnXfCS9jZ6idnzSePeIngXkJ3j/CCgM79RJ8XOgdTkc1IHjcwtnQJtbw DjVQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9GSTWfCb5EE/NSDaeZnWXhb9iMAdwIiOPhmKGByClik=; b=a5vVAeZLeH8rVzRdG/q5YUbX+R/KXghDfNoZJOAatPGC15+wyiI7CSPeMkISHD+CFv mYzJgi/f2YuK47DYr9Di1CL0hZiLHS2myjkyOG9ogJuol4v5DxYOfrjM3oX/T4V7RIFi ZyJU54lFnof2do73m98tPsmDfVgUZlA11Cv5/Udx65dJkBuDRi4EImnEq9knRDFsZ5oa 2OlS1zHHsaHAi+STQ8a/QUv+BdFM1/pJNRmKW6O0cXRff8OJ3ICittu06QR6raqLZWTg rMWXF1N+KCK97IP8T6q6/BJa+OpufBUrBhjbaEsDSfUgdA5Zi1YJqIOJsGGbZKzxs0Jh S/ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SfsHOjbV; 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 a14si2407789edn.92.2020.04.17.00.06.11; Fri, 17 Apr 2020 00:06:39 -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=SfsHOjbV; 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 S1728414AbgDQHEp (ORCPT + 99 others); Fri, 17 Apr 2020 03:04:45 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57977 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726625AbgDQHEp (ORCPT ); Fri, 17 Apr 2020 03:04:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587107083; 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=9GSTWfCb5EE/NSDaeZnWXhb9iMAdwIiOPhmKGByClik=; b=SfsHOjbVcJzTEbVVQm/MO4DdlBs74a01tu2h6Q1MQ+iY7NECF3IJqr9wUXHxHETbP/PBk1 xVfPfKLMCYdvAlWB+rhy3xnolXrqqOoB1B8eCcFVhPW2qz826ZEKXTlACLjOzKo+fA5z0h 1/FrQZwYnC2KE+Jfg/j09QsaOXy36iY= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-53-jdvTFo89MCGfiFEvhhcR9Q-1; Fri, 17 Apr 2020 03:04:41 -0400 X-MC-Unique: jdvTFo89MCGfiFEvhhcR9Q-1 Received: by mail-qk1-f199.google.com with SMTP id h9so1161832qkm.5 for ; Fri, 17 Apr 2020 00:04:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=9GSTWfCb5EE/NSDaeZnWXhb9iMAdwIiOPhmKGByClik=; b=CKhhuEK6+szIkDUFfEtI33mwnYGn0r0J7rMBw0+ZXaIieydk80KFGz4L8e1Vo/48QQ 46nhxVZvrV9vG5/2EnjqzsphVETwCwPX3cqUdiKJkCc/xYygj2wsfRTqL6DbLm9P6ix4 eVLAsEBQpXUWqCXo8qgK9AgrND1smw/9UvLoWunwVl9PYxdseDXod0OLCQV4R2O/i0NL L3RN4IMXcB+fgAFZ+juNd/c4+EEp8utqYkxpPOagAe3nlI0uWlNnBBd9H5Zd/cbtDxlL tFq2U5Yr5kBa2/qrHQ6+xIChhT2EwhAhidRA7lMKs6yV0TvdEkHtWMFFmehCxvmkE5Ii 5/Cw== X-Gm-Message-State: AGi0PuZaReKkMCScbC3sDGmM6S4Pj7nw0pDh3ReLp5CWiDgVdWhWjTw8 9OD/zswchPmKmsd56G0snrLiCJwLB0MC1tMAsraDQuBkgIlurJHKaY9OdLwz7qk13MN9Ax6n9OU Oc1bLod+B5WU4qXYetYDfTXcOt3t5+wFK15P+Gv47 X-Received: by 2002:a05:6214:4ec:: with SMTP id cl12mr1273097qvb.8.1587107081149; Fri, 17 Apr 2020 00:04:41 -0700 (PDT) X-Received: by 2002:a05:6214:4ec:: with SMTP id cl12mr1273073qvb.8.1587107080876; Fri, 17 Apr 2020 00:04:40 -0700 (PDT) MIME-Version: 1.0 References: <20200416075643.27330-1-eperezma@redhat.com> <20200416075643.27330-8-eperezma@redhat.com> <20200416183324-mutt-send-email-mst@kernel.org> In-Reply-To: <20200416183324-mutt-send-email-mst@kernel.org> From: Eugenio Perez Martin Date: Fri, 17 Apr 2020 09:04:04 +0200 Message-ID: Subject: Re: [PATCH v2 7/8] tools/virtio: Reset index in virtio_test --reset. To: "Michael S. Tsirkin" Cc: Stephen Rothwell , "virtualization@lists.linux-foundation.org" , Christian Borntraeger , Linux Next Mailing List , kvm list , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 17, 2020 at 12:34 AM Michael S. Tsirkin wrote: > > On Thu, Apr 16, 2020 at 09:56:42AM +0200, Eugenio P=C3=A9rez wrote: > > This way behavior for vhost is more like a VM. > > > > Signed-off-by: Eugenio P=C3=A9rez > > I dropped --reset from 5.7 since Linus felt it's unappropriate. > I guess I should squash this in with --reset? > Yes please. If you prefer I can do it using the base you want, so all commits messages are right. Thanks! > > --- > > tools/virtio/virtio_test.c | 33 ++++++++++++++++++++++++++------- > > 1 file changed, 26 insertions(+), 7 deletions(-) > > > > diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c > > index 18d5347003eb..dca64d36a882 100644 > > --- a/tools/virtio/virtio_test.c > > +++ b/tools/virtio/virtio_test.c > > @@ -20,7 +20,6 @@ > > #include "../../drivers/vhost/test.h" > > > > #define RANDOM_BATCH -1 > > -#define RANDOM_RESET -1 > > > > /* Unused */ > > void *__kmalloc_fake, *__kfree_ignore_start, *__kfree_ignore_end; > > @@ -49,6 +48,7 @@ struct vdev_info { > > > > static const struct vhost_vring_file no_backend =3D { .fd =3D -1 }, > > backend =3D { .fd =3D 1 }; > > +static const struct vhost_vring_state null_state =3D {}; > > > > bool vq_notify(struct virtqueue *vq) > > { > > @@ -174,14 +174,19 @@ static void run_test(struct vdev_info *dev, struc= t vq_info *vq, > > 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); > > + if (!reset_n) { > > + next_reset =3D INT_MAX; > > + } > > + > > for (;;) { > > virtqueue_disable_cb(vq->vq); > > completed_before =3D completed; > > started_before =3D started; > > do { > > - const bool reset =3D reset_n && completed > next_= reset; > > + const bool reset =3D completed > next_reset; > > if (random_batch) > > batch =3D (random() % vq->vring.num) + 1; > > > > @@ -224,10 +229,24 @@ static void run_test(struct vdev_info *dev, struc= t vq_info *vq, > > } > > > > if (reset) { > > + struct vhost_vring_state s =3D { .index = =3D 0 }; > > + > > + vq_reset(vq, vq->vring.num, &dev->vdev); > > + > > + r =3D ioctl(dev->control, VHOST_GET_VRING= _BASE, > > + &s); > > + assert(!r); > > + > > + s.num =3D 0; > > + r =3D ioctl(dev->control, VHOST_SET_VRING= _BASE, > > + &null_state); > > + assert(!r); > > + > > r =3D ioctl(dev->control, VHOST_TEST_SET_= BACKEND, > > &backend); > > assert(!r); > > > > + started =3D completed; > > while (completed > next_reset) > > next_reset +=3D completed; > > } > > @@ -249,7 +268,9 @@ static void run_test(struct vdev_info *dev, struct = vq_info *vq, > > test =3D 0; > > r =3D ioctl(dev->control, VHOST_TEST_RUN, &test); > > assert(r >=3D 0); > > - fprintf(stderr, "spurious wakeups: 0x%llx\n", spurious); > > + fprintf(stderr, > > + "spurious wakeups: 0x%llx started=3D0x%lx completed=3D0x%= lx\n", > > + spurious, started, completed); > > } > > > > const char optstring[] =3D "h"; > > @@ -312,7 +333,7 @@ static void help(void) > > " [--no-virtio-1]" > > " [--delayed-interrupt]" > > " [--batch=3Drandom/N]" > > - " [--reset=3Drandom/N]" > > + " [--reset=3DN]" > > "\n"); > > } > > > > @@ -360,11 +381,9 @@ int main(int argc, char **argv) > > case 'r': > > if (!optarg) { > > reset =3D 1; > > - } else if (0 =3D=3D strcmp(optarg, "random")) { > > - reset =3D RANDOM_RESET; > > } else { > > reset =3D strtol(optarg, NULL, 10); > > - assert(reset >=3D 0); > > + assert(reset > 0); > > assert(reset < (long)INT_MAX + 1); > > } > > break; > > -- > > 2.18.1 >