From patchwork Thu Apr 16 07:56:36 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: 11492455 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 6F488112C for ; Thu, 16 Apr 2020 07:58:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5731620784 for ; Thu, 16 Apr 2020 07:58:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KpIxz8Ur" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441094AbgDPH6t (ORCPT ); Thu, 16 Apr 2020 03:58:49 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:54360 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440767AbgDPH5B (ORCPT ); Thu, 16 Apr 2020 03:57:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587023820; 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=e1k01JD5xORhS1YT1xVO0vHDHL2WrkMx7ODikVyTREQ=; b=KpIxz8Ur6wlKffHi1mxzcHWFyPBHQ4Zz100qbTAhWgxdfoIm7RCW6v4Ry2/qKlwGz/kqUF 58FEjBhJHv8CTtOux1tO0XwZU/t9G1Uo0vCQvifrgh4VopAN6DXQjwJSQKVmBAF25L3Z2u kqwWFlJZIkw1qY6Z04Hal1tUURnKm/g= 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-114-YBSDWHJlMbyoAM-xemqa1A-1; Thu, 16 Apr 2020 03:56:56 -0400 X-MC-Unique: YBSDWHJlMbyoAM-xemqa1A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58F71107ACC9; Thu, 16 Apr 2020 07:56:55 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-194.ams2.redhat.com [10.36.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0B7C7E7C0; Thu, 16 Apr 2020 07:56:52 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: Stephen Rothwell , "virtualization@lists.linux-foundation.org" , Christian Borntraeger , =?utf-8?q?Eugenio_P=C3=A9re?= =?utf-8?q?z?= , Linux Next Mailing List , kvm list , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 1/8] tools/virtio: fix virtio_test.c indentation Date: Thu, 16 Apr 2020 09:56:36 +0200 Message-Id: <20200416075643.27330-2-eperezma@redhat.com> In-Reply-To: <20200416075643.27330-1-eperezma@redhat.com> References: <20200416075643.27330-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Just removing extra whitespace. Signed-off-by: Eugenio Pérez --- tools/virtio/virtio_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index 25be607d8711..1d5144590df6 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c @@ -222,7 +222,7 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, &backend); assert(!r); - while (completed > next_reset) + while (completed > next_reset) next_reset += completed; } } while (r == 0); From patchwork Thu Apr 16 07:56:37 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: 11492453 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 E568615AB for ; Thu, 16 Apr 2020 07:58:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C213621556 for ; Thu, 16 Apr 2020 07:58:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d3JE1EZv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441080AbgDPH6l (ORCPT ); Thu, 16 Apr 2020 03:58:41 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35919 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440761AbgDPH5E (ORCPT ); Thu, 16 Apr 2020 03:57:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587023823; 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=NIXtCxLH9qE2Xr1d3NAPwfOyt7PzhZHgvlWtNr1RJhc=; b=d3JE1EZvYQGzk0bHCiofiQ/IQWQOjHHGd2OOPSShJr2Yq4j0hD5AcvvFivASUR8T5UQjrX Aptb1Z/k1b8eqFvHDg7389PbPHA901zZI/zH3TkHFjDHa6l5gMBtGRQcZBYdzB7HK4jVoh 63L6tAp4WOmlR0DKsmecY8+I/6EdoF8= 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-268-VibkYPSGNAO5AKaTj77VSw-1; Thu, 16 Apr 2020 03:56:59 -0400 X-MC-Unique: VibkYPSGNAO5AKaTj77VSw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17F23800D5C; Thu, 16 Apr 2020 07:56:58 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-194.ams2.redhat.com [10.36.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id B28567E7C5; Thu, 16 Apr 2020 07:56:55 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: Stephen Rothwell , "virtualization@lists.linux-foundation.org" , Christian Borntraeger , =?utf-8?q?Eugenio_P=C3=A9re?= =?utf-8?q?z?= , Linux Next Mailing List , kvm list , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 2/8] vhost: Not cleaning batched descs in VHOST_SET_VRING_BASE ioctl Date: Thu, 16 Apr 2020 09:56:37 +0200 Message-Id: <20200416075643.27330-3-eperezma@redhat.com> In-Reply-To: <20200416075643.27330-1-eperezma@redhat.com> References: <20200416075643.27330-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org They are cleaned in vhost_vq_set_backend, which can be called with an active backend. To set and remove backends already clean batched descriptors, so to do it here is completely redundant. Fixes: ("af3756cfed9a vhost: batching fetches") Signed-off-by: Eugenio Pérez --- drivers/vhost/vhost.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 0395229486a9..882d0df57e24 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1579,7 +1579,6 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg vq->last_avail_idx = s.num; /* Forget the cached index value. */ vq->avail_idx = vq->last_avail_idx; - vq->ndescs = vq->first_desc = 0; break; case VHOST_GET_VRING_BASE: s.index = idx; From patchwork Thu Apr 16 07:56:38 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: 11492447 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 C19C415AB for ; Thu, 16 Apr 2020 07:58:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8C9D20784 for ; Thu, 16 Apr 2020 07:58:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ihOJa4RG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440848AbgDPH5P (ORCPT ); Thu, 16 Apr 2020 03:57:15 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25772 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440794AbgDPH5F (ORCPT ); Thu, 16 Apr 2020 03:57:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587023823; 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=J/bW9r45TOwsNmE8eTZdikVBjfTc4MSQA0VtKPvgd54=; b=ihOJa4RGup7av+25PmlIlPN5MpEn6vlDwpiIg6QPPStKpNGaU/ob+Uz8Ikmxj2x0MwFPKr rvnG+3XM2JHhTwOzJiQDfJB5MDlABthJtFUFiL1W/VO6JONnkLJmgT6/ep51c9snyGINyp LHzVTeDFeKFwIcJnyW65BkE4tNLolh0= 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-148-YgMnOMW2PYamKI8TvnTRkQ-1; Thu, 16 Apr 2020 03:57:02 -0400 X-MC-Unique: YgMnOMW2PYamKI8TvnTRkQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF545801E5E; Thu, 16 Apr 2020 07:57:00 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-194.ams2.redhat.com [10.36.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 726E17E7C0; Thu, 16 Apr 2020 07:56:58 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: Stephen Rothwell , "virtualization@lists.linux-foundation.org" , Christian Borntraeger , =?utf-8?q?Eugenio_P=C3=A9re?= =?utf-8?q?z?= , Linux Next Mailing List , kvm list , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 3/8] vhost: Replace vq->private_data access by backend accesors Date: Thu, 16 Apr 2020 09:56:38 +0200 Message-Id: <20200416075643.27330-4-eperezma@redhat.com> In-Reply-To: <20200416075643.27330-1-eperezma@redhat.com> References: <20200416075643.27330-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This function still places backend directly in private_data, instead of use the accesors created on ("cbfc8f21b49a vhost: Create accessors for virtqueues private_data"). Using accesor. Fixes: ("7ce8cc28ce48 tools/virtio: Add --reset=random") Signed-off-by: Eugenio Pérez --- drivers/vhost/test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c index 251ca723ac3f..789c096e454b 100644 --- a/drivers/vhost/test.c +++ b/drivers/vhost/test.c @@ -265,7 +265,7 @@ static int vhost_test_set_features(struct vhost_test *n, u64 features) static long vhost_test_set_backend(struct vhost_test *n, unsigned index, int fd) { - static void *private_data; + static void *backend; const bool enable = fd != -1; struct vhost_virtqueue *vq; @@ -290,11 +290,11 @@ static long vhost_test_set_backend(struct vhost_test *n, unsigned index, int fd) } if (!enable) { vhost_poll_stop(&vq->poll); - private_data = vq->private_data; - vq->private_data = NULL; + backend = vhost_vq_get_backend(vq); + vhost_vq_set_backend(vq, NULL); } else { r = vhost_vq_init_access(vq); - vq->private_data = private_data; + vhost_vq_set_backend(vq, backend); if (r == 0) r = vhost_poll_start(&vq->poll, vq->kick); } From patchwork Thu Apr 16 07:56:39 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: 11492439 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 5BADD112C for ; Thu, 16 Apr 2020 07:57:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4359420784 for ; Thu, 16 Apr 2020 07:57:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dI23tCu8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440867AbgDPH5T (ORCPT ); Thu, 16 Apr 2020 03:57:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33765 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439656AbgDPH5K (ORCPT ); Thu, 16 Apr 2020 03:57:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587023828; 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=idl26PH4x2DDa3aO5wcLhHmY07eZSjGnVzySfXlVtnM=; b=dI23tCu81lGatxoSU2aGVQsy8S/w+VoaULsHIlxGtpmEwKzLH9urzLnwoHd/CpIAQSdANf 5HDBRoFZY+1XqR3eBDvMf3Z94TkrLURSAPHcAajqf8gPAK9mKFQxgYEsJJUbEkHH82ezxJ kATphb3TXdCZDIOMt9U40nVCbVqOaq4= 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-488-1NCnUh1hM8KXoG3rcApRbA-1; Thu, 16 Apr 2020 03:57:05 -0400 X-MC-Unique: 1NCnUh1hM8KXoG3rcApRbA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 988288024D6; Thu, 16 Apr 2020 07:57:03 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-194.ams2.redhat.com [10.36.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33E8B7E7C0; Thu, 16 Apr 2020 07:57:01 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: Stephen Rothwell , "virtualization@lists.linux-foundation.org" , Christian Borntraeger , =?utf-8?q?Eugenio_P=C3=A9re?= =?utf-8?q?z?= , Linux Next Mailing List , kvm list , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 4/8] vhost: Fix bad order in vhost_test_set_backend at enable Date: Thu, 16 Apr 2020 09:56:39 +0200 Message-Id: <20200416075643.27330-5-eperezma@redhat.com> In-Reply-To: <20200416075643.27330-1-eperezma@redhat.com> References: <20200416075643.27330-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The reset was not done properly: A init call was given with no active backend. This solves that. Fixes: ("7c48601a3d4d tools/virtio: Add --reset=random") Signed-off-by: Eugenio Pérez --- drivers/vhost/test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c index 789c096e454b..6aed0cab8b17 100644 --- a/drivers/vhost/test.c +++ b/drivers/vhost/test.c @@ -293,8 +293,8 @@ static long vhost_test_set_backend(struct vhost_test *n, unsigned index, int fd) backend = vhost_vq_get_backend(vq); vhost_vq_set_backend(vq, NULL); } else { - r = vhost_vq_init_access(vq); vhost_vq_set_backend(vq, backend); + r = vhost_vq_init_access(vq); if (r == 0) r = vhost_poll_start(&vq->poll, vq->kick); } From patchwork Thu Apr 16 07:56:40 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: 11492449 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 B949E112C for ; Thu, 16 Apr 2020 07:58:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9871421556 for ; Thu, 16 Apr 2020 07:58:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H4K3SBoY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441049AbgDPH6a (ORCPT ); Thu, 16 Apr 2020 03:58:30 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:33057 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440834AbgDPH5N (ORCPT ); Thu, 16 Apr 2020 03:57:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587023831; 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=ykITk4fxK46D6AMrZatD/OE634nsOv7eweYKlbWRBw8=; b=H4K3SBoYjiV3cKFwnFv+Z1ahNok6aOXZEpiakbbCQ9QBnYIYNE9kqWQNnAFTYy50k7Y/cm hNiDIEfvdFBx3qJS3RrKd6d/eoWEaGg02zRxPzG0bbxH7PtQkpWksoDHXOoTlvu4RjeHKb BSJ4QcqgdONgdlgwwu0we9RBfrVNEuI= 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-244-Hw17gpxjPcefP6o9UzMOdw-1; Thu, 16 Apr 2020 03:57:07 -0400 X-MC-Unique: Hw17gpxjPcefP6o9UzMOdw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58C73DB81; Thu, 16 Apr 2020 07:57:06 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-194.ams2.redhat.com [10.36.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF0BA7E7C0; Thu, 16 Apr 2020 07:57:03 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: Stephen Rothwell , "virtualization@lists.linux-foundation.org" , Christian Borntraeger , =?utf-8?q?Eugenio_P=C3=A9re?= =?utf-8?q?z?= , Linux Next Mailing List , kvm list , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 5/8] tools/virtio: Use __vring_new_virtqueue in virtio_test.c Date: Thu, 16 Apr 2020 09:56:40 +0200 Message-Id: <20200416075643.27330-6-eperezma@redhat.com> In-Reply-To: <20200416075643.27330-1-eperezma@redhat.com> References: <20200416075643.27330-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org As updated in ("2a2d1382fe9d virtio: Add improved queue allocation API") Signed-off-by: Eugenio Pérez --- tools/virtio/virtio_test.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index 1d5144590df6..d9827b640c21 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c @@ -106,10 +106,9 @@ static void vq_info_add(struct vdev_info *dev, int num) assert(r >= 0); memset(info->ring, 0, vring_legacy_size(num, 4096)); vring_legacy_init(&info->vring, num, info->ring, 4096); - info->vq = vring_new_virtqueue(info->idx, - info->vring.num, 4096, &dev->vdev, - true, false, info->ring, - vq_notify, vq_callback, "test"); + info->vq = + __vring_new_virtqueue(info->idx, info->vring, &dev->vdev, true, + false, vq_notify, vq_callback, "test"); assert(info->vq); info->vq->priv = info; vhost_vq_setup(dev, info); From patchwork Thu Apr 16 07:56:41 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: 11492441 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 72675112C for ; Thu, 16 Apr 2020 07:57:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A6ED21556 for ; Thu, 16 Apr 2020 07:57:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ikHbNatU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440876AbgDPH5W (ORCPT ); Thu, 16 Apr 2020 03:57:22 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:29910 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440796AbgDPH5Q (ORCPT ); Thu, 16 Apr 2020 03:57:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587023835; 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=gavfKGuNl7br7RXb7XSyuq0WG8m5khS0l1y8vD9u01c=; b=ikHbNatUX9nVUVc6CTbYhlzguMdMZMUBksI0SW2Mq1myzpmOwamfePmbjoQo/SsdXhiM+2 C4FBWNGtTwrAhS3DzeRO7kWAE/pDYxoRH1bTH9PNzEz6IyhM47GiOB/CbbLrMxu+dFkPcU Bqx2ywR90guDVMWEi4nm8iyuNnDJAxE= 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-500-tkGFXRgxOSOh6b_CqJMs6A-1; Thu, 16 Apr 2020 03:57:13 -0400 X-MC-Unique: tkGFXRgxOSOh6b_CqJMs6A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C72601005509; Thu, 16 Apr 2020 07:57:11 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-194.ams2.redhat.com [10.36.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67EA37E7C0; Thu, 16 Apr 2020 07:57:06 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: Stephen Rothwell , "virtualization@lists.linux-foundation.org" , Christian Borntraeger , =?utf-8?q?Eugenio_P=C3=A9re?= =?utf-8?q?z?= , Linux Next Mailing List , kvm list , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 6/8] tools/virtio: Extract virtqueue initialization in vq_reset Date: Thu, 16 Apr 2020 09:56:41 +0200 Message-Id: <20200416075643.27330-7-eperezma@redhat.com> In-Reply-To: <20200416075643.27330-1-eperezma@redhat.com> References: <20200416075643.27330-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org So we can reset after that in the main loop. Signed-off-by: Eugenio Pérez --- tools/virtio/virtio_test.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index d9827b640c21..18d5347003eb 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c @@ -95,6 +95,19 @@ void vhost_vq_setup(struct vdev_info *dev, struct vq_info *info) assert(r >= 0); } +static void vq_reset(struct vq_info *info, int num, struct virtio_device *vdev) +{ + if (info->vq) + vring_del_virtqueue(info->vq); + + memset(info->ring, 0, vring_legacy_size(num, 4096)); + vring_legacy_init(&info->vring, num, info->ring, 4096); + info->vq = __vring_new_virtqueue(info->idx, info->vring, vdev, true, + false, vq_notify, vq_callback, "test"); + assert(info->vq); + info->vq->priv = info; +} + static void vq_info_add(struct vdev_info *dev, int num) { struct vq_info *info = &dev->vqs[dev->nvqs]; @@ -104,13 +117,7 @@ static void vq_info_add(struct vdev_info *dev, int num) info->call = eventfd(0, EFD_NONBLOCK); r = posix_memalign(&info->ring, 4096, vring_legacy_size(num, 4096)); assert(r >= 0); - memset(info->ring, 0, vring_legacy_size(num, 4096)); - vring_legacy_init(&info->vring, num, info->ring, 4096); - info->vq = - __vring_new_virtqueue(info->idx, info->vring, &dev->vdev, true, - false, vq_notify, vq_callback, "test"); - assert(info->vq); - info->vq->priv = info; + vq_reset(info, num, &dev->vdev); vhost_vq_setup(dev, info); dev->fds[info->idx].fd = info->call; dev->fds[info->idx].events = POLLIN; From patchwork Thu Apr 16 07:56:42 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: 11492445 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 C0D4415AB for ; Thu, 16 Apr 2020 07:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7E5F20784 for ; Thu, 16 Apr 2020 07:58:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AaSOw14X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440875AbgDPH6K (ORCPT ); Thu, 16 Apr 2020 03:58:10 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:45820 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439911AbgDPH5S (ORCPT ); Thu, 16 Apr 2020 03:57:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587023837; 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=bdhOBCEl4eFdpUqKoAGyqIbQDwv6pzTPA4cNsDQtl/I=; b=AaSOw14XwCg/BlhRgsJ3uVtEfBSLw+rFa/fDuF8pge/afty9J/Ey48Cp9IV8DQ/2OXQrI6 9T8nQo9wI+ND0rkQxl5NeuKoU8UOd2QTRMQsFccoKVAzWfS+F9Lzq7EzvRNutS50a0fx7y rsA5oZqJwWTrKkc/x74/32bzk/YzWI8= 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-288-6j42YKquNzOJyXnjBZ3A_A-1; Thu, 16 Apr 2020 03:57:15 -0400 X-MC-Unique: 6j42YKquNzOJyXnjBZ3A_A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89DE91005509; Thu, 16 Apr 2020 07:57:14 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-194.ams2.redhat.com [10.36.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D4817E7C0; Thu, 16 Apr 2020 07:57:11 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: Stephen Rothwell , "virtualization@lists.linux-foundation.org" , Christian Borntraeger , =?utf-8?q?Eugenio_P=C3=A9re?= =?utf-8?q?z?= , Linux Next Mailing List , kvm list , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 7/8] tools/virtio: Reset index in virtio_test --reset. Date: Thu, 16 Apr 2020 09:56:42 +0200 Message-Id: <20200416075643.27330-8-eperezma@redhat.com> In-Reply-To: <20200416075643.27330-1-eperezma@redhat.com> References: <20200416075643.27330-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This way behavior for vhost is more like a VM. Signed-off-by: Eugenio Pérez --- 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 = { .fd = -1 }, backend = { .fd = 1 }; +static const struct vhost_vring_state null_state = {}; bool vq_notify(struct virtqueue *vq) { @@ -174,14 +174,19 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, unsigned len; long long spurious = 0; const bool random_batch = batch == RANDOM_BATCH; + r = ioctl(dev->control, VHOST_TEST_RUN, &test); assert(r >= 0); + if (!reset_n) { + next_reset = INT_MAX; + } + for (;;) { virtqueue_disable_cb(vq->vq); completed_before = completed; started_before = started; do { - const bool reset = reset_n && completed > next_reset; + const bool reset = completed > next_reset; if (random_batch) batch = (random() % vq->vring.num) + 1; @@ -224,10 +229,24 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, } if (reset) { + struct vhost_vring_state s = { .index = 0 }; + + vq_reset(vq, vq->vring.num, &dev->vdev); + + r = ioctl(dev->control, VHOST_GET_VRING_BASE, + &s); + assert(!r); + + s.num = 0; + r = ioctl(dev->control, VHOST_SET_VRING_BASE, + &null_state); + assert(!r); + r = ioctl(dev->control, VHOST_TEST_SET_BACKEND, &backend); assert(!r); + started = completed; while (completed > next_reset) next_reset += completed; } @@ -249,7 +268,9 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, test = 0; r = ioctl(dev->control, VHOST_TEST_RUN, &test); assert(r >= 0); - fprintf(stderr, "spurious wakeups: 0x%llx\n", spurious); + fprintf(stderr, + "spurious wakeups: 0x%llx started=0x%lx completed=0x%lx\n", + spurious, started, completed); } const char optstring[] = "h"; @@ -312,7 +333,7 @@ static void help(void) " [--no-virtio-1]" " [--delayed-interrupt]" " [--batch=random/N]" - " [--reset=random/N]" + " [--reset=N]" "\n"); } @@ -360,11 +381,9 @@ int main(int argc, char **argv) case 'r': if (!optarg) { reset = 1; - } else if (0 == strcmp(optarg, "random")) { - reset = RANDOM_RESET; } else { reset = strtol(optarg, NULL, 10); - assert(reset >= 0); + assert(reset > 0); assert(reset < (long)INT_MAX + 1); } break; From patchwork Thu Apr 16 07:56:43 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: 11492443 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 BF67315AB for ; Thu, 16 Apr 2020 07:57:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7B0021556 for ; Thu, 16 Apr 2020 07:57:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GjTJXd4m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440184AbgDPH5c (ORCPT ); Thu, 16 Apr 2020 03:57:32 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42036 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440874AbgDPH5X (ORCPT ); Thu, 16 Apr 2020 03:57:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587023842; 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=payC5JiVreqHkU2B+K9UiLU+mY+GY4f5CPsBYBzyoLA=; b=GjTJXd4mzA2ISq4r3dZkf15+bwSangu3mJWzkolir83A9Wq72cMeiIvnyYREKkPsth+/zB VGA6Z4bgpKsqjibxdoTDcRhaIus0LEFdLJ/lAK7qoJhFimFdfeVRO0mPWGM9c83kdwvulh r8Rj76Xce9acMm7CJELrqoOWrKsIRAs= 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-179-A3DgaoqiOKqhn-19x2antg-1; Thu, 16 Apr 2020 03:57:18 -0400 X-MC-Unique: A3DgaoqiOKqhn-19x2antg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 461FF107ACC9; Thu, 16 Apr 2020 07:57:17 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-194.ams2.redhat.com [10.36.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id E34AD7E7C0; Thu, 16 Apr 2020 07:57:14 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: Stephen Rothwell , "virtualization@lists.linux-foundation.org" , Christian Borntraeger , =?utf-8?q?Eugenio_P=C3=A9re?= =?utf-8?q?z?= , Linux Next Mailing List , kvm list , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 8/8] tools/virtio: Use tools/include/list.h instead of stubs Date: Thu, 16 Apr 2020 09:56:43 +0200 Message-Id: <20200416075643.27330-9-eperezma@redhat.com> In-Reply-To: <20200416075643.27330-1-eperezma@redhat.com> References: <20200416075643.27330-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org It should not make any significant difference but reduce stub code. Signed-off-by: Eugenio Pérez --- tools/virtio/linux/kernel.h | 7 +------ tools/virtio/linux/virtio.h | 5 ++--- tools/virtio/virtio_test.c | 1 + tools/virtio/vringh_test.c | 2 ++ 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h index 6683b4a70b05..caab980211a6 100644 --- a/tools/virtio/linux/kernel.h +++ b/tools/virtio/linux/kernel.h @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -135,10 +136,4 @@ static inline void free_page(unsigned long addr) (void) (&_min1 == &_min2); \ _min1 < _min2 ? _min1 : _min2; }) -/* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ -#define list_add_tail(a, b) do {} while (0) -#define list_del(a) do {} while (0) -#define list_for_each_entry(a, b, c) while (0) -/* end of stubs */ - #endif /* KERNEL_H */ diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h index b751350d4ce8..5d90254ddae4 100644 --- a/tools/virtio/linux/virtio.h +++ b/tools/virtio/linux/virtio.h @@ -11,12 +11,11 @@ struct device { struct virtio_device { struct device dev; u64 features; + struct list_head vqs; }; struct virtqueue { - /* TODO: commented as list macros are empty stubs for now. - * Broken but enough for virtio_ring.c - * struct list_head list; */ + struct list_head list; void (*callback)(struct virtqueue *vq); const char *name; struct virtio_device *vdev; diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index dca64d36a882..c0b924b41a1d 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c @@ -129,6 +129,7 @@ static void vdev_info_init(struct vdev_info* dev, unsigned long long features) int r; memset(dev, 0, sizeof *dev); dev->vdev.features = features; + INIT_LIST_HEAD(&dev->vdev.vqs); dev->buf_size = 1024; dev->buf = malloc(dev->buf_size); assert(dev->buf); diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c index 8ee2c9a6ad46..b88b0337fcfd 100644 --- a/tools/virtio/vringh_test.c +++ b/tools/virtio/vringh_test.c @@ -307,6 +307,7 @@ static int parallel_test(u64 features, close(to_host[0]); gvdev.vdev.features = features; + INIT_LIST_HEAD(&gvdev.vdev.vqs); gvdev.to_host_fd = to_host[1]; gvdev.notifies = 0; @@ -453,6 +454,7 @@ int main(int argc, char *argv[]) getrange = getrange_iov; vdev.features = 0; + INIT_LIST_HEAD(&vdev.vqs); while (argv[1]) { if (strcmp(argv[1], "--indirect") == 0)