patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Hao Chen <chenh@yusur.tech>
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>,
	dpdk stable <stable@dpdk.org>
Subject: patch 'vhost: fix deadlock during vDPA SW live migration' has been queued to stable release 21.11.7
Date: Tue,  5 Mar 2024 15:34:02 +0000	[thread overview]
Message-ID: <20240305153449.263666-29-ktraynor@redhat.com> (raw)
In-Reply-To: <20240305153449.263666-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to stable release 21.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/11/24. 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/15afe0935f9e0e6e216bfee114c0e17855899bea

Thanks.

Kevin

---
From 15afe0935f9e0e6e216bfee114c0e17855899bea Mon Sep 17 00:00:00 2001
From: Hao Chen <chenh@yusur.tech>
Date: Mon, 22 Jan 2024 11:27:44 +0800
Subject: [PATCH] vhost: fix deadlock during vDPA SW live migration

[ upstream commit 19639c3b693bcfdc941c56d9d5bd60f65a8eeecb ]

In a nested virtualization environment, running dpdk-vdpa
in QEMU-L1 for software live migration will result in a
deadlock between dpdk-vdpa and QEMU-L2 processes.
'rte_vdpa_relay_vring_used'->
'__vhost_iova_to_vva'->
'vhost_user_iotlb_rd_unlock(vq)'->
'vhost_user_iotlb_miss'-> send vhost message
'VHOST_USER_SLAVE_IOTLB_MSG' to QEMU-L2's vdpa socket, then
call 'vhost_user_iotlb_rd_lock(vq)' to hold the read lock
`iotlb_lock`.

But there is no place to release this read lock.

QEMU-L2 get the 'VHOST_USER_SLAVE_IOTLB_MSG', then call
'vhost_user_send_device_iotlb_msg' to send
'VHOST_USER_IOTLB_MSG' messages to dpdk-vdpa.

dpdk-vdpa will call vhost_user_iotlb_cache_insert and will
obtain the write lock `iotlb_lock`, but the read lock
`iotlb_lock` has not been released and will block here.

This patch add lock and unlock function to fix the deadlock.

Fixes: b13ad2decc83 ("vhost: provide helpers for virtio ring relay")

Signed-off-by: Hao Chen <chenh@yusur.tech>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/vhost/vdpa.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/vhost/vdpa.c b/lib/vhost/vdpa.c
index 09ad5d866e..bd00c9d2c2 100644
--- a/lib/vhost/vdpa.c
+++ b/lib/vhost/vdpa.c
@@ -20,4 +20,5 @@
 #include "vdpa_driver.h"
 #include "vhost.h"
+#include "iotlb.h"
 
 /** Double linked list of vDPA devices. */
@@ -177,15 +178,19 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
 				return -1;
 
+			vhost_user_iotlb_rd_lock(vq);
 			desc_ring = (struct vring_desc *)(uintptr_t)
 				vhost_iova_to_vva(dev, vq,
 						vq->desc[desc_id].addr, &dlen,
 						VHOST_ACCESS_RO);
+			vhost_user_iotlb_rd_unlock(vq);
 			if (unlikely(!desc_ring))
 				return -1;
 
 			if (unlikely(dlen < vq->desc[desc_id].len)) {
+				vhost_user_iotlb_rd_lock(vq);
 				idesc = vhost_alloc_copy_ind_table(dev, vq,
 						vq->desc[desc_id].addr,
 						vq->desc[desc_id].len);
+				vhost_user_iotlb_rd_unlock(vq);
 				if (unlikely(!idesc))
 					return -1;
@@ -204,7 +209,10 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
 				goto fail;
 			desc = desc_ring[desc_id];
-			if (desc.flags & VRING_DESC_F_WRITE)
+			if (desc.flags & VRING_DESC_F_WRITE) {
+				vhost_user_iotlb_rd_lock(vq);
 				vhost_log_write_iova(dev, vq, desc.addr,
 						     desc.len);
+				vhost_user_iotlb_rd_unlock(vq);
+			}
 			desc_id = desc.next;
 		} while (desc.flags & VRING_DESC_F_NEXT);
-- 
2.43.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-03-05 14:08:55.383056216 +0000
+++ 0029-vhost-fix-deadlock-during-vDPA-SW-live-migration.patch	2024-03-05 14:08:54.644520749 +0000
@@ -1 +1 @@
-From 19639c3b693bcfdc941c56d9d5bd60f65a8eeecb Mon Sep 17 00:00:00 2001
+From 15afe0935f9e0e6e216bfee114c0e17855899bea Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 19639c3b693bcfdc941c56d9d5bd60f65a8eeecb ]
+
@@ -30 +31,0 @@
-Cc: stable@dpdk.org
@@ -35,2 +36,2 @@
- lib/vhost/vdpa.c | 11 +++++++++--
- 1 file changed, 9 insertions(+), 2 deletions(-)
+ lib/vhost/vdpa.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
@@ -39 +40 @@
-index 9776fc07a9..a1dd5a753b 100644
+index 09ad5d866e..bd00c9d2c2 100644
@@ -48,7 +49 @@
-@@ -148,5 +149,4 @@ rte_vdpa_unregister_device(struct rte_vdpa_device *dev)
- int
- rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
--	__rte_no_thread_safety_analysis /* FIXME: requires iotlb_lock? */
- {
- 	struct virtio_net *dev = get_device(vid);
-@@ -194,15 +194,19 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
+@@ -177,15 +178,19 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
@@ -74 +69 @@
-@@ -221,7 +225,10 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
+@@ -204,7 +209,10 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)


  parent reply	other threads:[~2024-03-05 15:35 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 15:33 patch 'hash: remove some dead code' " Kevin Traynor
2024-03-05 15:33 ` patch 'regexdev: fix logtype register' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/i40e: remove redundant judgment in flow parsing' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/iavf: fix memory leak on security context error' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/ixgbe: fix memoy leak after device init failure' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/ice: fix link update' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/ice: fix tunnel TSO capabilities' " Kevin Traynor
2024-03-05 15:33 ` patch 'kernel/freebsd: fix module build on FreeBSD 14' " Kevin Traynor
2024-03-05 15:33 ` patch 'ci: update versions of actions in GHA' " Kevin Traynor
2024-03-05 15:33 ` patch 'eal/x86: add AMD vendor check for TSC calibration' " Kevin Traynor
2024-03-05 15:33 ` patch 'eal: verify strdup return' " Kevin Traynor
2024-03-05 15:33 ` patch 'bus/dpaa: " Kevin Traynor
2024-03-05 15:33 ` patch 'bus/fslmc: " Kevin Traynor
2024-03-05 15:33 ` patch 'bus/vdev: " Kevin Traynor
2024-03-05 15:33 ` patch 'dma/idxd: " Kevin Traynor
2024-03-05 15:33 ` patch 'event/cnxk: " Kevin Traynor
2024-03-05 15:33 ` patch 'net/failsafe: fix memory leak in args parsing' " Kevin Traynor
2024-03-05 15:33 ` patch 'app/dumpcap: verify strdup return' " Kevin Traynor
2024-03-05 15:33 ` patch 'app/pdump: " Kevin Traynor
2024-03-05 15:33 ` patch 'app/crypto-perf: " Kevin Traynor
2024-03-05 15:33 ` patch 'test: " Kevin Traynor
2024-03-05 15:33 ` patch 'examples/qos_sched: fix memory leak in args parsing' " Kevin Traynor
2024-03-05 15:33 ` patch 'common/mlx5: fix calloc parameters' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/bnx2x: " Kevin Traynor
2024-03-05 15:33 ` patch 'net/nfp: " Kevin Traynor
2024-03-05 15:33 ` patch 'build: fix linker warnings about undefined symbols' " Kevin Traynor
2024-03-05 15:34 ` patch 'vhost: fix virtqueue access check in vhost-user setup' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/virtio: remove duplicate queue xstats' " Kevin Traynor
2024-03-05 15:34 ` Kevin Traynor [this message]
2024-03-05 15:34 ` patch 'vhost: fix memory leak in Virtio Tx split path' " Kevin Traynor
2024-03-05 15:34 ` patch 'cryptodev: remove unused extern variable' " Kevin Traynor
2024-03-05 15:34 ` patch 'common/cnxk: fix memory leak in CPT init' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/crypto-perf: fix next segment mbuf' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/crypto-perf: fix data comparison' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/crypto-perf: fix encrypt operation verification' " Kevin Traynor
2024-03-05 15:34 ` patch 'event/cnxk: fix dequeue timeout configuration' " Kevin Traynor
2024-03-05 15:34 ` patch 'test/event: skip test if no driver is present' " Kevin Traynor
2024-03-05 15:34 ` patch 'doc: fix commands in eventdev test tool guide' " Kevin Traynor
2024-03-05 15:34 ` patch 'ethdev: fix NVGRE encap flow action description' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/af_xdp: fix memzone leak on config failure' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: refactor VF mailbox message struct' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: refactor PF " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: fix VF multiple count on one reset' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: fix disable command with firmware' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: fix reset level comparison' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: remove QinQ insert support for VF' " Kevin Traynor
2024-03-05 15:34 ` patch 'doc: add --latencystats option in testpmd guide' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/testpmd: hide --bitrate-stats in help if disabled' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/vmxnet3: fix initialization on FreeBSD' " Kevin Traynor
2024-03-05 15:34 ` patch 'drivers/net: fix buffer overflow for packet types list' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/testpmd: fix crash in multi-process forwarding' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/ionic: fix RSS query' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/ionic: fix device close' " Kevin Traynor
2024-03-05 15:34 ` patch 'common/sfc_efx/base: use C11 static assert' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/memif: fix extra mbuf refcnt update in zero copy Tx' " Kevin Traynor
2024-03-05 15:34 ` patch 'net: add macros for VLAN metadata parsing' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/netvsc: fix " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: fix array overflow' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: fix 50G and 100G forced speed' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: fix speed change from 200G to 25G on Thor' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: fix backward firmware compatibility' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: modify locking for representor Tx' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: fix deadlock in ULP timer callback' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/cnxk: fix flow RSS configuration' " Kevin Traynor
2024-03-05 15:34 ` patch 'common/cnxk: fix mbox region copy' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/mlx5: fix jump action validation' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/mlx5: fix GENEVE TLV option management' " Kevin Traynor
2024-03-05 15:34 ` patch 'common/mlx5: fix duplicate read of general capabilities' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/mlx5: fix stats query crash in secondary process' " Kevin Traynor
2024-03-05 15:34 ` patch 'telemetry: fix connected clients count' " Kevin Traynor
2024-03-05 15:34 ` patch 'telemetry: fix empty JSON dictionaries' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240305153449.263666-29-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=chenh@yusur.tech \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).