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 B3403A0C46; Tue, 28 Sep 2021 09:46:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5472410DC; Tue, 28 Sep 2021 09:46:18 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2101.outbound.protection.outlook.com [40.107.21.101]) by mails.dpdk.org (Postfix) with ESMTP id 9238F40DF6; Tue, 28 Sep 2021 09:46:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YuMPNUZ7mYBFwP7qbg/dE8tYJIQBYlLAuiO3BP96bnXpvL2vUFaZw6Cx66WQaSzBlRuJ9IPA4XaLdz0rHogSGgZDsRLdHSqZkJMe3ehT53pO42TMTyv9kLbd6l3jhFX80qCNC0rh9KKQm167g+2/GoE7woPYnS6B5jBHK/bCXs54Qdw6CtL6bXX2vv/DxjYjSCLly7/Fkc8pbMOur2kgZKRJi5nvOZkxHXLpyNHn7e3owC8rT1LJ53Bd0E1MbwEvrTfW+yytr/NYBE1wVMduGn7D0XQGNUxAVdVjCNAloM3Dw7LqMGS4UzqpRRhdSAxVm2yBhnHIkfaSYLjIe/MKTA== 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=5VrhJYumEGT3LN7eW+Qp42Mf4mqh0cBvFMctRrPyt4Y=; b=eHZFJk7U5NAiF6p8xi6eD3r6nGNXEBonu6Izb1uzeWP1nImkqXiIFjeNj8wIhntqZHIWvCkAuG07p6Gfz5qidzvLp9V2nCHWgHKrZqa2PogP1E/l6AumYrCf3I91A2sCNbfAnepQP+HzVQOHkb74R2m8pbNcwRyEsD/2LxIv/6S8L4GwZM9hhb7ab+T56LsyktDlknGXOYR7oLOenZKTUV9tVWmW332rVtGJUOYvXytAkLuHgs2rTtSeLxQ2LhJDbP1TffzcVuv3mjjKJIfgrFRHqm3Bp9WNd3tZJlRgyjDox/qhuizgRELoNci52wNe5WcvWOmGQm6NCJXwbksSWw== 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=5VrhJYumEGT3LN7eW+Qp42Mf4mqh0cBvFMctRrPyt4Y=; b=bOMMuH8awU0EcQhj41u7wArzgc+Zi7HjeYzSosC/zNHMHEjnKb6KC6a2q/WHDWUe+7zPJk7JBqRaY7Y2Z3z/cTKO8oxKcImC2qig0FAgwiCczL9RVVOYzqUUiUCruraDqw1CNi7RcvyaGEoHIXj3EphwQc+ZabUZA+1kC/Y0yMs= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nokia.com; Received: from PA4PR07MB7600.eurprd07.prod.outlook.com (2603:10a6:102:c5::12) by PR3PR07MB6698.eurprd07.prod.outlook.com (2603:10a6:102:64::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.13; Tue, 28 Sep 2021 07:46:11 +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.013; Tue, 28 Sep 2021 07:46:11 +0000 To: "Wang, Haiyue" , "dev@dpdk.org" Cc: "stable@dpdk.org" , "Richardson, Bruce" References: <20210927171815.16216-1-julien.meunier@nokia.com> From: Julien Meunier Message-ID: <6e713015-8438-5af0-dc34-5372795b34c7@nokia.com> Date: Tue, 28 Sep 2021 09:46:12 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: HE1PR05CA0188.eurprd05.prod.outlook.com (2603:10a6:3:f9::12) To PA4PR07MB7600.eurprd07.prod.outlook.com (2603:10a6:102:c5::12) MIME-Version: 1.0 Received: from [192.168.1.25] (86.242.117.254) by HE1PR05CA0188.eurprd05.prod.outlook.com (2603:10a6:3:f9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Tue, 28 Sep 2021 07:46:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7cd26c93-e58f-429d-758e-08d982540a43 X-MS-TrafficTypeDiagnostic: PR3PR07MB6698: 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: OhaD4FJ5zFAiGYsxt51peGV4Nqx9cMsUlBkB0nO7LJttSA0PhJMN5MuUv1L15gYwW/3LRRuU4HmZ3HW/tHlfGE3PxOUhLc/TyY/SFNtsTTP5750pMyhWYDqz2YxDYIaSwCNK4zjiMEHNugdFA9KzRtpNykLBERSoK5OhEOFDtSh/aH/jT27cXzxm763P9h9zYgVGT5JAd9j7SxTG30Q1W8TfOXBL6AOuOJRS8kJKa3EysmDcQaGzum8+WBxv/nZ3VgisfLnXMuL/dl/UfMPAk7fhpY6J/ouLlW5gOc4COdxpxCoA+Tx2H6NkhkCLljsfl/1y/alYsvban9lUoQmahLIhIu9z2wMlDqyoRvzq1TRQIHrUWktWWtFZdgS4FFIuzAeFd7vR5UZyK/zuuCAuN70nGG2XoQkKIW48xvU7RkXf0djNdUsD5VZaxXFPhcMalnv6TLqchqpsiYH/oiQQ4U7vCHaR/xND7MqgNCn177DQoTxy7OS92bhLfoSWk9yqpFNfj5T3sEys0G4j0IJyRemfi6NLQ4gEn66Vg2rqxk7V6NWMZB03wqjXUd4kbfAbEIsyvXRMdYI+kQgJh4SkDLQ3/Jo6DtW+F2resho40UnquiSBk4PRxquB0d97Qp+XZrHVIe+Ru8QOtYSwTfVbOABMA53CEecAA3KpHev+prtTcvKbT9nF4WM402vC2knnoycHbsHaSJq8qju+nrIsYpzAUyh8IaZr803iEkJ2NYA= 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)(5660300002)(66946007)(2616005)(38100700002)(956004)(53546011)(36756003)(66556008)(66476007)(83380400001)(16576012)(2906002)(8676002)(8936002)(86362001)(31696002)(4326008)(26005)(316002)(44832011)(31686004)(110136005)(6486002)(54906003)(186003)(508600001)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OUtBQm5CUkdnSVFNUzN3aVp1WWdxa2NCQTZKdVV0cDVGSEJkV1hEa0NmQ2RG?= =?utf-8?B?Y3FiOUVYRDFjdThlUGlMeTlvUTNTYUllbWpTSkJRUlpEbk1YNWJBUFUyU2s1?= =?utf-8?B?VmxmUGVpLzY5RmVsaEQ3TkNOVitTdnk4NDVLSUVyK0pCbEJCaXVEMExXWG5k?= =?utf-8?B?UlhBeVdnSkhCOFR6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f-8?B?Mzd3c1dQQ3drSXRldUdGZ2tPYUVVTjNhYTNlOVVXdlRmeVVKbGh0YXFWOSt5?= =?utf-8?B?cFd3ZUFlaFRJaVl3ekhBNWVaS2tibDM2MHg2Z0VYOFpKSmExd3pGVS9QTWxl?= =?utf-8?B?MnhzM3phVmNOcTVDQ2pOeUcycUh1SWFUSkcrNW1ITnl6bGNiUXlRNHRnSTFS?= =?utf-8?B?L2dxWW1hVjhjb1VLWERGa0FEQWx4YjBXaW9FZHljTEl1MDV5RDFvTkhnRTdw?= =?utf-8?B?TE9xSG5uc00xeHVZRHN2UHkwbGVEUlpmWEZNUU1JSzhtdVpSTWJaRzdFYU5w?= =?utf-8?B?NW1nNTMyR3lTWFFac3YwYXNselVxSHR0RXdBMlpEMnYwbUcxOWo4NS9rUzlW?= =?utf-8?B?T05Uelg0U25KZkk0UExiclJhWUl1cmJzZTV3WGJaZVdoWFJabDV3dDBMNjE5?= =?utf-8?B?WE9aQjRlM0Jydk85UHZpOGxUZmR4WU02QmFaaHZQYnY1OU5LcG1RZFFsdi9x?= =?utf-8?B?My85emxwVCtiTmNNTVFBYllOamcxUlJSZVRHNWlGVWhDQklQd3JJK0QvVWQr?= =?utf-8?B?NXJUUkdZK0RZN1FHMnZnMjZWRHNtQ0VvaVp5bVA5SGpPam1YTU0zSVpqS1lo?= =?utf-8?B?Tk9SYnlNSVg3dWd5UmNOOUZCTjVFT1Z1TFNGVDVyYjdQcHl5UFpCRGRvamZZ?= =?utf-8?Q?wpnGUxurhyM21OaCsBnE+kGT6TisD/xXMWTgSTc?= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7cd26c93-e58f-429d-758e-08d982540a43 X-MS-Exchange-CrossTenant-AuthSource: PA4PR07MB7600.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2021 07:46:11.1947 (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: VbRp4C25jmPCu8xXWkGqHYyhap5E08EGw0Xi5HwlRxmyxYPjjeKtBw4gLcHOXhIpBXWq24e36XgNb2+cE/RTvxkKOhykQic5W4xGflafTTo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB6698 Subject: Re: [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" Hello, On 28/09/2021 05:21, Wang, Haiyue wrote: >> -----Original Message----- >> From: Wang, Haiyue >> Sent: Tuesday, September 28, 2021 11:06 >> To: 'Julien Meunier' ; dev@dpdk.org >> Cc: stable@dpdk.org; Richardson, Bruce >> Subject: RE: [PATCH] net/ixgbe: fix RxQ/TxQ release >> >>> -----Original Message----- >>> From: Julien Meunier >>> Sent: Tuesday, September 28, 2021 01:18 >>> To: dev@dpdk.org >>> Cc: stable@dpdk.org; Richardson, Bruce ; Wang, Haiyue >>> >>> Subject: [PATCH] net/ixgbe: fix RxQ/TxQ release >>> >>> 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. >>> >> >> Are you able to setup not a power of 2 successfully ? >> > > My fault, yes, possible. ;-) > Yes, we have some usecases where the nb of descriptiors for the TxQ is set to 1536. I modified the test_pmd_perf in order to validate this behavior, as my ixgbe X550 supports the loopback mode: - nb_desc = 2048 => txq is drained and stopped correctly - nb_desc = 1536 => freeze during the teardown >> int >> rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id, >> uint16_t nb_tx_desc, unsigned int socket_id, >> const struct rte_eth_txconf *tx_conf) >> { >> ... >> >> if (nb_tx_desc > dev_info.tx_desc_lim.nb_max || >> nb_tx_desc < dev_info.tx_desc_lim.nb_min || >> nb_tx_desc % dev_info.tx_desc_lim.nb_align != 0) { >> RTE_ETHDEV_LOG(ERR, >> "Invalid value for nb_tx_desc(=%hu), should be: <= %hu, >= %hu, and a product >> of %hu\n", >> nb_tx_desc, dev_info.tx_desc_lim.nb_max, >> dev_info.tx_desc_lim.nb_min, >> dev_info.tx_desc_lim.nb_align); >> return -EINVAL; >> } >> >> ... >> >> } >> >>> 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; >>> > > Just one line ? > > i = (i + 1) % txq->nb_tx_desc > Ah yes, I was too focused with this bitmask... The shorter, the better. I will send a V2 today. Thanks for this feedback ! >>> /* 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 > -- Julien Meunier