From patchwork Fri Apr 3 16:51:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 11473165 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 EC1B0159A for ; Fri, 3 Apr 2020 16:51:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9AD12073B for ; Fri, 3 Apr 2020 16:51:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ds4VvLH3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404079AbgDCQvh (ORCPT ); Fri, 3 Apr 2020 12:51:37 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:29905 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728095AbgDCQvg (ORCPT ); Fri, 3 Apr 2020 12:51:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585932695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=8Hv0uUrFnNOWfNc5i6u80voUI6IiFg7M4Etc0ppl07Y=; b=ds4VvLH3+Sh9Hk19DflQBHvy2Gdi90rDBdVMyLk0v/YaYifgHng8AZRaf6iblvCFg/C9+f 8P0LXm/jNCpGrHtoRPWSFr9g99C/o0TKDllI+KudYXIYhH4mDez0+EN5Rmr/+XmaUApCXu /9hJQyDjbU1ec8b17j/jg+EaFWNhI78= 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-369-z1n5TK3VMjumBR5MSHdrIQ-1; Fri, 03 Apr 2020 12:51:33 -0400 X-MC-Unique: z1n5TK3VMjumBR5MSHdrIQ-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 7EDF7DBA6; Fri, 3 Apr 2020 16:51:31 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F7CC18A85; Fri, 3 Apr 2020 16:51:28 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: kvm list , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , =?utf-8?q?Eugenio_P?= =?utf-8?q?=C3=A9rez?= , Stephen Rothwell , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" , Christian Borntraeger Subject: [PATCH 1/8] tools/virtio: fix virtio_test.c indentation Date: Fri, 3 Apr 2020 18:51:12 +0200 Message-Id: <20200403165119.5030-2-eperezma@redhat.com> In-Reply-To: <20200403165119.5030-1-eperezma@redhat.com> References: <20200403165119.5030-1-eperezma@redhat.com> 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 --- 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 93d81cd64ba0..38aa5316b266 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 Fri Apr 3 16:51:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 11473167 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 57853159A for ; Fri, 3 Apr 2020 16:51:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 368F02080C for ; Fri, 3 Apr 2020 16:51:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f/6K9izj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404154AbgDCQvm (ORCPT ); Fri, 3 Apr 2020 12:51:42 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:33662 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404137AbgDCQvm (ORCPT ); Fri, 3 Apr 2020 12:51:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585932701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=8YeWmblf5mS/8GdUhzLA4Htge8P1tK+DUvfsT44OWM8=; b=f/6K9izjQnUQFRZnEsR0ubNwaAJpsOYQ/Erf6Ibj3qVr74HSoNkmuiN8eSA6bKwuqwoi7t AoOWD0LW1HDZrjdCjZx/9vAprjcyvs0P9YgsdHmZoCQkbyVWL9jBXK9B30BzzmxEP9T0KV tKwjZvtB41RCva+mMIZDVzMAcE7vOOM= 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-452-4k1-NX7ePo2t4I62hjtMTw-1; Fri, 03 Apr 2020 12:51:39 -0400 X-MC-Unique: 4k1-NX7ePo2t4I62hjtMTw-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 4758D1005513; Fri, 3 Apr 2020 16:51:38 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE378A0A7B; Fri, 3 Apr 2020 16:51:31 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: kvm list , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , =?utf-8?q?Eugenio_P?= =?utf-8?q?=C3=A9rez?= , Stephen Rothwell , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" , Christian Borntraeger Subject: [PATCH 2/8] vhost: Not cleaning batched descs in VHOST_SET_VRING_BASE ioctl Date: Fri, 3 Apr 2020 18:51:13 +0200 Message-Id: <20200403165119.5030-3-eperezma@redhat.com> In-Reply-To: <20200403165119.5030-1-eperezma@redhat.com> References: <20200403165119.5030-1-eperezma@redhat.com> 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 --- 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 Fri Apr 3 16:51:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 11473171 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 836ED15AB for ; Fri, 3 Apr 2020 16:51:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 589852082F for ; Fri, 3 Apr 2020 16:51:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OzVJcL7q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404620AbgDCQvs (ORCPT ); Fri, 3 Apr 2020 12:51:48 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:27936 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404613AbgDCQvs (ORCPT ); Fri, 3 Apr 2020 12:51:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585932707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=+TgfKjPk2T5P2zzuaFMRdLZ3Utt6NiSkelGon/Wg0oc=; b=OzVJcL7qOcIYL33LSHySLcAKoI7sIzm7Rd72AEXFnfSEvB4WIOjK1oXvccXrRb2VWRKQTc ZNEVshkJDjj6+w8YVOvhXx6cAeTwtlln+LQf0P04sPr0I6FYVOFILWbTruOjXaN+fgKWq+ +NJoBmg5IutN/SF8nSiHYOmMdcarUuA= 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-117-FS9jkDrXPjKkupA58dS5qg-1; Fri, 03 Apr 2020 12:51:42 -0400 X-MC-Unique: FS9jkDrXPjKkupA58dS5qg-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 2655A1005F82; Fri, 3 Apr 2020 16:51:41 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id A450A18A85; Fri, 3 Apr 2020 16:51:38 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: kvm list , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , =?utf-8?q?Eugenio_P?= =?utf-8?q?=C3=A9rez?= , Stephen Rothwell , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" , Christian Borntraeger Subject: [PATCH 3/8] vhost: Replace vq->private_data access by backend accesors Date: Fri, 3 Apr 2020 18:51:14 +0200 Message-Id: <20200403165119.5030-4-eperezma@redhat.com> In-Reply-To: <20200403165119.5030-1-eperezma@redhat.com> References: <20200403165119.5030-1-eperezma@redhat.com> 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 --- 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 Fri Apr 3 16:51:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 11473169 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 4F3E71392 for ; Fri, 3 Apr 2020 16:51:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D3D52082F for ; Fri, 3 Apr 2020 16:51:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ab/mhgdl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404627AbgDCQvu (ORCPT ); Fri, 3 Apr 2020 12:51:50 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:54235 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404173AbgDCQvu (ORCPT ); Fri, 3 Apr 2020 12:51:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585932709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=2SJcOix8Fae6FyLtzcXlO0OaUSu2FwzPh/mvZNztQFQ=; b=ab/mhgdlvSO0cH38joT/STX/g8p/yAn3iL2mKt3G62CegEHFGu96apiJ3E/62D/iJ5afwl Yfh/+mKsy48hS6dGoiDpufhW9CD7Z0+00bZ3BNWWtF6CfhubNO6FUrOl4pGOld5n5bB2Hh A3vjAn3ZUMQflqThfMVB4WQJ5YyJ8ag= 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-353-Ndb9pVMBPAuljmrtVMmZdA-1; Fri, 03 Apr 2020 12:51:45 -0400 X-MC-Unique: Ndb9pVMBPAuljmrtVMmZdA-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 F1E8113F8; Fri, 3 Apr 2020 16:51:43 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8583718A85; Fri, 3 Apr 2020 16:51:41 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: kvm list , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , =?utf-8?q?Eugenio_P?= =?utf-8?q?=C3=A9rez?= , Stephen Rothwell , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" , Christian Borntraeger Subject: [PATCH 4/8] vhost: Fix bad order in vhost_test_set_backend at enable Date: Fri, 3 Apr 2020 18:51:15 +0200 Message-Id: <20200403165119.5030-5-eperezma@redhat.com> In-Reply-To: <20200403165119.5030-1-eperezma@redhat.com> References: <20200403165119.5030-1-eperezma@redhat.com> 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 Fixes: ("7c48601a3d4d tools/virtio: Add --reset=random") --- 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 Fri Apr 3 16:51:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 11473173 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 11307159A for ; Fri, 3 Apr 2020 16:51:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA43221556 for ; Fri, 3 Apr 2020 16:51:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QrzQqfnJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404632AbgDCQvx (ORCPT ); Fri, 3 Apr 2020 12:51:53 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:30134 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404628AbgDCQvx (ORCPT ); Fri, 3 Apr 2020 12:51:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585932712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=X2YzNwxGjX7RUhG5xjgh2bTQxpqtEuU8/vbNLpGIK/g=; b=QrzQqfnJv5fA715dt86lvJaMgkn/mrTYiNetcwvHgBJrIV7GtAkcvKolrXoXy48yY+4na7 2s0YHJRMlMsZATy1EBnkjh/WR4QyFAb2xlG1LVbYbFX4Y1zKJWiN/p08RxRn5h+9QOavW8 8H3vTrL/ICRyosfotzP9hAVVDONoBB8= 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-297-mnMUANtrPPeJ7OnLqubzmg-1; Fri, 03 Apr 2020 12:51:50 -0400 X-MC-Unique: mnMUANtrPPeJ7OnLqubzmg-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 42B718017CE; Fri, 3 Apr 2020 16:51:49 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8B0418A85; Fri, 3 Apr 2020 16:51:44 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: kvm list , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , =?utf-8?q?Eugenio_P?= =?utf-8?q?=C3=A9rez?= , Stephen Rothwell , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" , Christian Borntraeger Subject: [PATCH 5/8] tools/virtio: Use __vring_new_virtqueue in virtio_test.c Date: Fri, 3 Apr 2020 18:51:16 +0200 Message-Id: <20200403165119.5030-6-eperezma@redhat.com> In-Reply-To: <20200403165119.5030-1-eperezma@redhat.com> References: <20200403165119.5030-1-eperezma@redhat.com> 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 --- 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 38aa5316b266..9b730434997c 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_size(num, 4096)); vring_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 Fri Apr 3 16:51:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 11473177 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 7CE931392 for ; Fri, 3 Apr 2020 16:52:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BD1821556 for ; Fri, 3 Apr 2020 16:52:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CPt4LxMl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404650AbgDCQv7 (ORCPT ); Fri, 3 Apr 2020 12:51:59 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:57892 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404638AbgDCQv4 (ORCPT ); Fri, 3 Apr 2020 12:51:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585932715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=nk4IMYZH5hA+grx8NX+gdSGbc36TSHy3mPL/TXH5NwQ=; b=CPt4LxMlUXUh/kRvw4h113OMEcm4GnyN4dGfbClB4gozyVaZgWxdBJ9KHQXaPkDOriss8g jJ26GEklJPIBCKkKNDEHyEqtlE7Gp7xjonEagbZDNVjyw06n3B9bYwYQA2Py1nqBTXOdiD ai7thVuO9skmahwZYKe6Hq2OC3s0RBc= 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-463-bacAC-9KM1GftEvSI7fyMA-1; Fri, 03 Apr 2020 12:51:53 -0400 X-MC-Unique: bacAC-9KM1GftEvSI7fyMA-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 19AB2800D53; Fri, 3 Apr 2020 16:51:52 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id A058518A85; Fri, 3 Apr 2020 16:51:49 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: kvm list , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , =?utf-8?q?Eugenio_P?= =?utf-8?q?=C3=A9rez?= , Stephen Rothwell , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" , Christian Borntraeger Subject: [PATCH 6/8] tools/virtio: Extract virtqueue initialization in vq_reset Date: Fri, 3 Apr 2020 18:51:17 +0200 Message-Id: <20200403165119.5030-7-eperezma@redhat.com> In-Reply-To: <20200403165119.5030-1-eperezma@redhat.com> References: <20200403165119.5030-1-eperezma@redhat.com> 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 --- 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 9b730434997c..7b7829e510c0 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_size(num, 4096)); + vring_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_size(num, 4096)); assert(r >= 0); - memset(info->ring, 0, vring_size(num, 4096)); - vring_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 Fri Apr 3 16:51:18 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: 11473179 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 935D1159A for ; Fri, 3 Apr 2020 16:52:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 721BB21655 for ; Fri, 3 Apr 2020 16:52:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="apAArPAa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404018AbgDCQwN (ORCPT ); Fri, 3 Apr 2020 12:52:13 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38095 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404629AbgDCQv7 (ORCPT ); Fri, 3 Apr 2020 12:51:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585932718; 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=dbrbXbuWyZrlOy+yoiqtbmywqt31syCjQq35ukfw0g0=; b=apAArPAaviI2tLrTHj1ai+SlvOL7M8yMKC8WEedKur3dBzOKOtgt97f7Tf902P+O12q/PO +If1xKSKhg3NRk6swXbUQLYFqWtgb+D5kUdezEMyiDDJ07+MowPP3SpJAs+zJB1hvZERsJ OoC1LKUrY6Xx/pKDuOEjemR2o9J0W8E= 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-292-Z_cMZfXAOEaxuRn1K_5rog-1; Fri, 03 Apr 2020 12:51:56 -0400 X-MC-Unique: Z_cMZfXAOEaxuRn1K_5rog-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 E7DD48018A8; Fri, 3 Apr 2020 16:51:54 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76E8D18A85; Fri, 3 Apr 2020 16:51:52 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: kvm list , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , =?utf-8?q?Eugenio_P?= =?utf-8?q?=C3=A9rez?= , Stephen Rothwell , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" , Christian Borntraeger Subject: [PATCH 7/8] tools/virtio: Reset index in virtio_test --reset. Date: Fri, 3 Apr 2020 18:51:18 +0200 Message-Id: <20200403165119.5030-8-eperezma@redhat.com> In-Reply-To: <20200403165119.5030-1-eperezma@redhat.com> References: <20200403165119.5030-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 7b7829e510c0..82902fc3ba2a 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 Fri Apr 3 16:51:19 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: 11473175 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 207FF159A for ; Fri, 3 Apr 2020 16:52:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F27202073B for ; Fri, 3 Apr 2020 16:52:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="D3ya/KDK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404658AbgDCQwJ (ORCPT ); Fri, 3 Apr 2020 12:52:09 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:57792 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404665AbgDCQwD (ORCPT ); Fri, 3 Apr 2020 12:52:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585932722; 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=yMmscrcPxrNtAuLRokAXM6YRXQcJoZNIY/bvDej50a4=; b=D3ya/KDKovjr2j4dzy2vJxLMQy9g4MMIfR9kNlpY82Wcjyk0gR5kQPbsXBey3rjZDLavPD Fkh6LvtZAARe7xpeEv5HkxFzW9KqfiA3AsA656fW81H+6rdruktP44ROs2me3L8ObGY/9o R23cbmj5EkznY6yjc5xBi/aeU2uvhLw= 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-93-22eF_FI-NECPEOFPgRuKEw-1; Fri, 03 Apr 2020 12:51:59 -0400 X-MC-Unique: 22eF_FI-NECPEOFPgRuKEw-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 BAABD477; Fri, 3 Apr 2020 16:51:57 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50155A0A7B; Fri, 3 Apr 2020 16:51:55 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: kvm list , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , =?utf-8?q?Eugenio_P?= =?utf-8?q?=C3=A9rez?= , Stephen Rothwell , Cornelia Huck , Halil Pasic , "linux-kernel@vger.kernel.org" , Christian Borntraeger Subject: [PATCH 8/8] tools/virtio: Use tools/include/list.h instead of stubs Date: Fri, 3 Apr 2020 18:51:19 +0200 Message-Id: <20200403165119.5030-9-eperezma@redhat.com> In-Reply-To: <20200403165119.5030-1-eperezma@redhat.com> References: <20200403165119.5030-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 82902fc3ba2a..cb3f29c09aff 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 293653463303..fa87b58bd5fa 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)