From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C9E3DA0542 for ; Fri, 11 Nov 2022 11:34:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C60D342D14; Fri, 11 Nov 2022 11:34:31 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id C8FD742D15 for ; Fri, 11 Nov 2022 11:34:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668162870; 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=cYd1bFBc84/ICfpxEEN7TyhLSsx29nvLH5RNtevjtFw=; b=WYQ2sW00t6d4PCNDt86O+5BYXTK+k+ptQEHVhGSe+oftHWl8w+sWvayCZiQGxoi80V1m5T JE5rpPx2Shsl6IFlJKoYD88g+gdQChCOAzYk/MZoX21Bi0CCS+zUeAjc1V4sC+qksivtVJ UrSIRfJt3mkBBa15q8ilP6i5eFu0i0c= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-649-zDhrngNYPXW5OEjUwVwTcw-1; Fri, 11 Nov 2022 05:34:29 -0500 X-MC-Unique: zDhrngNYPXW5OEjUwVwTcw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E69691C05EA6; Fri, 11 Nov 2022 10:34:28 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.195.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id CADE2200E288; Fri, 11 Nov 2022 10:34:27 +0000 (UTC) From: Kevin Traynor To: Changpeng Liu Cc: Chenbo Xia , dpdk stable Subject: patch 'vhost: add non-blocking API for posting interrupt' has been queued to stable release 21.11.3 Date: Fri, 11 Nov 2022 10:33:06 +0000 Message-Id: <20221111103337.307408-16-ktraynor@redhat.com> In-Reply-To: <20221111103337.307408-1-ktraynor@redhat.com> References: <20221111103337.307408-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/14/22. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/a5ff9ebc8b9bb626f31cf9df83b1ae83cfd629dc Thanks. Kevin --- >From a5ff9ebc8b9bb626f31cf9df83b1ae83cfd629dc Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Mon, 17 Oct 2022 15:48:17 +0800 Subject: [PATCH] vhost: add non-blocking API for posting interrupt [ upstream commit 830f7e790732b3a4b8830b181d399e317098d291 ] Vhost-user library locks all VQ's access lock when processing vring based messages, such as SET_VRING_KICK and SET_VRING_CALL, and the data processing thread may already be started, e.g: SPDK vhost-blk and vhost-scsi will start the data processing thread when one vring is ready, then deadlock may happen when SPDK is posting interrupts to VM. Here, we add a new API which allows caller to try again later for this case. Bugzilla ID: 1015 Fixes: c5736998305d ("vhost: fix missing virtqueue lock protection") Signed-off-by: Changpeng Liu Reviewed-by: Chenbo Xia --- doc/guides/prog_guide/vhost_lib.rst | 6 ++++++ lib/vhost/rte_vhost.h | 15 +++++++++++++++ lib/vhost/version.map | 1 + lib/vhost/vhost.c | 30 +++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst index 8959568d8f..6ad1afa378 100644 --- a/doc/guides/prog_guide/vhost_lib.rst +++ b/doc/guides/prog_guide/vhost_lib.rst @@ -304,4 +304,10 @@ The following is an overview of some key Vhost API functions: path. Completed packets are returned to applications through ``pkts``. +* ``rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx)`` + + Notify the guest that used descriptors have been added to the vring. This function + will return -EAGAIN when vq's access lock is held by other thread, user should try + again later. + Vhost-user Implementations -------------------------- diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h index 2acb31df2d..1582617423 100644 --- a/lib/vhost/rte_vhost.h +++ b/lib/vhost/rte_vhost.h @@ -919,4 +919,19 @@ rte_vhost_clr_inflight_desc_packed(int vid, uint16_t vring_idx, int rte_vhost_vring_call(int vid, uint16_t vring_idx); +/** + * Notify the guest that used descriptors have been added to the vring. This + * function acts as a memory barrier. This function will return -EAGAIN when + * vq's access lock is held by other thread, user should try again later. + * + * @param vid + * vhost device ID + * @param vring_idx + * vring index + * @return + * 0 on success, -1 on failure, -EAGAIN for another retry + */ +__rte_experimental +int rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx); + /** * Get vhost RX queue avail count. diff --git a/lib/vhost/version.map b/lib/vhost/version.map index 0f315ed2a5..2cd6ea8a29 100644 --- a/lib/vhost/version.map +++ b/lib/vhost/version.map @@ -85,4 +85,5 @@ EXPERIMENTAL { # added in 21.11 rte_vhost_get_monitor_addr; + rte_vhost_vring_call_nonblock; }; diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 24f94495c6..86672fcc33 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1312,4 +1312,34 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx) } +int +rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx) +{ + struct virtio_net *dev; + struct vhost_virtqueue *vq; + + dev = get_device(vid); + if (!dev) + return -1; + + if (vring_idx >= VHOST_MAX_VRING) + return -1; + + vq = dev->virtqueue[vring_idx]; + if (!vq) + return -1; + + if (!rte_spinlock_trylock(&vq->access_lock)) + return -EAGAIN; + + if (vq_is_packed(dev)) + vhost_vring_call_packed(dev, vq); + else + vhost_vring_call_split(dev, vq); + + rte_spinlock_unlock(&vq->access_lock); + + return 0; +} + uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id) -- 2.38.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-11 10:32:17.471053637 +0000 +++ 0016-vhost-add-non-blocking-API-for-posting-interrupt.patch 2022-11-11 10:32:17.037300619 +0000 @@ -1 +1 @@ -From 830f7e790732b3a4b8830b181d399e317098d291 Mon Sep 17 00:00:00 2001 +From a5ff9ebc8b9bb626f31cf9df83b1ae83cfd629dc Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 830f7e790732b3a4b8830b181d399e317098d291 ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -21,6 +22,5 @@ - doc/guides/prog_guide/vhost_lib.rst | 6 ++++++ - doc/guides/rel_notes/release_22_11.rst | 6 ++++++ - lib/vhost/rte_vhost.h | 15 +++++++++++++ - lib/vhost/version.map | 1 + - lib/vhost/vhost.c | 30 ++++++++++++++++++++++++++ - 5 files changed, 58 insertions(+) + doc/guides/prog_guide/vhost_lib.rst | 6 ++++++ + lib/vhost/rte_vhost.h | 15 +++++++++++++++ + lib/vhost/version.map | 1 + + lib/vhost/vhost.c | 30 +++++++++++++++++++++++++++++ + 4 files changed, 52 insertions(+) @@ -29 +29 @@ -index 0d9eca1f7d..e8bb8c9b7b 100644 +index 8959568d8f..6ad1afa378 100644 @@ -32 +32 @@ -@@ -298,4 +298,10 @@ The following is an overview of some key Vhost API functions: +@@ -304,4 +304,10 @@ The following is an overview of some key Vhost API functions: @@ -41,17 +41,2 @@ - * ``rte_vhost_vring_stats_get_names(int vid, uint16_t queue_id, struct rte_vhost_stat_name *names, unsigned int size)`` - -diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst -index c62acde891..6722832f3f 100644 ---- a/doc/guides/rel_notes/release_22_11.rst -+++ b/doc/guides/rel_notes/release_22_11.rst -@@ -189,4 +189,10 @@ New Features - by the vhost library. - -+* **Added non-blocking notify API to vhost library.** -+ -+ Added ``rte_vhost_vring_call_nonblock`` API to notify the guest that -+ used descriptors have been added to the vring in non-blocking way. -+ User should check the return value of this API and try again if needed. -+ - * **Added support for MACsec in rte_security.** - + Vhost-user Implementations + -------------------------- @@ -59 +44 @@ -index bb7d86a432..d22b25cd4e 100644 +index 2acb31df2d..1582617423 100644 @@ -62 +47 @@ -@@ -910,4 +910,19 @@ rte_vhost_clr_inflight_desc_packed(int vid, uint16_t vring_idx, +@@ -919,4 +919,19 @@ rte_vhost_clr_inflight_desc_packed(int vid, uint16_t vring_idx, @@ -83 +68 @@ -index 0b61870870..d64786fa71 100644 +index 0f315ed2a5..2cd6ea8a29 100644 @@ -86,3 +71,3 @@ -@@ -98,4 +98,5 @@ EXPERIMENTAL { - # added in 22.11 - rte_vhost_async_dma_unconfigure; +@@ -85,4 +85,5 @@ EXPERIMENTAL { + # added in 21.11 + rte_vhost_get_monitor_addr; @@ -93 +78 @@ -index 1bb01c2a2e..19c7b92c32 100644 +index 24f94495c6..86672fcc33 100644 @@ -96 +81 @@ -@@ -1319,4 +1319,34 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx) +@@ -1312,4 +1312,34 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)