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 1F8BBA00C2; Tue, 8 Mar 2022 15:24:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6047840696; Tue, 8 Mar 2022 15:24:40 +0100 (CET) Received: from m12-18.163.com (m12-18.163.com [220.181.12.18]) by mails.dpdk.org (Postfix) with ESMTP id E318F40696 for ; Tue, 8 Mar 2022 15:24:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=kfCF8 cn2c7P3HcCnNcSOV825AizRWVHdqa2mENIfDAY=; b=HQLiQkPnEJ19MqpshHrAw l34ybNGIEEp86g20p3l/dKdlPtR6duBkoNy+lNj5MOs5rVsJ88EgwLZTcZgscznf G4NVH1HRXZByGKSHJMlQNd7D6ay7iTnAOD0EqFGPPxnf3n0PixDLkqpT+e/m++fb Js2atlNir5tVEYkV5u8N7k= Received: from DESKTOP-ONA2IA7.localdomain (unknown [223.104.159.196]) by smtp14 (Coremail) with SMTP id EsCowACXzwMSZydid6CDGA--.5977S4; Tue, 08 Mar 2022 22:24:23 +0800 (CST) From: Gaoxiang Liu To: chas3@att.com, humin29@huawei.com Cc: dev@dpdk.org, liugaoxiang@huawei.com, Gaoxiang Liu Subject: [PATCH v4] net/bonding: another fix to LACP mempool size Date: Tue, 8 Mar 2022 22:24:02 +0800 Message-Id: <20220308142402.2455-1-gaoxiangliu0@163.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220305070922.308-1-gaoxiangliu0@163.com> References: <20220305070922.308-1-gaoxiangliu0@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: EsCowACXzwMSZydid6CDGA--.5977S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxGF13Kry7Xw1DWr47Jw1rtFb_yoW5ZryUpr W7Wan8tF1UArZI9ws7X3WFkws5uas2vr4UKws8Za4rAr47AFn8Kr18try5urW8WrWktrs0 vF4UZasIgF45GrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRs0egUUUUU= X-Originating-IP: [223.104.159.196] X-CM-SenderInfo: xjdr5xxdqjzxjxq6il2tof0z/xtbBDxi9OlPAPTrMsQAAs5 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 The following log message may appear after a slave is idle(or nearly idle) for a few minutes:"PMD: Failed to allocate LACP packet from pool". And bond mode 4 negotiation may fail. Problem:When bond mode 4 has been chosed and delicated queue has not been enable, all mbufs from a slave' private pool(used exclusively for transmitting LACPDUs) have been allocated in interrupt thread, and are still sitting in the device's tx descriptor ring and other cores' mempool caches in fwd thread. Thus the interrupt thread can not alloc LACP packet from pool. Solution: Ensure that each slave'tx (LACPDU) mempool owns more than n-tx-queues * n-tx-descriptor + fwd_core_num * per-core-mmempool-flush-threshold mbufs. Note that the LACP tx machine fuction is the only code that allocates from a slave's private pool. It runs in the context of the interrupt thread, and thus it has no mempool cache of its own. Signed-off-by: Gaoxiang Liu --- v2: * Fixed compile issues. v3: * delete duplicate code. v4; * Fixed some issues. 1. total_tx_desc should use += 2. add detailed logs --- drivers/net/bonding/rte_eth_bond_8023ad.c | 8 +++++--- lib/mempool/rte_mempool.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c index ca50583d62..d2168073cc 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.c +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c @@ -1050,6 +1050,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint32_t total_tx_desc; struct bond_tx_queue *bd_tx_q; uint16_t q_id; + uint32_t cache_size; /* Given slave mus not be in active list */ RTE_ASSERT(find_slave_by_id(internals->active_slaves, @@ -1100,11 +1101,12 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, total_tx_desc += bd_tx_q->nb_tx_desc; } + cache_size = RTE_MEMPOOL_CACHE_MAX_SIZE >= 32 ? + 32 : RTE_MEMPOOL_CACHE_MAX_SIZE; + total_tx_desc += rte_lcore_count() * cache_size * RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER; snprintf(mem_name, RTE_DIM(mem_name), "slave_port%u_pool", slave_id); port->mbuf_pool = rte_pktmbuf_pool_create(mem_name, total_tx_desc, - RTE_MEMPOOL_CACHE_MAX_SIZE >= 32 ? - 32 : RTE_MEMPOOL_CACHE_MAX_SIZE, - 0, element_size, socket_id); + cache_size, 0, element_size, socket_id); /* Any memory allocation failure in initialization is critical because * resources can't be free, so reinitialization is impossible. */ diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 1e7a3c1527..fa15ed710f 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -56,6 +56,8 @@ extern "C" { #endif +#define RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER 1.5 + #define RTE_MEMPOOL_HEADER_COOKIE1 0xbadbadbadadd2e55ULL /**< Header cookie. */ #define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL /**< Header cookie. */ #define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL /**< Trailer cookie.*/ -- 2.32.0