* [PATCH] net/bonding: another fix to LACP mempool size @ 2022-03-04 9:56 Gaoxiang Liu 2022-03-05 2:26 ` [PATCH v2] " Gaoxiang Liu 0 siblings, 1 reply; 20+ messages in thread From: Gaoxiang Liu @ 2022-03-04 9:56 UTC (permalink / raw) To: chas3, humin29; +Cc: dev, liugaoxiang, Gaoxiang Liu 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: All mbufs from a slave' private pool(used exclusively for transmitting LACPDUs) have been allocated and are still sitting in the device's tx descriptor ring and other cores' mempool caches. 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 <liugaoxiang@huawei.com> --- drivers/net/bonding/rte_eth_bond_8023ad.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c index ca50583d62..f896195447 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,6 +1101,9 @@ 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_SIZ; + total_tx_desc = rte_lcore_count() * cache_size * 1.5; 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 ? -- 2.32.0 ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2] net/bonding: another fix to LACP mempool size 2022-03-04 9:56 [PATCH] net/bonding: another fix to LACP mempool size Gaoxiang Liu @ 2022-03-05 2:26 ` Gaoxiang Liu 2022-03-05 7:09 ` [PATCH v3] " Gaoxiang Liu 0 siblings, 1 reply; 20+ messages in thread From: Gaoxiang Liu @ 2022-03-05 2:26 UTC (permalink / raw) To: chas3, humin29; +Cc: dev, liugaoxiang, Gaoxiang Liu 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: All mbufs from a slave' private pool(used exclusively for transmitting LACPDUs) have been allocated and are still sitting in the device's tx descriptor ring and other cores' mempool caches. 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 <liugaoxiang@huawei.com> --- v2: * Fixed compile issues. --- drivers/net/bonding/rte_eth_bond_8023ad.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c index ca50583d62..831c7dc6ab 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,6 +1101,9 @@ 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 * 1.5; 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 ? -- 2.32.0 ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v3] net/bonding: another fix to LACP mempool size 2022-03-05 2:26 ` [PATCH v2] " Gaoxiang Liu @ 2022-03-05 7:09 ` Gaoxiang Liu 2022-03-08 1:17 ` Min Hu (Connor) 2022-03-08 14:24 ` [PATCH v4] " Gaoxiang Liu 0 siblings, 2 replies; 20+ messages in thread From: Gaoxiang Liu @ 2022-03-05 7:09 UTC (permalink / raw) To: chas3, humin29; +Cc: dev, liugaoxiang, Gaoxiang Liu 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: All mbufs from a slave' private pool(used exclusively for transmitting LACPDUs) have been allocated and are still sitting in the device's tx descriptor ring and other cores' mempool caches. 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 <liugaoxiang@huawei.com> --- v2: * Fixed compile issues. v3: * delete duplicate code. --- drivers/net/bonding/rte_eth_bond_8023ad.c | 8 +++++--- 1 file changed, 5 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..d73038b018 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 * 1.5; 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. */ -- 2.32.0 ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3] net/bonding: another fix to LACP mempool size 2022-03-05 7:09 ` [PATCH v3] " Gaoxiang Liu @ 2022-03-08 1:17 ` Min Hu (Connor) 2022-03-08 14:24 ` [PATCH v4] " Gaoxiang Liu 1 sibling, 0 replies; 20+ messages in thread From: Min Hu (Connor) @ 2022-03-08 1:17 UTC (permalink / raw) To: Gaoxiang Liu, chas3; +Cc: dev, liugaoxiang HI, 在 2022/3/5 15:09, Gaoxiang Liu 写道: > 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: All mbufs from a slave' private pool(used exclusively for > transmitting LACPDUs) > have been allocated and are still sitting in the device's tx descriptor > ring and > other cores' mempool caches. > > 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. How do you get this way to calculate 'total_tx_desc'? I want to know the causal logic. > > 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 <liugaoxiang@huawei.com> > > --- > v2: > * Fixed compile issues. > > v3: > * delete duplicate code. > --- > drivers/net/bonding/rte_eth_bond_8023ad.c | 8 +++++--- > 1 file changed, 5 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..d73038b018 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 * 1.5; According to your comment, is it wrong? or: 'total_tx_desc += rte_lcore_count() * cache_size * 1.5;' > 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. */ > ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v4] net/bonding: another fix to LACP mempool size 2022-03-05 7:09 ` [PATCH v3] " Gaoxiang Liu 2022-03-08 1:17 ` Min Hu (Connor) @ 2022-03-08 14:24 ` Gaoxiang Liu 2022-03-09 0:32 ` Min Hu (Connor) ` (3 more replies) 1 sibling, 4 replies; 20+ messages in thread From: Gaoxiang Liu @ 2022-03-08 14:24 UTC (permalink / raw) To: chas3, humin29; +Cc: dev, liugaoxiang, Gaoxiang Liu 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 <liugaoxiang@huawei.com> --- 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 ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4] net/bonding: another fix to LACP mempool size 2022-03-08 14:24 ` [PATCH v4] " Gaoxiang Liu @ 2022-03-09 0:32 ` Min Hu (Connor) 2022-03-09 1:25 ` Stephen Hemminger ` (2 subsequent siblings) 3 siblings, 0 replies; 20+ messages in thread From: Min Hu (Connor) @ 2022-03-09 0:32 UTC (permalink / raw) To: Gaoxiang Liu, chas3; +Cc: dev, liugaoxiang Acked-by: Min Hu (Connor) <humin29@huawei.com> 在 2022/3/8 22:24, Gaoxiang Liu 写道: > 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 <liugaoxiang@huawei.com> > > --- > 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.*/ > ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4] net/bonding: another fix to LACP mempool size 2022-03-08 14:24 ` [PATCH v4] " Gaoxiang Liu 2022-03-09 0:32 ` Min Hu (Connor) @ 2022-03-09 1:25 ` Stephen Hemminger 2022-03-09 2:53 ` Min Hu (Connor) 2022-03-09 1:26 ` Stephen Hemminger 2022-03-25 12:10 ` [PATCH v5] " Gaoxiang Liu 3 siblings, 1 reply; 20+ messages in thread From: Stephen Hemminger @ 2022-03-09 1:25 UTC (permalink / raw) To: Gaoxiang Liu; +Cc: chas3, humin29, dev, liugaoxiang On Tue, 8 Mar 2022 22:24:02 +0800 Gaoxiang Liu <gaoxiangliu0@163.com> wrote: > 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 Why is a magic number from bonding ending up in the user API for mempool? ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4] net/bonding: another fix to LACP mempool size 2022-03-09 1:25 ` Stephen Hemminger @ 2022-03-09 2:53 ` Min Hu (Connor) 2022-03-25 12:02 ` Gaoxiang Liu 0 siblings, 1 reply; 20+ messages in thread From: Min Hu (Connor) @ 2022-03-09 2:53 UTC (permalink / raw) To: Stephen Hemminger, Gaoxiang Liu; +Cc: chas3, dev, liugaoxiang Hi, Stephen, 在 2022/3/9 9:25, Stephen Hemminger 写道: > On Tue, 8 Mar 2022 22:24:02 +0800 > Gaoxiang Liu <gaoxiangliu0@163.com> wrote: > >> 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 > > Why is a magic number from bonding ending up in the user API for mempool? Yes, I suggest putting the macro(name should be changed) in bonding. No need to define a new RTE_* macro in mempool. By the way, the RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER is the same as CACHE_FLUSHTHRESH_MULTIPLIER already defined in rte_mempool.c. > . > ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re:Re: [PATCH v4] net/bonding: another fix to LACP mempool size 2022-03-09 2:53 ` Min Hu (Connor) @ 2022-03-25 12:02 ` Gaoxiang Liu 0 siblings, 0 replies; 20+ messages in thread From: Gaoxiang Liu @ 2022-03-25 12:02 UTC (permalink / raw) To: Min Hu (Connor); +Cc: Stephen Hemminger, chas3, dev, liugaoxiang [-- Attachment #1: Type: text/plain, Size: 936 bytes --] Hi, Stephen, Min Hu, I will fix the issues. Thanks. Gaoxiang. At 2022-03-09 10:53:15, "Min Hu (Connor)" <humin29@huawei.com> wrote: >Hi, Stephen, > >在 2022/3/9 9:25, Stephen Hemminger 写道: >> On Tue, 8 Mar 2022 22:24:02 +0800 >> Gaoxiang Liu <gaoxiangliu0@163.com> wrote: >> >>> 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 >> >> Why is a magic number from bonding ending up in the user API for mempool? >Yes, I suggest putting the macro(name should be changed) in bonding. No >need to define a new RTE_* macro in mempool. >By the way, the RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER is the same as >CACHE_FLUSHTHRESH_MULTIPLIER already defined in rte_mempool.c. > > >> . >> [-- Attachment #2: Type: text/html, Size: 1373 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4] net/bonding: another fix to LACP mempool size 2022-03-08 14:24 ` [PATCH v4] " Gaoxiang Liu 2022-03-09 0:32 ` Min Hu (Connor) 2022-03-09 1:25 ` Stephen Hemminger @ 2022-03-09 1:26 ` Stephen Hemminger 2022-03-25 12:10 ` [PATCH v5] " Gaoxiang Liu 3 siblings, 0 replies; 20+ messages in thread From: Stephen Hemminger @ 2022-03-09 1:26 UTC (permalink / raw) To: Gaoxiang Liu; +Cc: chas3, humin29, dev, liugaoxiang On Tue, 8 Mar 2022 22:24:02 +0800 Gaoxiang Liu <gaoxiangliu0@163.com> wrote: > + cache_size = RTE_MEMPOOL_CACHE_MAX_SIZE >= 32 ? > + 32 : RTE_MEMPOOL_CACHE_MAX_SIZE; No need to open code a min(). cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_SIZE, 32); ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v5] net/bonding: another fix to LACP mempool size 2022-03-08 14:24 ` [PATCH v4] " Gaoxiang Liu ` (2 preceding siblings ...) 2022-03-09 1:26 ` Stephen Hemminger @ 2022-03-25 12:10 ` Gaoxiang Liu 2022-03-25 13:01 ` Gaoxiang Liu 3 siblings, 1 reply; 20+ messages in thread From: Gaoxiang Liu @ 2022-03-25 12:10 UTC (permalink / raw) To: chas3, humin29; +Cc: dev, liugaoxiang, Gaoxiang Liu 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 <liugaoxiang@huawei.com> --- v2: * Fixed compile issues. v3: * delete duplicate code. v4; * Fixed some issues. 1. total_tx_desc should use += 2. add detailed logs v5: * Fixed some issues. 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c 2. use RTE_MIN --- drivers/net/bonding/rte_eth_bond_8023ad.c | 11 ++++++++--- 1 file changed, 8 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..4c65e7fff7 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,15 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, total_tx_desc += bd_tx_q->nb_tx_desc; } +/* 8023AD_CACHE_FLUSHTHRESH_MULTIPLIER is the same as + * CACHE_FLUSHTHRESH_MULTIPLIER already defined in rte_mempool.c */ +#define 8023AD_CACHE_FLUSHTHRESH_MULTIPLIER 1.5 + + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); + total_tx_desc += rte_lcore_count() * cache_size * 8023AD_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. */ -- 2.32.0 ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v5] net/bonding: another fix to LACP mempool size 2022-03-25 12:10 ` [PATCH v5] " Gaoxiang Liu @ 2022-03-25 13:01 ` Gaoxiang Liu 2022-03-25 13:13 ` Morten Brørup 2022-03-25 13:34 ` [PATCH v6] " Gaoxiang Liu 0 siblings, 2 replies; 20+ messages in thread From: Gaoxiang Liu @ 2022-03-25 13:01 UTC (permalink / raw) To: chas3, humin29; +Cc: dev, liugaoxiang, Gaoxiang Liu 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 <liugaoxiang@huawei.com> --- v2: * Fixed compile issues. v3: * delete duplicate code. v4; * Fixed some issues. 1. total_tx_desc should use += 2. add detailed logs v5: * Fixed some issues. 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c 2. use RTE_MIN --- drivers/net/bonding/rte_eth_bond_8023ad.c | 11 ++++++++--- 1 file changed, 8 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..2c39b0d062 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,15 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, total_tx_desc += bd_tx_q->nb_tx_desc; } +/* BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER is the same as + * CACHE_FLUSHTHRESH_MULTIPLIER already defined in rte_mempool.c */ +#define BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER 1.5 + + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); + total_tx_desc += rte_lcore_count() * cache_size * BONDING_8023AD_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. */ -- 2.32.0 ^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [PATCH v5] net/bonding: another fix to LACP mempool size 2022-03-25 13:01 ` Gaoxiang Liu @ 2022-03-25 13:13 ` Morten Brørup 2022-03-26 12:57 ` Wang, Haiyue 2022-03-25 13:34 ` [PATCH v6] " Gaoxiang Liu 1 sibling, 1 reply; 20+ messages in thread From: Morten Brørup @ 2022-03-25 13:13 UTC (permalink / raw) To: Gaoxiang Liu, chas3, humin29 Cc: dev, liugaoxiang, olivier.matz, andrew.rybchenko +CC mempool maintainers > From: Gaoxiang Liu [mailto:gaoxiangliu0@163.com] > Sent: Friday, 25 March 2022 14.02 > > 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 <liugaoxiang@huawei.com> > > --- > v2: > * Fixed compile issues. > > v3: > * delete duplicate code. > > v4; > * Fixed some issues. > 1. total_tx_desc should use += > 2. add detailed logs > > v5: > * Fixed some issues. > 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c > 2. use RTE_MIN > --- > drivers/net/bonding/rte_eth_bond_8023ad.c | 11 ++++++++--- > 1 file changed, 8 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..2c39b0d062 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,15 @@ bond_mode_8023ad_activate_slave(struct > rte_eth_dev *bond_dev, > total_tx_desc += bd_tx_q->nb_tx_desc; > } > > +/* BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER is the same as > + * CACHE_FLUSHTHRESH_MULTIPLIER already defined in rte_mempool.c */ > +#define BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER 1.5 Very important comment. Thank you! May I suggest that a similar comment is added to the rte_mempool.c file, so if CACHE_FLUSHTHRESH_MULTIPLIER is changed there, we don't forget to change the copy-pasted code in the rte_eth_bond_8023ad.c file too. It has previously been discussed changing it from 1.5 to 2 for symmetry reasons. > + > + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); > + total_tx_desc += rte_lcore_count() * cache_size * > BONDING_8023AD_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. */ > -- > 2.32.0 > ^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [PATCH v5] net/bonding: another fix to LACP mempool size 2022-03-25 13:13 ` Morten Brørup @ 2022-03-26 12:57 ` Wang, Haiyue 0 siblings, 0 replies; 20+ messages in thread From: Wang, Haiyue @ 2022-03-26 12:57 UTC (permalink / raw) To: Morten Brørup, Gaoxiang Liu, chas3, humin29 Cc: dev, liugaoxiang, olivier.matz, andrew.rybchenko > -----Original Message----- > From: Morten Brørup <mb@smartsharesystems.com> > Sent: Friday, March 25, 2022 21:14 > To: Gaoxiang Liu <gaoxiangliu0@163.com>; chas3@att.com; humin29@huawei.com > Cc: dev@dpdk.org; liugaoxiang@huawei.com; olivier.matz@6wind.com; andrew.rybchenko@oktetlabs.ru > Subject: RE: [PATCH v5] net/bonding: another fix to LACP mempool size > > +CC mempool maintainers > > > From: Gaoxiang Liu [mailto:gaoxiangliu0@163.com] > > Sent: Friday, 25 March 2022 14.02 > > > > 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 <liugaoxiang@huawei.com> > > > > --- > > v2: > > * Fixed compile issues. > > > > v3: > > * delete duplicate code. > > > > v4; > > * Fixed some issues. > > 1. total_tx_desc should use += > > 2. add detailed logs > > > > v5: > > * Fixed some issues. > > 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c > > 2. use RTE_MIN > > --- > > drivers/net/bonding/rte_eth_bond_8023ad.c | 11 ++++++++--- > > > > +/* BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER is the same as > > + * CACHE_FLUSHTHRESH_MULTIPLIER already defined in rte_mempool.c */ > > +#define BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER 1.5 > > Very important comment. Thank you! > > May I suggest that a similar comment is added to the rte_mempool.c file, so if > CACHE_FLUSHTHRESH_MULTIPLIER is changed there, we don't forget to change the copy-pasted code in the > rte_eth_bond_8023ad.c file too. It has previously been discussed changing it from 1.5 to 2 for > symmetry reasons. Then, introduce some kind of public API macro, like RTE_MEMPOOL_CACHE_MAX_FLUSHTHRESH_MULTIPLIER as RTE_MEMPOOL_CACHE_MAX_SIZE does ? So that when calling mempool create API, it can do other kind of calculation, like RTE_MIN(user's new flush multiper, RTE_MEMPOOL_CACHE_MAX_FLUSHTHRESH_MULTIPLIER). Just a suggestion, so that no need add strange comments like BONDING_8023AD in an lib. > > > + > > + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); > > + total_tx_desc += rte_lcore_count() * cache_size * > > BONDING_8023AD_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. */ > > -- > > 2.32.0 > > ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v6] net/bonding: another fix to LACP mempool size 2022-03-25 13:01 ` Gaoxiang Liu 2022-03-25 13:13 ` Morten Brørup @ 2022-03-25 13:34 ` Gaoxiang Liu 2022-03-25 14:04 ` Morten Brørup 2022-03-28 15:16 ` [PATCH v7] " Gaoxiang Liu 1 sibling, 2 replies; 20+ messages in thread From: Gaoxiang Liu @ 2022-03-25 13:34 UTC (permalink / raw) To: chas3, humin29; +Cc: dev, liugaoxiang, Gaoxiang Liu 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 <liugaoxiang@huawei.com> --- v2: * Fixed compile issues. v3: * delete duplicate code. v4; * Fixed some issues. 1. total_tx_desc should use += 2. add detailed logs v5: * Fixed some issues. 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c 2. use RTE_MIN v6: * add a comment of CACHE_FLUSHTHRESH_MULTIPLIER macro --- drivers/net/bonding/rte_eth_bond_8023ad.c | 11 ++++++++--- lib/mempool/rte_mempool.c | 2 ++ 2 files changed, 10 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..2c39b0d062 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,15 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, total_tx_desc += bd_tx_q->nb_tx_desc; } +/* BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER is the same as + * CACHE_FLUSHTHRESH_MULTIPLIER already defined in rte_mempool.c */ +#define BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER 1.5 + + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); + total_tx_desc += rte_lcore_count() * cache_size * BONDING_8023AD_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.c b/lib/mempool/rte_mempool.c index c5a699b1d6..6126067628 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -55,6 +55,8 @@ static void mempool_event_callback_invoke(enum rte_mempool_event event, struct rte_mempool *mp); +/* CACHE_FLUSHTHRESH_MULTIPLIER is the same as + * BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER in rte_eth_bond_8023ad.c */ #define CACHE_FLUSHTHRESH_MULTIPLIER 1.5 #define CALC_CACHE_FLUSHTHRESH(c) \ ((typeof(c))((c) * CACHE_FLUSHTHRESH_MULTIPLIER)) -- 2.32.0 ^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [PATCH v6] net/bonding: another fix to LACP mempool size 2022-03-25 13:34 ` [PATCH v6] " Gaoxiang Liu @ 2022-03-25 14:04 ` Morten Brørup 2022-03-28 15:16 ` [PATCH v7] " Gaoxiang Liu 1 sibling, 0 replies; 20+ messages in thread From: Morten Brørup @ 2022-03-25 14:04 UTC (permalink / raw) To: Gaoxiang Liu, chas3, humin29; +Cc: dev, liugaoxiang > From: Gaoxiang Liu [mailto:gaoxiangliu0@163.com] > Sent: Friday, 25 March 2022 14.34 > > 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 <liugaoxiang@huawei.com> > > --- > v2: > * Fixed compile issues. > > v3: > * delete duplicate code. > > v4; > * Fixed some issues. > 1. total_tx_desc should use += > 2. add detailed logs > > v5: > * Fixed some issues. > 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c > 2. use RTE_MIN > > v6: > * add a comment of CACHE_FLUSHTHRESH_MULTIPLIER macro > --- > drivers/net/bonding/rte_eth_bond_8023ad.c | 11 ++++++++--- > lib/mempool/rte_mempool.c | 2 ++ > 2 files changed, 10 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..2c39b0d062 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,15 @@ bond_mode_8023ad_activate_slave(struct > rte_eth_dev *bond_dev, > total_tx_desc += bd_tx_q->nb_tx_desc; > } > > +/* BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER is the same as > + * CACHE_FLUSHTHRESH_MULTIPLIER already defined in rte_mempool.c */ > +#define BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER 1.5 > + > + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); > + total_tx_desc += rte_lcore_count() * cache_size * > BONDING_8023AD_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.c b/lib/mempool/rte_mempool.c > index c5a699b1d6..6126067628 100644 > --- a/lib/mempool/rte_mempool.c > +++ b/lib/mempool/rte_mempool.c > @@ -55,6 +55,8 @@ static void > mempool_event_callback_invoke(enum rte_mempool_event event, > struct rte_mempool *mp); > > +/* CACHE_FLUSHTHRESH_MULTIPLIER is the same as > + * BONDING_8023AD_CACHE_FLUSHTHRESH_MULTIPLIER in > rte_eth_bond_8023ad.c */ > #define CACHE_FLUSHTHRESH_MULTIPLIER 1.5 > #define CALC_CACHE_FLUSHTHRESH(c) \ > ((typeof(c))((c) * CACHE_FLUSHTHRESH_MULTIPLIER)) > -- > 2.32.0 > Acked-by: Morten Brørup <mb@smartsharesystems.com> ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v7] net/bonding: another fix to LACP mempool size 2022-03-25 13:34 ` [PATCH v6] " Gaoxiang Liu 2022-03-25 14:04 ` Morten Brørup @ 2022-03-28 15:16 ` Gaoxiang Liu 2022-04-29 14:20 ` Ferruh Yigit 2024-04-12 19:04 ` Ferruh Yigit 1 sibling, 2 replies; 20+ messages in thread From: Gaoxiang Liu @ 2022-03-28 15:16 UTC (permalink / raw) To: chas3, humin29; +Cc: olivier.matz, dev, liugaoxiang, Gaoxiang Liu 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 <liugaoxiang@huawei.com> --- v2: * Fixed compile issues. v3: * delete duplicate code. v4; * Fixed some issues. 1. total_tx_desc should use += 2. add detailed logs v5: * Fixed some issues. 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c 2. use RTE_MIN v6: * add a comment of CACHE_FLUSHTHRESH_MULTIPLIER macro v7: * Fixed some issues. 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_mempool.h --- drivers/net/bonding/rte_eth_bond_8023ad.c | 7 ++++--- lib/mempool/rte_mempool.h | 2 ++ 2 files changed, 6 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..f7f6828126 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,11 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, total_tx_desc += bd_tx_q->nb_tx_desc; } + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); + 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 ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v7] net/bonding: another fix to LACP mempool size 2022-03-28 15:16 ` [PATCH v7] " Gaoxiang Liu @ 2022-04-29 14:20 ` Ferruh Yigit 2022-05-01 7:02 ` Matan Azrad 2024-04-12 19:04 ` Ferruh Yigit 1 sibling, 1 reply; 20+ messages in thread From: Ferruh Yigit @ 2022-04-29 14:20 UTC (permalink / raw) To: Gaoxiang Liu, chas3, humin29 Cc: olivier.matz, dev, liugaoxiang, Andrew Rybchenko, Morten Brørup, Haiyue Wang, Matan Azrad, Viacheslav Ovsiienko On 3/28/2022 4:16 PM, Gaoxiang Liu wrote: > 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 <liugaoxiang@huawei.com> > > --- > v2: > * Fixed compile issues. > > v3: > * delete duplicate code. > > v4; > * Fixed some issues. > 1. total_tx_desc should use += > 2. add detailed logs > > v5: > * Fixed some issues. > 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c > 2. use RTE_MIN > > v6: > * add a comment of CACHE_FLUSHTHRESH_MULTIPLIER macro > > v7: > * Fixed some issues. > 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_mempool.h > --- > drivers/net/bonding/rte_eth_bond_8023ad.c | 7 ++++--- > lib/mempool/rte_mempool.h | 2 ++ > 2 files changed, 6 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..f7f6828126 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,11 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, > total_tx_desc += bd_tx_q->nb_tx_desc; > } > > + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); > + 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 > + This change seems already get some comments and changes in previous versions. I also thought why we are adding a new macro to the mempool for a bonding driver update, but that is not the whole picture. There is an existing 'CACHE_FLUSHTHRESH_MULTIPLIER' macro in mempool, this patch wants to use it but that macro is not exposed. And I can see there is other user of that macros (mlx5_rxq.c [1]) suffering from same problem. So, what do you think having two patches, - first one is only for mempool update, which removes the 'CACHE_FLUSHTHRESH_MULTIPLIER' from 'rte_mempool.c', adds 'RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER' to 'rte_mempool.h' as this patch does, and update existing usage. - second patch just updates the bonding driver and use the new 'RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER' macro [1] @Matan, @Slava, 'mlx5_rxq.c', comment mentions that it intends to use 'CACHE_FLUSHTHRESH_MULTIPLIER' but can't access it and use a hardcoded value (2). But the hard coded value and macro values doesn't match, is it intentional. When 'RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER' is exposed in header, can it be replaced with hard coded value in the driver? > #define RTE_MEMPOOL_HEADER_COOKIE1 0xbadbadbadadd2e55ULL /**< Header cookie. */ > #define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL /**< Header cookie. */ > #define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL /**< Trailer cookie.*/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [PATCH v7] net/bonding: another fix to LACP mempool size 2022-04-29 14:20 ` Ferruh Yigit @ 2022-05-01 7:02 ` Matan Azrad 0 siblings, 0 replies; 20+ messages in thread From: Matan Azrad @ 2022-05-01 7:02 UTC (permalink / raw) To: Ferruh Yigit, Gaoxiang Liu, chas3, humin29 Cc: olivier.matz, dev, liugaoxiang, Andrew Rybchenko, Morten Brørup, Haiyue Wang, Slava Ovsiienko Hi Ferruh, Gaoxiang From: Ferruh Yigit > On 3/28/2022 4:16 PM, Gaoxiang Liu wrote: > > 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 <liugaoxiang@huawei.com> > > > > --- > > v2: > > * Fixed compile issues. > > > > v3: > > * delete duplicate code. > > > > v4; > > * Fixed some issues. > > 1. total_tx_desc should use += > > 2. add detailed logs > > > > v5: > > * Fixed some issues. > > 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c 2. > use > > RTE_MIN > > > > v6: > > * add a comment of CACHE_FLUSHTHRESH_MULTIPLIER macro > > > > v7: > > * Fixed some issues. > > 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_mempool.h > > --- > > drivers/net/bonding/rte_eth_bond_8023ad.c | 7 ++++--- > > lib/mempool/rte_mempool.h | 2 ++ > > 2 files changed, 6 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..f7f6828126 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,11 @@ bond_mode_8023ad_activate_slave(struct > rte_eth_dev *bond_dev, > > total_tx_desc += bd_tx_q->nb_tx_desc; > > } > > > > + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); > > + 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 > > + > > This change seems already get some comments and changes in previous > versions. > > I also thought why we are adding a new macro to the mempool for a bonding > driver update, but that is not the whole picture. > There is an existing 'CACHE_FLUSHTHRESH_MULTIPLIER' macro in mempool, > this patch wants to use it but that macro is not exposed. > And I can see there is other user of that macros (mlx5_rxq.c [1]) suffering > from same problem. > > So, what do you think having two patches, > - first one is only for mempool update, which removes the > 'CACHE_FLUSHTHRESH_MULTIPLIER' from 'rte_mempool.c', adds > 'RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER' to 'rte_mempool.h' as > this patch does, and update existing usage. > > - second patch just updates the bonding driver and use the new > 'RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER' macro > > > > [1] @Matan, @Slava, > 'mlx5_rxq.c', comment mentions that it intends to use > 'CACHE_FLUSHTHRESH_MULTIPLIER' but can't access it and use a hardcoded > value (2). But the hard coded value and macro values doesn't match, is it > intentional. I think it is to pass the cache size check into mempool API. > When 'RTE_MEMPOOL_CACHE_FLUSHTHRESH_MULTIPLIER' is exposed in > header, can it be replaced with hard coded value in the driver? Yes, we need to be careful with the types when doing the calculation to ensure it will continue to pass the mempool check. For sure, we can help and validate here. Matan > > > > > #define RTE_MEMPOOL_HEADER_COOKIE1 0xbadbadbadadd2e55ULL > /**< Header cookie. */ > > #define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL > /**< Header cookie. */ > > #define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL > /**< > > Trailer cookie.*/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v7] net/bonding: another fix to LACP mempool size 2022-03-28 15:16 ` [PATCH v7] " Gaoxiang Liu 2022-04-29 14:20 ` Ferruh Yigit @ 2024-04-12 19:04 ` Ferruh Yigit 1 sibling, 0 replies; 20+ messages in thread From: Ferruh Yigit @ 2024-04-12 19:04 UTC (permalink / raw) To: Gaoxiang Liu, chas3, humin29 Cc: olivier.matz, dev, liugaoxiang, Morten Brørup On 3/28/2022 4:16 PM, Gaoxiang Liu wrote: > 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. > Hi Gaoxiang, Briefly, this patch increases the mempool size, an additional amount to compensate cache size. Above mentions two reasons for increase, 1. mbufs in Tx ring of the device. As far as I can see mbufs allocated from 'mbuf_pool' and enqueued to device Tx ring, and if what I understand above is Tx queue may be disabled causing mbufs stuck in this ring. 2. mbufs stuck in mempool per core cache. Increasing mempool size can be an option but can we address root cause, for 1. if the device Tx queue is disabled can we skip enqueue to the ring. And for 2. as you said mbuf is allocated only in the interrupt thread which doesn't have any cache, so not sure why other lcore caches filled. Also can we disable the caches instead, as this is already used for low traffic? > 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 <liugaoxiang@huawei.com> > > --- > v2: > * Fixed compile issues. > > v3: > * delete duplicate code. > > v4; > * Fixed some issues. > 1. total_tx_desc should use += > 2. add detailed logs > > v5: > * Fixed some issues. > 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_eth_bond-8023ad.c > 2. use RTE_MIN > > v6: > * add a comment of CACHE_FLUSHTHRESH_MULTIPLIER macro > > v7: > * Fixed some issues. > 1. move CACHE_FLUSHTHRESH_MULTIPLIER to rte_mempool.h > --- > drivers/net/bonding/rte_eth_bond_8023ad.c | 7 ++++--- > lib/mempool/rte_mempool.h | 2 ++ > 2 files changed, 6 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..f7f6828126 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,11 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, > total_tx_desc += bd_tx_q->nb_tx_desc; > } > > + cache_size = RTE_MIN(RTE_MEMPOOL_CACHE_MAX_SIZE, 32); > I can see it is coming from old code, but do you know why 32 selected as cache size, is it an arbitrary value? > + 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 > + > I can see we delve into discussion related to this exposing this value from library, instead of having a copy in driver (which is valid point). Looking to the reason to usage, driver tries to compensate the mbufs may be may be stuck in the cache till they hit the threshold. But this flush threshold value can be driver internal, and it seems original intention is not have something driver/application be aware of this value. So instead of using this value, what about first try disabling cache as mentioned above? ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-04-12 19:04 UTC | newest] Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-04 9:56 [PATCH] net/bonding: another fix to LACP mempool size Gaoxiang Liu 2022-03-05 2:26 ` [PATCH v2] " Gaoxiang Liu 2022-03-05 7:09 ` [PATCH v3] " Gaoxiang Liu 2022-03-08 1:17 ` Min Hu (Connor) 2022-03-08 14:24 ` [PATCH v4] " Gaoxiang Liu 2022-03-09 0:32 ` Min Hu (Connor) 2022-03-09 1:25 ` Stephen Hemminger 2022-03-09 2:53 ` Min Hu (Connor) 2022-03-25 12:02 ` Gaoxiang Liu 2022-03-09 1:26 ` Stephen Hemminger 2022-03-25 12:10 ` [PATCH v5] " Gaoxiang Liu 2022-03-25 13:01 ` Gaoxiang Liu 2022-03-25 13:13 ` Morten Brørup 2022-03-26 12:57 ` Wang, Haiyue 2022-03-25 13:34 ` [PATCH v6] " Gaoxiang Liu 2022-03-25 14:04 ` Morten Brørup 2022-03-28 15:16 ` [PATCH v7] " Gaoxiang Liu 2022-04-29 14:20 ` Ferruh Yigit 2022-05-01 7:02 ` Matan Azrad 2024-04-12 19:04 ` Ferruh Yigit
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).