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 41FBEA0540 for ; Thu, 7 Jul 2022 09:59:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C748406B4; Thu, 7 Jul 2022 09:59:38 +0200 (CEST) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mails.dpdk.org (Postfix) with ESMTP id 01C8B406B4 for ; Thu, 7 Jul 2022 09:59:37 +0200 (CEST) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id CC94F3FC12 for ; Thu, 7 Jul 2022 07:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1657180776; bh=/H4nmQLTEPObV/H3py/1Hu0gg3N6bQF+D5HLy9pTa0g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=I1Ho5NWM2HuF2Y/+UYRiChfinYz9N4VRcDlmjjMhGHJJ7a4BcTdTkfYsa8dJZlnBk lMVf+WQpyWou+4VN+HOqam9Yw+F8O09+s6Sz3rGmUcTh8aYiW0Nhzstj1Hq0n3LVM0 fpEmDJkJuPfv9KIlewr6cjyTtWHVkYg/3qMrgiW78cebYfcIGiJjp+SQmPJic4EnsC 0J3OMRP0eC6vTusE98gBTTdDCWPqexm1dxDJZqZWNLIKjdcQ//tzRwdxsN7J5OoUED OTHZFCOG8QZcbRgsWgKHvwa+h8oh+u6mKOrhIR7y7yMg+sTxUKRJo/vys4SSx3sflo 8U01sZVYW1O9A== Received: by mail-ed1-f72.google.com with SMTP id f13-20020a0564021e8d00b00437a2acb543so13315894edf.7 for ; Thu, 07 Jul 2022 00:59:36 -0700 (PDT) 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=/H4nmQLTEPObV/H3py/1Hu0gg3N6bQF+D5HLy9pTa0g=; b=SkhFJq8lmsvXY/LOmj8EfaCAzvRoeEXS06/21APuDi5cygnWbVQ6j7evAn88FF3r6N q+iPnJtD9RRXQVlsQ2YjG45VGJ4o8+yszBUmhOGE5cbKkzHKm3Vt58yfN6VhxrB8Dbmw lXGq9gbHFwMexPBgfuwgn6bfhUFSBsdI/Z8ByWzeMNm96sJhbc520W1kEMQz4W6oczz/ QclHJKX1RpRq+BC11xCt9KBYMXlcf2InTu0Y2ZmDfmrYAvG/8RXG6CYgG1Et1PLnoPZd A63BgaldyIwI2VBlj7g+Q/FoVLD7TEx/up5kBABZeFK9fbcUr+PcZACAsg8LLHRSJOiH ekJg== X-Gm-Message-State: AJIora/3pECfaaXWlYgCn8b1vwBH8GMiFHXIAmwIl03Dk1ijaz6yhCZq RdWn6Ihs4DexZ/Tgt8coQFzIoFSi91nIdXxvtBOQkTYl0hCuq73mLmnxGHNqU/ATQxjOmFP3RXl +2OM0lcID9rk+3jKG6vOkpA4X X-Received: by 2002:a05:6402:405:b0:433:426d:7d59 with SMTP id q5-20020a056402040500b00433426d7d59mr61589761edv.122.1657180776338; Thu, 07 Jul 2022 00:59:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ubtOaiDHD9xANpI1sybkddFKhwDPEQZzZp0yZiYCJ7lt7m2ng+NiSsAdYxJqpyW6H8paN5mA== X-Received: by 2002:a05:6402:405:b0:433:426d:7d59 with SMTP id q5-20020a056402040500b00433426d7d59mr61589738edv.122.1657180776162; Thu, 07 Jul 2022 00:59:36 -0700 (PDT) Received: from Keschdeichel.fritz.box ([2a02:6d40:3a4f:7b00:c19b:938e:7c97:afe2]) by smtp.gmail.com with ESMTPSA id h17-20020a1709060f5100b00705cdfec71esm18405664ejj.7.2022.07.07.00.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 00:59:35 -0700 (PDT) From: christian.ehrhardt@canonical.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 19.11.13 Date: Thu, 7 Jul 2022 09:55:19 +0200 Message-Id: <20220707075522.194223-84-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220707075522.194223-1-christian.ehrhardt@canonical.com> References: <20220707075522.194223-1-christian.ehrhardt@canonical.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 19.11.13 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/09/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/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/48e451fe409e603da6e21b72163cb53c25284dd1 Thanks. Christian Ehrhardt --- >From 48e451fe409e603da6e21b72163cb53c25284dd1 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 35dcd84b8b..bb714a5c90 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -652,7 +652,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; @@ -678,7 +678,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(); } @@ -690,7 +690,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(); } } @@ -772,7 +772,7 @@ new_device(int vid) eth_dev->data->dev_link.link_status = 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); @@ -802,7 +802,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 = ETH_LINK_DOWN; @@ -863,7 +863,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"); @@ -1050,7 +1050,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; } @@ -1061,7 +1061,7 @@ eth_dev_stop(struct rte_eth_dev *dev) struct pmd_internal *internal = dev->data->dev_private; rte_atomic32_set(&internal->started, 0); - update_queuing_status(dev); + update_queuing_status(dev, true); } static void -- 2.37.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-07-07 09:54:14.600465371 +0200 +++ 0084-net-vhost-fix-deadlock-on-vring-state-change.patch 2022-07-07 09:54:11.025824987 +0200 @@ -1 +1 @@ -From 193edd75a94fe8d0d633d1702109779fd7b7d6a0 Mon Sep 17 00:00:00 2001 +From 48e451fe409e603da6e21b72163cb53c25284dd1 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 35dcd84b8b..bb714a5c90 100644 @@ -29 +30 @@ -@@ -741,7 +741,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) +@@ -652,7 +652,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) @@ -38 +39 @@ -@@ -767,7 +767,7 @@ update_queuing_status(struct rte_eth_dev *dev) +@@ -678,7 +678,7 @@ update_queuing_status(struct rte_eth_dev *dev) @@ -47 +48 @@ -@@ -779,7 +779,7 @@ update_queuing_status(struct rte_eth_dev *dev) +@@ -690,7 +690,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); +@@ -772,7 +772,7 @@ new_device(int vid) + eth_dev->data->dev_link.link_status = ETH_LINK_UP; @@ -65 +66 @@ -@@ -898,7 +898,7 @@ destroy_device(int vid) +@@ -802,7 +802,7 @@ destroy_device(int vid) @@ -72 +73 @@ - eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN; + eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; @@ -74 +75 @@ -@@ -1008,7 +1008,7 @@ vring_state_changed(int vid, uint16_t vring, int enable) +@@ -863,7 +863,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) +@@ -1050,7 +1050,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev) @@ -92 +93,2 @@ -@@ -1209,7 +1209,7 @@ eth_dev_stop(struct rte_eth_dev *dev) +@@ -1061,7 +1061,7 @@ eth_dev_stop(struct rte_eth_dev *dev) + struct pmd_internal *internal = dev->data->dev_private; @@ -94 +95,0 @@ - dev->data->dev_started = 0; @@ -98,2 +98,0 @@ - - return 0; @@ -100,0 +100,2 @@ + + static void