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 7C3B4A04FF for ; Thu, 5 May 2022 14:28:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5FE3942841; Thu, 5 May 2022 14:28:20 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 55BA542830; Thu, 5 May 2022 14:28:18 +0200 (CEST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KvCcq5TPRz1JBqH; Thu, 5 May 2022 20:27:07 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 20:28:11 +0800 From: "Min Hu (Connor)" To: CC: Chengwen Feng , , Min Hu , Yisen Zhuang , Lijun Ou Subject: [PATCH v2 4/7] net/hns3: fix more mbufs are freed when Tx done cleanup Date: Thu, 5 May 2022 20:27:04 +0800 Message-ID: <20220505122707.61182-5-humin29@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220505122707.61182-1-humin29@huawei.com> References: <20220406092240.52900-1-humin29@huawei.com> <20220505122707.61182-1-humin29@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected 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 From: Chengwen Feng Currently, the hns3 PMD may free more mbufs than free_cnt parameter, this is an incorrect implementation. This patch fixes it. Fixes: 0b77e8f3d364 ("net/hns3: optimize Tx performance") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_rxtx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index a28de06dfd..0c91e4721e 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -4595,7 +4595,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) static int hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt) { - uint16_t round_free_cnt; + uint16_t round_cnt; uint32_t idx; if (free_cnt == 0 || free_cnt > txq->nb_tx_desc) @@ -4604,13 +4604,13 @@ hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt) if (txq->tx_rs_thresh == 0) return 0; - round_free_cnt = roundup(free_cnt, txq->tx_rs_thresh); - for (idx = 0; idx < round_free_cnt; idx += txq->tx_rs_thresh) { + round_cnt = rounddown(free_cnt, txq->tx_rs_thresh); + for (idx = 0; idx < round_cnt; idx += txq->tx_rs_thresh) { if (hns3_tx_free_useless_buffer(txq) != 0) break; } - return RTE_MIN(idx, free_cnt); + return idx; } int -- 2.33.0