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 D51BAA0C46; Mon, 27 Sep 2021 19:18:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51AC9410DC; Mon, 27 Sep 2021 19:18:31 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2110.outbound.protection.outlook.com [40.107.22.110]) by mails.dpdk.org (Postfix) with ESMTP id 4526E40E3C; Mon, 27 Sep 2021 19:18:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OXrqOuTFbWi82XXaoS3FTHbfpFo6PZg52KrfNOkZeTsPcEUj1XVnh5c26Gs4mAHx8vO1+SZyOg/+nJ0xYdrtePLASoFeIroFBPkhGDIoh/diZu5YZn1+qFjDJ1tw8d2WCahFtNdlPdrrvMMZtDz4WE9Efor8oXTD1qrLclUQIbEfgLze1F/9flY+VFrRietfH9V5GnfY75607UIM/htj0JMADsxEWjVSFt9uKN78cJEvWtxXPqvPNmkdl79zPwl6BZ9tZIMd55s5rPZWoSd2HaIa+MoBtVTTUUcFwAbZH/kRLBbNIIqTlrnoKqVE41gRTsjYqp9ygmCQRJrbmMdoVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iAI4xlLegwsAm4sNKtdeL8w1PBlAWOw+sLJxrcl4kKQ=; b=W4G/AU5fAkiObGHruneI7lLp61+yZrpeWDN1PvwbVrc3rwIzHh2+GnaXG50xBkN69Lgawnsyp+yp6ke83R/PekjytNnR6tMlZY627/6zkXVnGM3Mrrr7qRkvew9dHOQ4dMk6j9K9lp1gzEY+hZZQhvbO4QR32Mh2aQU0nOd6dmv+el8q1+6n5kkrL7VoWC0NPLq1yNh6xvDlA+S7Q7xUNebLeZ1JC4azEh8GfhEp0LzjwbgezR6w8cAWrFYGERw/WyAIZiDSMYJnhhresyhIf/DRZSH5kilAsdf9qiXkS25boIStZvYRTBcdN+S9z1obTIXk3n+9G4b7hyTwDvPLAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iAI4xlLegwsAm4sNKtdeL8w1PBlAWOw+sLJxrcl4kKQ=; b=RlUNyrxBiveezOJlPFqxYL5vVCcbh2yDd4j3XcZb2X13o+u4v93KIno2hPQVurMHZDHXYRvW6Fmgu2Us9VmvrScrRrfGzoO2U881PF6v44hk6A0CryIHbBC1nShX+AR7eNpqMtZ8ImJWr+jEgH8BFwU1b/flKrtoy/1Kd+9iXeU= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=nokia.com; Received: from PA4PR07MB7600.eurprd07.prod.outlook.com (2603:10a6:102:c5::12) by PA4PR07MB7549.eurprd07.prod.outlook.com (2603:10a6:102:cd::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.9; Mon, 27 Sep 2021 17:18:29 +0000 Received: from PA4PR07MB7600.eurprd07.prod.outlook.com ([fe80::2dc9:3fc1:3047:aa1d]) by PA4PR07MB7600.eurprd07.prod.outlook.com ([fe80::2dc9:3fc1:3047:aa1d%5]) with mapi id 15.20.4566.012; Mon, 27 Sep 2021 17:18:29 +0000 From: Julien Meunier To: dev@dpdk.org Cc: stable@dpdk.org, bruce.richardson@intel.com, Haiyue Wang Date: Mon, 27 Sep 2021 19:18:14 +0200 Message-Id: <20210927171815.16216-1-julien.meunier@nokia.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MA1PR01CA0162.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::32) To PA4PR07MB7600.eurprd07.prod.outlook.com (2603:10a6:102:c5::12) MIME-Version: 1.0 Received: from localhost (86.242.117.254) by MA1PR01CA0162.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Mon, 27 Sep 2021 17:18:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a74aa4e1-4a33-4d8b-376f-08d981dad2c4 X-MS-TrafficTypeDiagnostic: PA4PR07MB7549: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B7GxwhXhs4UdUqxKFql0LtHnAq2NrnpMZzfqbdrs5kkd731tKPYv/zH0g9JaDiYrOckXAZC7NsmW7ouou8s0koK22QHzttcN1Kd1/jtg/aMsA60gG5K4Di2LD0QqucvYs2uXqlcTE76weT2EQ1ULDzb0yEGDhjKXdKVvrjI/ile+fI1rFXUMDdRjgQBHizli2ku9DEiEvRmayFYV1gF7Kwe3aL38Gh3Ifx/JwlQqfy5HF7DCkR7iQ9vtjuZe0OBVupz6dd7jKpMdrCUc4E+QIyjH0i0YewB2ELEyD4OrRsa3JL6mPj1d4nw0ZJVf/2YiYIKZHhZ+euhNp+I4eXsDHYtgNstJHixCzZnQIZP87pafHxlR/I4FJZNle8yOugUpoyWfQkus0aQR2IY58tm6KgYIl81ndvHsYt/bGbYV1Wzllvn623JpULNEP8WRJVQ5rQJvIiC6z94ASWGI04jZ0HAWONLYau8tululoRlUgHWzMko9OPbPoOKFBP3vwfU+8v5mc6gLfuBtvBNJ2AoWEBkBT0uX4oI9xG8sHjZ7xJEGz3bFSBxZ/y3N0fk/CxkWaNlsK/hRnl7zoWrQy878gKO4AucYOkvx9lYM+dOxcFX8b6tY7x+1o0P3pwg5dL91yMyiOcoQTcj7ptoQAfTXIw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR07MB7600.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66556008)(6916009)(6496006)(66476007)(2616005)(186003)(508600001)(956004)(6486002)(36756003)(26005)(83380400001)(66946007)(86362001)(4326008)(44832011)(6666004)(1076003)(8936002)(8676002)(316002)(38100700002)(5660300002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Ixp3M2YqZt9wkiEZp/9wDPzq88j7TiS4lQO+8Rx+J9CCxl/eHDVjMon4ScDO?= =?us-ascii?Q?1StTSvWTDamTJTz09Qql79LpVMxwoeUwXNzj+S9rDCCodCCosOeN8HI9WHyb?= =?us-ascii?Q?cYhVPBapqePiN2XJ64AfrQEMfXgSVACj/TfQraJP4wkX9FaxHsovfYgLYY7L?= =?us-ascii?Q?uO3B78qqG6QuSRsDqsKq7XqDtr+0T/l/Vu9WjlIxsmAieOPzk8kplLbJcor8?= =?us-ascii?Q?HDTtV2HYj4nSbhlIO7CCIVAQfLRPDkCMB2ONJUlWutS45EdBTbhd4c9EYxP8?= =?us-ascii?Q?N6k+GBLAdsg1aVsr3CExzRUc/HydzQvSMWMojTBUPlNZ5QpOgePaO0zyd8+j?= =?us-ascii?Q?rWwEFjIr5Cs3kCoyNhGJ6WP3+p9ho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?Q?8sJr2LW4kDLG32DfS5sJy9zVqnAZov9HVxvxcsSeD2haLvBqFLzVw8R4o87P?= =?us-ascii?Q?F2Q//MollkJDt9nCI96YM7GD?= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a74aa4e1-4a33-4d8b-376f-08d981dad2c4 X-MS-Exchange-CrossTenant-AuthSource: PA4PR07MB7600.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2021 17:18:29.2835 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gnllNovgGbA0pctwPccPlHBaeFxpZcdMNOHAtMVaMDOHhE4kKXVwvx5/pEdejYOTOtpFHmVEObYuQ30mLaLHZAMAv0dKYnGcM6qBIvTSqxg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR07MB7549 Subject: [dpdk-dev] [PATCH] net/ixgbe: fix RxQ/TxQ release X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On the vector implementation, during the tear-down, the mbufs not drained in the RxQ and TxQ are freed based on an algorithm which supposed that the number of descriptors is a power of 2 (max_desc). Based on this hypothesis, this algorithm uses a bitmask in order to detect an index overflow during the iteration, and to restart the loop from 0. However, there is no such power of 2 requirement in the ixgbe for the number of descriptors in the RxQ / TxQ. The only requirement is to have a number correctly aligned. If a user requested to configure a number of descriptors which is not a power of 2, as a consequence, during the tear-down, it was possible to be in an infinite loop, and to never reach the exit loop condition. By removing the bitmask and changing the loop method, we can avoid this issue, and allow the user to configure a RxQ / TxQ which is not a power of 2. Fixes: c95584dc2b18 ("ixgbe: new vectorized functions for Rx/Tx") Cc: bruce.richardson@intel.com Cc: stable@dpdk.org Signed-off-by: Julien Meunier --- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h index adba855ca3..8912558918 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h @@ -150,11 +150,14 @@ _ixgbe_tx_queue_release_mbufs_vec(struct ixgbe_tx_queue *txq) return; /* release the used mbufs in sw_ring */ - for (i = txq->tx_next_dd - (txq->tx_rs_thresh - 1); - i != txq->tx_tail; - i = (i + 1) & max_desc) { + i = txq->tx_next_dd - (txq->tx_rs_thresh - 1); + while (i != txq->tx_tail) { txe = &txq->sw_ring_v[i]; rte_pktmbuf_free_seg(txe->mbuf); + + i = i + 1; + if (i > max_desc) + i = 0; } txq->nb_tx_free = max_desc; @@ -168,7 +171,7 @@ _ixgbe_tx_queue_release_mbufs_vec(struct ixgbe_tx_queue *txq) static inline void _ixgbe_rx_queue_release_mbufs_vec(struct ixgbe_rx_queue *rxq) { - const unsigned int mask = rxq->nb_rx_desc - 1; + const unsigned int max_desc = rxq->nb_rx_desc - 1; unsigned int i; if (rxq->sw_ring == NULL || rxq->rxrearm_nb >= rxq->nb_rx_desc) @@ -181,11 +184,14 @@ _ixgbe_rx_queue_release_mbufs_vec(struct ixgbe_rx_queue *rxq) rte_pktmbuf_free_seg(rxq->sw_ring[i].mbuf); } } else { - for (i = rxq->rx_tail; - i != rxq->rxrearm_start; - i = (i + 1) & mask) { + i = rxq->rx_tail; + while (i != rxq->rxrearm_start) { if (rxq->sw_ring[i].mbuf != NULL) rte_pktmbuf_free_seg(rxq->sw_ring[i].mbuf); + + i = i + 1; + if (i > max_desc) + i = 0; } } -- 2.17.1