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 6A2C2A0540 for ; Wed, 6 Jul 2022 22:35:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64DB34069D; Wed, 6 Jul 2022 22:35:53 +0200 (CEST) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 4C4F24113D for ; Wed, 6 Jul 2022 22:35:51 +0200 (CEST) Received: by mail-wr1-f46.google.com with SMTP id v14so23614486wra.5 for ; Wed, 06 Jul 2022 13:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qA9bPSSAQpHtHM+OTBk2GJuOSYMqROr0yw7DmjpFtZA=; b=YYS06IEpGsh8XThFMm+b913mAYmsJY2HiavdTF9NCSN1eXw0rY17+1zBL6BR8RHRVS uY6zmpROEwv/kdFJdYRFYAh/fRHGwoQLApf3stN5RMLk49RD9c/LO0a/dfWW8symLeQV KUig80sgwFp98N45Myw9WXCrlnZF64HE+IJ8kg1Hqj/NPYnVIHGNBxA0mJjeDgabGkE/ jS24YOZip3hxvew9GoD1fSicprDBlPh7auN6beB3Xb0ozngWjZtlIEve6f+Nm8sBBTLr vtPmRIlbStWhJ28Cqs6/0MCqAw5eO6lAHVCSuG+YU48yl5bE71XX/GX008reJJQORib6 QHDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qA9bPSSAQpHtHM+OTBk2GJuOSYMqROr0yw7DmjpFtZA=; b=LV3AKt1UDQ/QvX3nYSd3NckMFm3gPiKrvVmWTbALk/CxoSy4lyNgQT2WnPjCK3XgRZ sqst1gc3iYeS8ueDZhgxivv8zbhZ8TeBIc0JXTxLqIbEg47jKR1SWDQE5+zZEjmxVw0/ 5nw81PX3yJ+yr00E4VrcNirkDjLQLTs1maffq8UxkOrHeDchB0r9xIGeLqXv+tfgx6TM n0LIhbRK+PkTVVbxLTHoAie0vKOVk/oP4RVTObYXPLa1ESW+RHbtFScUdspkFNOH97Ws Hl5sGOOpyD94avHvi9Hz9kqYzL0caGfwa5qvMEBaAJQFx2A3FOoxEDHFyRc8TN2Vegpb 91Uw== X-Gm-Message-State: AJIora+YjIeS/9YlrojInQEwsbvbHh7I6qvD56Pu1QXzbUL+z6I6Mi/W M81ppTb+Qpim+6VFJvtsfEjvcp8AwzsqbA== X-Google-Smtp-Source: AGRyM1ux4Pf2FsscPvwX+U/BLglWSSIC97JLjA1BamQt+bHk76p0gZ1ksngY2CcCB7jX4Xs+lt31qA== X-Received: by 2002:adf:f006:0:b0:21d:7bf3:1f2e with SMTP id j6-20020adff006000000b0021d7bf31f2emr5739607wro.593.1657139750999; Wed, 06 Jul 2022 13:35:50 -0700 (PDT) Received: from localhost ([137.220.125.106]) by smtp.gmail.com with ESMTPSA id f20-20020a05600c155400b0039c41686421sm26156688wmg.17.2022.07.06.13.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 13:35:50 -0700 (PDT) From: luca.boccassi@gmail.com To: Yuan Wang Cc: Chenbo Xia , dpdk stable Subject: patch 'net/vhost: fix deadlock on vring state change' has been queued to stable release 21.11.2 Date: Wed, 6 Jul 2022 21:34:48 +0100 Message-Id: <20220706203506.3422496-13-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220706203506.3422496-1-luca.boccassi@gmail.com> References: <20220628151938.2278711-26-ktraynor@redhat.com> <20220706203506.3422496-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/08/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/5991d25b7489739b2b8d7c9af1c264f6a7f2988d Thanks. Luca Boccassi --- >From 5991d25b7489739b2b8d7c9af1c264f6a7f2988d Mon Sep 17 00:00:00 2001 From: Yuan Wang Date: Mon, 27 Jun 2022 13:51:25 +0800 Subject: [PATCH] net/vhost: fix deadlock on vring state change [ upstream commit 193edd75a94fe8d0d633d1702109779fd7b7d6a0 ] If vring state changes after pmd starts working, the locked vring notifies pmd, thus calling update_queuing_status(), the latter will wait for pmd to finish accessing vring, while pmd is also waiting for vring to be unlocked, thus causing deadlock. Actually, update_queuing_status() only needs to wait while destroy/stopping the device, but not in other cases. This patch adds a flag for whether or not to wait to fix this issue. Fixes: 1ce3c7fe149f ("net/vhost: emulate device start/stop behavior") Signed-off-by: Yuan Wang Reviewed-by: Chenbo Xia --- drivers/net/vhost/rte_eth_vhost.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index a248a65df4..a280e788fb 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -716,7 +716,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) } static void -update_queuing_status(struct rte_eth_dev *dev) +update_queuing_status(struct rte_eth_dev *dev, bool wait_queuing) { struct pmd_internal *internal = dev->data->dev_private; struct vhost_queue *vq; @@ -742,7 +742,7 @@ update_queuing_status(struct rte_eth_dev *dev) rte_atomic32_set(&vq->allow_queuing, 1); else rte_atomic32_set(&vq->allow_queuing, 0); - while (rte_atomic32_read(&vq->while_queuing)) + while (wait_queuing && rte_atomic32_read(&vq->while_queuing)) rte_pause(); } @@ -754,7 +754,7 @@ update_queuing_status(struct rte_eth_dev *dev) rte_atomic32_set(&vq->allow_queuing, 1); else rte_atomic32_set(&vq->allow_queuing, 0); - while (rte_atomic32_read(&vq->while_queuing)) + while (wait_queuing && rte_atomic32_read(&vq->while_queuing)) rte_pause(); } } @@ -836,7 +836,7 @@ new_device(int vid) eth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP; rte_atomic32_set(&internal->dev_attached, 1); - update_queuing_status(eth_dev); + update_queuing_status(eth_dev, false); VHOST_LOG(INFO, "Vhost device %d created\n", vid); @@ -866,7 +866,7 @@ destroy_device(int vid) internal = eth_dev->data->dev_private; rte_atomic32_set(&internal->dev_attached, 0); - update_queuing_status(eth_dev); + update_queuing_status(eth_dev, true); eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN; @@ -976,7 +976,7 @@ vring_state_changed(int vid, uint16_t vring, int enable) state->max_vring = RTE_MAX(vring, state->max_vring); rte_spinlock_unlock(&state->lock); - update_queuing_status(eth_dev); + update_queuing_status(eth_dev, false); VHOST_LOG(INFO, "vring%u is %s\n", vring, enable ? "enabled" : "disabled"); @@ -1163,7 +1163,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev) } rte_atomic32_set(&internal->started, 1); - update_queuing_status(eth_dev); + update_queuing_status(eth_dev, false); return 0; } @@ -1175,7 +1175,7 @@ eth_dev_stop(struct rte_eth_dev *dev) dev->data->dev_started = 0; rte_atomic32_set(&internal->started, 0); - update_queuing_status(dev); + update_queuing_status(dev, true); return 0; } -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-07-06 21:07:54.015964700 +0100 +++ 0013-net-vhost-fix-deadlock-on-vring-state-change.patch 2022-07-06 21:07:53.543518707 +0100 @@ -1 +1 @@ -From 193edd75a94fe8d0d633d1702109779fd7b7d6a0 Mon Sep 17 00:00:00 2001 +From 5991d25b7489739b2b8d7c9af1c264f6a7f2988d Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 193edd75a94fe8d0d633d1702109779fd7b7d6a0 ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org @@ -26 +27 @@ -index d75d256040..7e512d94bf 100644 +index a248a65df4..a280e788fb 100644 @@ -29 +30 @@ -@@ -741,7 +741,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) +@@ -716,7 +716,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) @@ -38 +39 @@ -@@ -767,7 +767,7 @@ update_queuing_status(struct rte_eth_dev *dev) +@@ -742,7 +742,7 @@ update_queuing_status(struct rte_eth_dev *dev) @@ -47 +48 @@ -@@ -779,7 +779,7 @@ update_queuing_status(struct rte_eth_dev *dev) +@@ -754,7 +754,7 @@ update_queuing_status(struct rte_eth_dev *dev) @@ -56,2 +57,2 @@ -@@ -868,7 +868,7 @@ new_device(int vid) - vhost_dev_csum_configure(eth_dev); +@@ -836,7 +836,7 @@ new_device(int vid) + eth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP; @@ -65 +66 @@ -@@ -898,7 +898,7 @@ destroy_device(int vid) +@@ -866,7 +866,7 @@ destroy_device(int vid) @@ -74 +75 @@ -@@ -1008,7 +1008,7 @@ vring_state_changed(int vid, uint16_t vring, int enable) +@@ -976,7 +976,7 @@ vring_state_changed(int vid, uint16_t vring, int enable) @@ -83 +84 @@ -@@ -1197,7 +1197,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev) +@@ -1163,7 +1163,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev) @@ -92 +93 @@ -@@ -1209,7 +1209,7 @@ eth_dev_stop(struct rte_eth_dev *dev) +@@ -1175,7 +1175,7 @@ eth_dev_stop(struct rte_eth_dev *dev)