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 59ECC45BB6 for ; Wed, 23 Oct 2024 23:21:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5474E40261; Wed, 23 Oct 2024 23:21:23 +0200 (CEST) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mails.dpdk.org (Postfix) with ESMTP id 353B140261 for ; Wed, 23 Oct 2024 23:21:22 +0200 (CEST) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-37d6a2aa748so99390f8f.1 for ; Wed, 23 Oct 2024 14:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729718482; x=1730323282; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FPnsXh8g7Cp+miPka7HfczU8dSahA1MmV9CEsgkR9uM=; b=Bcoy92JUWLNSfckKtiWJfBVE+92HOym7Xolhw0/YO/uzi1giAkxfwaoAmeCL917grK R3t5FmpMRsvmr6yvsAx7fjC9JOUEae1tlsCZ0cKGrLTTbYzojKs3jQL/l9cwZbNavX4H AfK4qshYBMBUAe4b1k1+sir3YtE12WtKr87dMWA9yq1l2789epNI3GMiJ3y3s808MhrA vJ2QcbJCZuVCvT/LwkYhXFFXynTgEOqS9driSwcoW0uErSclhuC5JxYflfaQY5YQ+haB aHnwQL/AnjcRXDFR9eh+m9Tyc+xtbvyr8Nwlg4d97IRQ1SG1oj1m5YjIW0lFcRqviR2W j9SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729718482; x=1730323282; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FPnsXh8g7Cp+miPka7HfczU8dSahA1MmV9CEsgkR9uM=; b=wfdRRNEg/UA/x8fg7qQmz03WTMA8PvcarRkSpqXdte1OuU2BoRFJXEsYNVsAESahEr LXCixLrsTSw0cTtTV7XilMkW7KCOZMTE5cSdty1um/5IrCHoZh+H63e1mO6k0IRcMsz2 ss4VrrltphZFFVQIglmbetzfMwVGdqyK20IFnsIOr3E7qCqijNhuIl4lEOzv1SjduyBx XM1Gs++Fn8fb1sB86MtCEse2voxJZNnGBCAv+1xSV0UmbQy91q3IdnDfeUjVaUBbMBjV mtHrg+b3MSFij0102hAnOgeURHA4H0uYpXiAU6efgh1/JgjaxC3mFPZwOTttR9Yf7JK0 jt8Q== X-Forwarded-Encrypted: i=1; AJvYcCUh6cCut521H9WYCT/zaOBDbxAjUxK0Ky+ca8fZ7RKrJpEskxrSG0mL1FL/5PwdDa3L+vJvmvc=@dpdk.org X-Gm-Message-State: AOJu0Yy80VI7pUboDfgsOAVpdbBEvzeyN/wjH3dPqTo992EdxEiH0Lww RsZtDsRPgpzJgX3G847IhxqOWU+Y7Sm+pyB5PiYEpvFw7PBCt/0BNX5tLF8E X-Google-Smtp-Source: AGHT+IEqcQMUpDy0MXZkc9UwUVXnOQj2K+7dYx7Kjldy/e8DY+9gib8K+V68kH6nhO1aDt2BR1ityA== X-Received: by 2002:adf:f7cb:0:b0:37d:461d:b1ea with SMTP id ffacd0b85a97d-37efcf898d0mr2481213f8f.48.1729718481656; Wed, 23 Oct 2024 14:21:21 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:21cd:def0:a01d:d2aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a37aecsm9825328f8f.8.2024.10.23.14.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 14:21:21 -0700 (PDT) From: luca.boccassi@gmail.com To: Bing Zhao Cc: Viacheslav Ovsiienko , dpdk stable Subject: patch 'net/mlx5: workaround list management of Rx queue control' has been queued to stable release 22.11.7 Date: Wed, 23 Oct 2024 22:16:50 +0100 Message-ID: <20241023211704.1216956-70-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023211704.1216956-1-luca.boccassi@gmail.com> References: <20241023211704.1216956-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 22.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 10/25/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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/09fbaf6867aacf98f237de8d501d25c5fc461c42 Thanks. Luca Boccassi --- >From 09fbaf6867aacf98f237de8d501d25c5fc461c42 Mon Sep 17 00:00:00 2001 From: Bing Zhao Date: Tue, 23 Jul 2024 14:14:11 +0300 Subject: [PATCH] net/mlx5: workaround list management of Rx queue control [ upstream commit f957ac99643535fd218753f4f956fc9c5aadd23c ] The LIST_REMOVE macro only removes the entry from the list and updates list itself. The pointers of this entry are not reset to NULL to prevent the accessing for the 2nd time. In the previous fix for the memory accessing, the "rxq_ctrl" was removed from the list in a device private data when the "refcnt" was decreased to 0. Under only shared or non-shared queues scenarios, this was safe since all the "rxq_ctrl" entries were freed or kept. There is one case that shared and non-shared Rx queues are configured simultaneously, for example, a hairpin Rx queue cannot be shared. When closing the port that allocated the shared Rx queues' "rxq_ctrl", if the next entry is hairpin "rxq_ctrl", the hairpin "rxq_ctrl" will be freed directly with other resources. When trying to close the another port sharing the "rxq_ctrl", the LIST_REMOVE will be called again and cause some UFA issue. If the memory is no longer mapped, there will be a SIGSEGV. Adding a flag in the Rx queue private structure to remove the "rxq_ctrl" from the list only on the port/queue that allocated it. Fixes: bcc220cb57d7 ("net/mlx5: fix shared Rx queue list management") Signed-off-by: Bing Zhao Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_rx.h | 1 + drivers/net/mlx5/mlx5_rxq.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h index 6b42e27c89..7d0d76123f 100644 --- a/drivers/net/mlx5/mlx5_rx.h +++ b/drivers/net/mlx5/mlx5_rx.h @@ -170,6 +170,7 @@ struct mlx5_rxq_ctrl { struct mlx5_rxq_priv { uint16_t idx; /* Queue index. */ uint32_t refcnt; /* Reference counter. */ + bool possessor; /* Shared rxq_ctrl allocated for the 1st time. */ struct mlx5_rxq_ctrl *ctrl; /* Shared Rx Queue. */ LIST_ENTRY(mlx5_rxq_priv) owner_entry; /* Entry in shared rxq_ctrl. */ struct mlx5_priv *priv; /* Back pointer to private data. */ diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 9179b9d9d7..2f5c705660 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -935,6 +935,7 @@ mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, rte_errno = ENOMEM; return -rte_errno; } + rxq->possessor = true; } rxq->priv = priv; rxq->idx = idx; @@ -2013,6 +2014,7 @@ mlx5_rxq_hairpin_new(struct rte_eth_dev *dev, struct mlx5_rxq_priv *rxq, tmpl->rxq.mr_ctrl.cache_bh = (struct mlx5_mr_btree) { 0 }; tmpl->rxq.idx = idx; rxq->hairpin_conf = *hairpin_conf; + rxq->possessor = true; mlx5_rxq_ref(dev, idx); LIST_INSERT_HEAD(&priv->rxqsctrl, tmpl, next); return tmpl; @@ -2280,7 +2282,8 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx) RTE_ETH_QUEUE_STATE_STOPPED; } } else { /* Refcnt zero, closing device. */ - LIST_REMOVE(rxq_ctrl, next); + if (rxq->possessor) + LIST_REMOVE(rxq_ctrl, next); LIST_REMOVE(rxq, owner_entry); if (LIST_EMPTY(&rxq_ctrl->owners)) { if (!rxq_ctrl->is_hairpin) -- 2.45.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-10-23 22:16:43.169147806 +0100 +++ 0070-net-mlx5-workaround-list-management-of-Rx-queue-cont.patch 2024-10-23 22:16:40.539944297 +0100 @@ -1 +1 @@ -From f957ac99643535fd218753f4f956fc9c5aadd23c Mon Sep 17 00:00:00 2001 +From 09fbaf6867aacf98f237de8d501d25c5fc461c42 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit f957ac99643535fd218753f4f956fc9c5aadd23c ] + @@ -28 +29,0 @@ -Cc: stable@dpdk.org @@ -38 +39 @@ -index 7d144921ab..9bcb43b007 100644 +index 6b42e27c89..7d0d76123f 100644 @@ -41,2 +42 @@ -@@ -173,6 +173,7 @@ struct mlx5_rxq_ctrl { - /* RX queue private data. */ +@@ -170,6 +170,7 @@ struct mlx5_rxq_ctrl { @@ -44,0 +45 @@ + uint32_t refcnt; /* Reference counter. */ @@ -46 +46,0 @@ - RTE_ATOMIC(uint32_t) refcnt; /* Reference counter. */ @@ -48,0 +49 @@ + struct mlx5_priv *priv; /* Back pointer to private data. */ @@ -50 +51 @@ -index f13fc3b353..c6655b7db4 100644 +index 9179b9d9d7..2f5c705660 100644 @@ -53 +54 @@ -@@ -938,6 +938,7 @@ mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, +@@ -935,6 +935,7 @@ mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, @@ -61 +62 @@ -@@ -2015,6 +2016,7 @@ mlx5_rxq_hairpin_new(struct rte_eth_dev *dev, struct mlx5_rxq_priv *rxq, +@@ -2013,6 +2014,7 @@ mlx5_rxq_hairpin_new(struct rte_eth_dev *dev, struct mlx5_rxq_priv *rxq, @@ -69 +70 @@ -@@ -2282,7 +2284,8 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx) +@@ -2280,7 +2282,8 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx)