xsk: fix underflow issues in zerocopy xmit
Subsystems (6)
v2 cover xsk: fix underflow issues in zerocopy xmit
From: Jason Xing <[email protected]>
Fix two underflow issues around {stmmac_xdp|igb}_xmit_zc().
Jason Xing (2):
stmmac: xsk: fix underflow of budget in zerocopy mode
igb: xsk: solve underflow of nb_pkts in zerocopy mode
drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
2.41.3
PATCH v2 1/2 stmmac: xsk: fix underflow of budget in zerocopy mode
From: Jason Xing <[email protected]>
An underflow can happen when the budget number of descs are consumed. as long as the budget is decreased to zero, it will again go into while (budget-- > 0) statement and get decreased by one, so the underflow issue can happen. It will lead to returning true whereas the expected value should be false.
In this case where all the budget is used up, it means zc function should return false to let the poll run again because normally we might have more data to process. Without this patch, zc function would return true instead.
---
v2
1. target net tree instead of net-next
2. revise commit message
3. use for loop to replace while loop
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -2596,7 +2596,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget) budget =min (budget,stmmac_tx_avail (priv, queue)); -while (budget-- >0 ) { +for (; budget >0 ; budget--) struct stmmac_metadata_request meta_req;struct xsk_tx_metadata *meta =NULL ;dma_addr_t dma_addr;
Signature · 1 line
2.41.3
RE: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
Quoted 29 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jason Xing
Sent: Tuesday, July 22, 2025 3:51 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>; Fijalkowski, Maciej <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Jason Xing <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy modeFrom: Jason Xing <[email protected]>
An underflow can happen when the budget number of descs are consumed. as long as the budget is decreased to zero, it will again go into while (budget-- > 0) statement and get decreased by one, so the underflow issue can happen. It will lead to returning true whereas the expected value should be false.
Quoted 7 lines
In this case where all the budget is used up, it means zc function should return false to let the poll run again because normally we might have more data to process. Without this patch, zc function would return true instead.
Fixes 132c32ee5bc0 ("net: stmmac: Add TX via XDP zero-copy socket")Signed-off-by Jason Xing <[email protected]>
Quoted 28 lines
---
v2[email protected]/
1. target net tree instead of net-next
2. revise commit message
3. use for loop to replace while loop--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -2596,7 +2596,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget) budget =min (budget,stmmac_tx_avail (priv, queue)); -while (budget-- >0 ) { +for (; budget >0 ; budget--) struct stmmac_metadata_request meta_req;struct xsk_tx_metadata *meta =NULL ;
dma_addr_tdma_addr;
--
2.41.3
kernel test robot
build botRe: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
In reply to Jason Xingkernel test robot noticed the following build errors:
Hi Jason,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jason-Xing/stmmac-xsk-fix-underflow-of-budget-in-zerocopy-mode/20250722-215348 base: net/main patch link: https://lore.kernel.org/r/20250722135057.85386-2-kerneljasonxing%40gmail.com patch subject: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20250723/[email protected]/config) compiler: alpha-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250723/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: In function 'stmmac_xdp_xmit_zc':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2600:17: error: expected expression before 'struct'
2600 | struct stmmac_metadata_request meta_req;
| ^~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2599:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
2599 | for (; budget > 0; budget--)
| ^~~
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2601:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
2601 | struct xsk_tx_metadata *meta = NULL;
| ^~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2611:25: error: break statement not within loop or switch
2611 | break;
| ^~~~~
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2615:25: error: break statement not within loop or switch
2615 | break;
| ^~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2621:25: error: continue statement not within a loop
2621 | continue;
| ^~~~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2660:17: error: 'meta_req' undeclared (first use in this function); did you mean 'net_eq'?
2660 | meta_req.priv = priv;
| ^~~~~~~~
| net_eq
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2660:17: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2591:14: warning: variable 'work_done' set but not used [-Wunused-but-set-variable]
2591 | bool work_done = true;
| ^~~~~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2586:34: warning: unused variable 'txq_stats' [-Wunused-variable]
2586 | struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue];
| ^~~~~~~~~
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: At top level:
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:32: error: expected declaration specifiers or '...' before '&' token
2685 | u64_stats_update_begin(&txq_stats->napi_syncp);
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:23: error: expected declaration specifiers or '...' before '&' token
2686 | u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
| ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:55: error: unknown type name 'tx_set_ic_bit'
2686 | u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
| ^~~~~~~~~~~~~
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2687:30: error: expected declaration specifiers or '...' before '&' token
2687 | u64_stats_update_end(&txq_stats->napi_syncp);
| ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2689:9: error: expected identifier or '(' before 'if'
2689 | if (tx_desc) {
| ^~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2699:9: error: expected identifier or '(' before 'return'
2699 | return !!budget && work_done;
| ^~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2700:1: error: expected identifier or '(' before '}' token
2700 | }
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: In function 'stmmac_xdp_xmit_zc':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2684:9: warning: control reaches end of non-void function [-Wreturn-type]
2684 | }
| ^vim +/struct +2600 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
1347b419318d6a Song Yoong Siang 2023-11-27 2581
132c32ee5bc09b Ong Boon Leong 2021-04-13 2582 static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
132c32ee5bc09b Ong Boon Leong 2021-04-13 2583 {
132c32ee5bc09b Ong Boon Leong 2021-04-13 2584 struct netdev_queue *nq = netdev_get_tx_queue(priv->dev, queue);
8531c80800c10e Christian Marangi 2022-07-23 2585 struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
8070274b472e2e Jisheng Zhang 2023-09-18 @2586 struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue];
132c32ee5bc09b Ong Boon Leong 2021-04-13 2587 struct xsk_buff_pool *pool = tx_q->xsk_pool;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2588 unsigned int entry = tx_q->cur_tx;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2589 struct dma_desc *tx_desc = NULL;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2590 struct xdp_desc xdp_desc;
132c32ee5bc09b Ong Boon Leong 2021-04-13 @2591 bool work_done = true;
133466c3bbe171 Jisheng Zhang 2023-07-18 2592 u32 tx_set_ic_bit = 0;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2593
132c32ee5bc09b Ong Boon Leong 2021-04-13 2594 /* Avoids TX time-out as we are sharing with slow path */
e92af33e472cf3 Alexander Lobakin 2021-11-17 2595 txq_trans_cond_update(nq);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2596
132c32ee5bc09b Ong Boon Leong 2021-04-13 2597 budget = min(budget, stmmac_tx_avail(priv, queue));
132c32ee5bc09b Ong Boon Leong 2021-04-13 2598
9074ec4e205d86 Jason Xing 2025-07-22 @2599 for (; budget > 0; budget--)
1347b419318d6a Song Yoong Siang 2023-11-27 @2600 struct stmmac_metadata_request meta_req;
1347b419318d6a Song Yoong Siang 2023-11-27 2601 struct xsk_tx_metadata *meta = NULL;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2602 dma_addr_t dma_addr;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2603 bool set_ic;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2604
132c32ee5bc09b Ong Boon Leong 2021-04-13 2605 /* We are sharing with slow path and stop XSK TX desc submission when
132c32ee5bc09b Ong Boon Leong 2021-04-13 2606 * available TX ring is less than threshold.
132c32ee5bc09b Ong Boon Leong 2021-04-13 2607 */
132c32ee5bc09b Ong Boon Leong 2021-04-13 2608 if (unlikely(stmmac_tx_avail(priv, queue) < STMMAC_TX_XSK_AVAIL) ||
132c32ee5bc09b Ong Boon Leong 2021-04-13 2609 !netif_carrier_ok(priv->dev)) {
132c32ee5bc09b Ong Boon Leong 2021-04-13 2610 work_done = false;
132c32ee5bc09b Ong Boon Leong 2021-04-13 @2611 break;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2612 }
132c32ee5bc09b Ong Boon Leong 2021-04-13 2613
132c32ee5bc09b Ong Boon Leong 2021-04-13 2614 if (!xsk_tx_peek_desc(pool, &xdp_desc))
132c32ee5bc09b Ong Boon Leong 2021-04-13 2615 break;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2616
bd17382ac36ed9 Xiaolei Wang 2024-05-13 2617 if (priv->est && priv->est->enable &&
bd17382ac36ed9 Xiaolei Wang 2024-05-13 2618 priv->est->max_sdu[queue] &&
bd17382ac36ed9 Xiaolei Wang 2024-05-13 2619 xdp_desc.len > priv->est->max_sdu[queue]) {
c5c3e1bfc9e0ee Rohan G Thomas 2024-01-27 2620 priv->xstats.max_sdu_txq_drop[queue]++;
c5c3e1bfc9e0ee Rohan G Thomas 2024-01-27 @2621 continue;
c5c3e1bfc9e0ee Rohan G Thomas 2024-01-27 2622 }
c5c3e1bfc9e0ee Rohan G Thomas 2024-01-27 2623
132c32ee5bc09b Ong Boon Leong 2021-04-13 2624 if (likely(priv->extend_desc))
132c32ee5bc09b Ong Boon Leong 2021-04-13 2625 tx_desc = (struct dma_desc *)(tx_q->dma_etx + entry);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2626 else if (tx_q->tbs & STMMAC_TBS_AVAIL)
132c32ee5bc09b Ong Boon Leong 2021-04-13 2627 tx_desc = &tx_q->dma_entx[entry].basic;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2628 else
132c32ee5bc09b Ong Boon Leong 2021-04-13 2629 tx_desc = tx_q->dma_tx + entry;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2630
132c32ee5bc09b Ong Boon Leong 2021-04-13 2631 dma_addr = xsk_buff_raw_get_dma(pool, xdp_desc.addr);
1347b419318d6a Song Yoong Siang 2023-11-27 2632 meta = xsk_buff_get_metadata(pool, xdp_desc.addr);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2633 xsk_buff_raw_dma_sync_for_device(pool, dma_addr, xdp_desc.len);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2634
132c32ee5bc09b Ong Boon Leong 2021-04-13 2635 tx_q->tx_skbuff_dma[entry].buf_type = STMMAC_TXBUF_T_XSK_TX;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2636
132c32ee5bc09b Ong Boon Leong 2021-04-13 2637 /* To return XDP buffer to XSK pool, we simple call
132c32ee5bc09b Ong Boon Leong 2021-04-13 2638 * xsk_tx_completed(), so we don't need to fill up
132c32ee5bc09b Ong Boon Leong 2021-04-13 2639 * 'buf' and 'xdpf'.
132c32ee5bc09b Ong Boon Leong 2021-04-13 2640 */
132c32ee5bc09b Ong Boon Leong 2021-04-13 2641 tx_q->tx_skbuff_dma[entry].buf = 0;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2642 tx_q->xdpf[entry] = NULL;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2643
132c32ee5bc09b Ong Boon Leong 2021-04-13 2644 tx_q->tx_skbuff_dma[entry].map_as_page = false;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2645 tx_q->tx_skbuff_dma[entry].len = xdp_desc.len;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2646 tx_q->tx_skbuff_dma[entry].last_segment = true;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2647 tx_q->tx_skbuff_dma[entry].is_jumbo = false;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2648
132c32ee5bc09b Ong Boon Leong 2021-04-13 2649 stmmac_set_desc_addr(priv, tx_desc, dma_addr);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2650
132c32ee5bc09b Ong Boon Leong 2021-04-13 2651 tx_q->tx_count_frames++;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2652
132c32ee5bc09b Ong Boon Leong 2021-04-13 2653 if (!priv->tx_coal_frames[queue])
132c32ee5bc09b Ong Boon Leong 2021-04-13 2654 set_ic = false;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2655 else if (tx_q->tx_count_frames % priv->tx_coal_frames[queue] == 0)
132c32ee5bc09b Ong Boon Leong 2021-04-13 2656 set_ic = true;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2657 else
132c32ee5bc09b Ong Boon Leong 2021-04-13 2658 set_ic = false;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2659
1347b419318d6a Song Yoong Siang 2023-11-27 @2660 meta_req.priv = priv;
1347b419318d6a Song Yoong Siang 2023-11-27 2661 meta_req.tx_desc = tx_desc;
1347b419318d6a Song Yoong Siang 2023-11-27 2662 meta_req.set_ic = &set_ic;
04f64dea13640f Song Yoong Siang 2025-02-16 2663 meta_req.tbs = tx_q->tbs;
04f64dea13640f Song Yoong Siang 2025-02-16 2664 meta_req.edesc = &tx_q->dma_entx[entry];
1347b419318d6a Song Yoong Siang 2023-11-27 2665 xsk_tx_metadata_request(meta, &stmmac_xsk_tx_metadata_ops,
1347b419318d6a Song Yoong Siang 2023-11-27 2666 &meta_req);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2667 if (set_ic) {
132c32ee5bc09b Ong Boon Leong 2021-04-13 2668 tx_q->tx_count_frames = 0;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2669 stmmac_set_tx_ic(priv, tx_desc);
133466c3bbe171 Jisheng Zhang 2023-07-18 2670 tx_set_ic_bit++;
132c32ee5bc09b Ong Boon Leong 2021-04-13 2671 }
132c32ee5bc09b Ong Boon Leong 2021-04-13 2672
132c32ee5bc09b Ong Boon Leong 2021-04-13 2673 stmmac_prepare_tx_desc(priv, tx_desc, 1, xdp_desc.len,
132c32ee5bc09b Ong Boon Leong 2021-04-13 2674 true, priv->mode, true, true,
132c32ee5bc09b Ong Boon Leong 2021-04-13 2675 xdp_desc.len);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2676
ad72f783de0682 Yanteng Si 2024-08-07 2677 stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2678
1347b419318d6a Song Yoong Siang 2023-11-27 2679 xsk_tx_metadata_to_compl(meta,
1347b419318d6a Song Yoong Siang 2023-11-27 2680 &tx_q->tx_skbuff_dma[entry].xsk_meta);
1347b419318d6a Song Yoong Siang 2023-11-27 2681
8531c80800c10e Christian Marangi 2022-07-23 2682 tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, priv->dma_conf.dma_tx_size);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2683 entry = tx_q->cur_tx;
132c32ee5bc09b Ong Boon Leong 2021-04-13 @2684 }
38cc3c6dcc09dc Petr Tesarik 2024-02-03 @2685 u64_stats_update_begin(&txq_stats->napi_syncp);
38cc3c6dcc09dc Petr Tesarik 2024-02-03 @2686 u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
38cc3c6dcc09dc Petr Tesarik 2024-02-03 2687 u64_stats_update_end(&txq_stats->napi_syncp);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2688
132c32ee5bc09b Ong Boon Leong 2021-04-13 @2689 if (tx_desc) {
132c32ee5bc09b Ong Boon Leong 2021-04-13 2690 stmmac_flush_tx_descriptors(priv, queue);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2691 xsk_tx_release(pool);
132c32ee5bc09b Ong Boon Leong 2021-04-13 2692 }
132c32ee5bc09b Ong Boon Leong 2021-04-13 2693
132c32ee5bc09b Ong Boon Leong 2021-04-13 2694 /* Return true if all of the 3 conditions are met
132c32ee5bc09b Ong Boon Leong 2021-04-13 2695 * a) TX Budget is still available
132c32ee5bc09b Ong Boon Leong 2021-04-13 2696 * b) work_done = true when XSK TX desc peek is empty (no more
132c32ee5bc09b Ong Boon Leong 2021-04-13 2697 * pending XSK TX for transmission)
132c32ee5bc09b Ong Boon Leong 2021-04-13 2698 */
132c32ee5bc09b Ong Boon Leong 2021-04-13 @2699 return !!budget && work_done;
132c32ee5bc09b Ong Boon Leong 2021-04-13 @2700 }
132c32ee5bc09b Ong Boon Leong 2021-04-13 2701 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
Quoted 15 lines · kernel test robot
Hi Jason,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jason-Xing/stmmac-xsk-fix-underflow-of-budget-in-zerocopy-mode/20250722-215348 base: net/main patch link: https://lore.kernel.org/r/20250722135057.85386-2-kerneljasonxing%40gmail.com patch subject: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20250723/[email protected]/config) compiler: alpha-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250723/[email protected]/reproduce)
Quoted 4 lines
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Oops, I posted a wrong version which missed one '{' after the 'for' statement.
Will post a correct version.
Thanks,
Jason
kernel test robot
build botRe: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
In reply to Jason Xingkernel test robot noticed the following build warnings:
Hi Jason,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jason-Xing/stmmac-xsk-fix-underflow-of-budget-in-zerocopy-mode/20250722-215348 base: net/main patch link: https://lore.kernel.org/r/20250722135057.85386-2-kerneljasonxing%40gmail.com patch subject: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20250723/[email protected]/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250723/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2601:3: warning: misleading indentation; statement is not part of the previous 'for' [-Wmisleading-indentation]
2601 | struct xsk_tx_metadata *meta = NULL;
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2599:2: note: previous statement is here
2599 | for (; budget > 0; budget--)
| ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2600:34: warning: unused variable 'meta_req' [-Wunused-variable]
2600 | struct stmmac_metadata_request meta_req;
| ^~~~~~~~
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2611:4: error: 'break' statement not in loop or switch statement
2611 | break;
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2615:4: error: 'break' statement not in loop or switch statement
2615 | break;
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2621:4: error: 'continue' statement not in loop statement
2621 | continue;
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2660:3: error: use of undeclared identifier 'meta_req'
2660 | meta_req.priv = priv;
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2661:3: error: use of undeclared identifier 'meta_req'
2661 | meta_req.tx_desc = tx_desc;
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2662:3: error: use of undeclared identifier 'meta_req'
2662 | meta_req.set_ic = &set_ic;
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2663:3: error: use of undeclared identifier 'meta_req'
2663 | meta_req.tbs = tx_q->tbs;
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2664:3: error: use of undeclared identifier 'meta_req'
2664 | meta_req.edesc = &tx_q->dma_entx[entry];
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2666:7: error: use of undeclared identifier 'meta_req'; did you mean 'net_eq'?
2666 | &meta_req);
| ^~~~~~~~
| net_eq
include/net/net_namespace.h:292:5: note: 'net_eq' declared here
292 | int net_eq(const struct net *net1, const struct net *net2)
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:25: error: expected parameter declarator
2685 | u64_stats_update_begin(&txq_stats->napi_syncp);
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:25: error: expected ')'
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:24: note: to match this '('
2685 | u64_stats_update_begin(&txq_stats->napi_syncp);
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:2: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
2685 | u64_stats_update_begin(&txq_stats->napi_syncp);
| ^
| int
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:24: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
2685 | u64_stats_update_begin(&txq_stats->napi_syncp);
| ^
| void
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:2: error: a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C23, conflicting with a previous declaration [-Werror,-Wdeprecated-non-prototype]
2685 | u64_stats_update_begin(&txq_stats->napi_syncp);
| ^
include/linux/u64_stats_sync.h:181:20: note: conflicting prototype is here
181 | static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:2: error: conflicting types for 'u64_stats_update_begin'
2685 | u64_stats_update_begin(&txq_stats->napi_syncp);
| ^
include/linux/u64_stats_sync.h:181:20: note: previous definition is here
181 | static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:16: error: expected parameter declarator
2686 | u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:16: error: expected ')'
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:15: note: to match this '('
2686 | u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
| ^
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:2: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
2686 | u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
| ^
| int
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
2686 | u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
| ^
| voidfatal error: too many errors emitted, stopping now [-ferror-limit=] 2 warnings and 20 errors generated.
vim +/for +2601 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
1347b419318d6af Song Yoong Siang 2023-11-27 2581
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2582 static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2583 {
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2584 struct netdev_queue *nq = netdev_get_tx_queue(priv->dev, queue);
8531c80800c10e8 Christian Marangi 2022-07-23 2585 struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
8070274b472e2e9 Jisheng Zhang 2023-09-18 2586 struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue];
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2587 struct xsk_buff_pool *pool = tx_q->xsk_pool;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2588 unsigned int entry = tx_q->cur_tx;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2589 struct dma_desc *tx_desc = NULL;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2590 struct xdp_desc xdp_desc;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2591 bool work_done = true;
133466c3bbe171f Jisheng Zhang 2023-07-18 2592 u32 tx_set_ic_bit = 0;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2593
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2594 /* Avoids TX time-out as we are sharing with slow path */
e92af33e472cf3a Alexander Lobakin 2021-11-17 2595 txq_trans_cond_update(nq);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2596
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2597 budget = min(budget, stmmac_tx_avail(priv, queue));
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2598
9074ec4e205d86d Jason Xing 2025-07-22 2599 for (; budget > 0; budget--)
1347b419318d6af Song Yoong Siang 2023-11-27 @2600 struct stmmac_metadata_request meta_req;
1347b419318d6af Song Yoong Siang 2023-11-27 @2601 struct xsk_tx_metadata *meta = NULL;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2602 dma_addr_t dma_addr;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2603 bool set_ic;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2604
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2605 /* We are sharing with slow path and stop XSK TX desc submission when
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2606 * available TX ring is less than threshold.
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2607 */
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2608 if (unlikely(stmmac_tx_avail(priv, queue) < STMMAC_TX_XSK_AVAIL) ||
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2609 !netif_carrier_ok(priv->dev)) {
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2610 work_done = false;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2611 break;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2612 }
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2613
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2614 if (!xsk_tx_peek_desc(pool, &xdp_desc))
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2615 break;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2616
bd17382ac36ed97 Xiaolei Wang 2024-05-13 2617 if (priv->est && priv->est->enable &&
bd17382ac36ed97 Xiaolei Wang 2024-05-13 2618 priv->est->max_sdu[queue] &&
bd17382ac36ed97 Xiaolei Wang 2024-05-13 2619 xdp_desc.len > priv->est->max_sdu[queue]) {
c5c3e1bfc9e0ee7 Rohan G Thomas 2024-01-27 2620 priv->xstats.max_sdu_txq_drop[queue]++;
c5c3e1bfc9e0ee7 Rohan G Thomas 2024-01-27 2621 continue;
c5c3e1bfc9e0ee7 Rohan G Thomas 2024-01-27 2622 }
c5c3e1bfc9e0ee7 Rohan G Thomas 2024-01-27 2623
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2624 if (likely(priv->extend_desc))
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2625 tx_desc = (struct dma_desc *)(tx_q->dma_etx + entry);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2626 else if (tx_q->tbs & STMMAC_TBS_AVAIL)
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2627 tx_desc = &tx_q->dma_entx[entry].basic;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2628 else
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2629 tx_desc = tx_q->dma_tx + entry;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2630
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2631 dma_addr = xsk_buff_raw_get_dma(pool, xdp_desc.addr);
1347b419318d6af Song Yoong Siang 2023-11-27 2632 meta = xsk_buff_get_metadata(pool, xdp_desc.addr);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2633 xsk_buff_raw_dma_sync_for_device(pool, dma_addr, xdp_desc.len);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2634
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2635 tx_q->tx_skbuff_dma[entry].buf_type = STMMAC_TXBUF_T_XSK_TX;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2636
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2637 /* To return XDP buffer to XSK pool, we simple call
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2638 * xsk_tx_completed(), so we don't need to fill up
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2639 * 'buf' and 'xdpf'.
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2640 */
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2641 tx_q->tx_skbuff_dma[entry].buf = 0;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2642 tx_q->xdpf[entry] = NULL;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2643
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2644 tx_q->tx_skbuff_dma[entry].map_as_page = false;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2645 tx_q->tx_skbuff_dma[entry].len = xdp_desc.len;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2646 tx_q->tx_skbuff_dma[entry].last_segment = true;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2647 tx_q->tx_skbuff_dma[entry].is_jumbo = false;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2648
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2649 stmmac_set_desc_addr(priv, tx_desc, dma_addr);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2650
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2651 tx_q->tx_count_frames++;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2652
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2653 if (!priv->tx_coal_frames[queue])
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2654 set_ic = false;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2655 else if (tx_q->tx_count_frames % priv->tx_coal_frames[queue] == 0)
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2656 set_ic = true;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2657 else
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2658 set_ic = false;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2659
1347b419318d6af Song Yoong Siang 2023-11-27 2660 meta_req.priv = priv;
1347b419318d6af Song Yoong Siang 2023-11-27 2661 meta_req.tx_desc = tx_desc;
1347b419318d6af Song Yoong Siang 2023-11-27 2662 meta_req.set_ic = &set_ic;
04f64dea13640fb Song Yoong Siang 2025-02-16 2663 meta_req.tbs = tx_q->tbs;
04f64dea13640fb Song Yoong Siang 2025-02-16 2664 meta_req.edesc = &tx_q->dma_entx[entry];
1347b419318d6af Song Yoong Siang 2023-11-27 2665 xsk_tx_metadata_request(meta, &stmmac_xsk_tx_metadata_ops,
1347b419318d6af Song Yoong Siang 2023-11-27 2666 &meta_req);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2667 if (set_ic) {
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2668 tx_q->tx_count_frames = 0;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2669 stmmac_set_tx_ic(priv, tx_desc);
133466c3bbe171f Jisheng Zhang 2023-07-18 2670 tx_set_ic_bit++;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2671 }
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2672
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2673 stmmac_prepare_tx_desc(priv, tx_desc, 1, xdp_desc.len,
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2674 true, priv->mode, true, true,
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2675 xdp_desc.len);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2676
ad72f783de06827 Yanteng Si 2024-08-07 2677 stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2678
1347b419318d6af Song Yoong Siang 2023-11-27 2679 xsk_tx_metadata_to_compl(meta,
1347b419318d6af Song Yoong Siang 2023-11-27 2680 &tx_q->tx_skbuff_dma[entry].xsk_meta);
1347b419318d6af Song Yoong Siang 2023-11-27 2681
8531c80800c10e8 Christian Marangi 2022-07-23 2682 tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, priv->dma_conf.dma_tx_size);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2683 entry = tx_q->cur_tx;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2684 }
38cc3c6dcc09dc3 Petr Tesarik 2024-02-03 2685 u64_stats_update_begin(&txq_stats->napi_syncp);
38cc3c6dcc09dc3 Petr Tesarik 2024-02-03 2686 u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
38cc3c6dcc09dc3 Petr Tesarik 2024-02-03 2687 u64_stats_update_end(&txq_stats->napi_syncp);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2688
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2689 if (tx_desc) {
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2690 stmmac_flush_tx_descriptors(priv, queue);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2691 xsk_tx_release(pool);
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2692 }
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2693
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2694 /* Return true if all of the 3 conditions are met
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2695 * a) TX Budget is still available
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2696 * b) work_done = true when XSK TX desc peek is empty (no more
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2697 * pending XSK TX for transmission)
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2698 */
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2699 return !!budget && work_done;
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2700 }
132c32ee5bc09b1 Ong Boon Leong 2021-04-13 2701 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v2 2/2 igb: xsk: solve underflow of nb_pkts in zerocopy mode
In reply to Jason XingFrom: Jason Xing <[email protected]>
There is no break time in the while() loop, so every time at the end of igb_xmit_zc(), underflow of nb_pkts will occur, which renders the return value always false. But theoretically, the result should be set after calling xsk_tx_peek_release_desc_batch(). We can take i40e_xmit_zc() as a good example.
Returning false means we're not done with transmission and we need one more poll, which is exactly what igb_xmit_zc() always did before this patch. After this patch, the return value depends on the nb_pkts value. Two cases might happen then:
1. if (nb_pkts < budget), it means we process all the possible data, so return true and no more necessary poll will be triggered because of this.
2. if (nb_pkts == budget), it means we might have more data, so return false to let another poll run again.
---
v2
1. target net tree instead of net-next
2. use for loop instead
--- drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_xsk.c +1 -2
@@ -482,7 +482,7 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool)if (!nb_pkts)return true; -while (nb_pkts-- >0 ) { +for (; i < nb_pkts; i++) { dma =xsk_buff_raw_get_dma (xsk_pool, descs[i].addr);xsk_buff_raw_dma_sync_for_device (xsk_pool, dma, descs[i].len);
@@ -512,7 +512,6 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool) total_bytes += descs[i].len; - i++; tx_ring->next_to_use++; tx_buffer_info->next_to_watch = tx_desc;if (tx_ring->next_to_use == tx_ring->count)
Signature · 1 line
2.41.3
RE: [Intel-wired-lan] [PATCH net v2 2/2] igb: xsk: solve underflow of nb_pkts in zerocopy mode
Quoted 41 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jason Xing
Sent: Tuesday, July 22, 2025 3:51 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Karlsson, Magnus <[email protected]>; Fijalkowski, Maciej <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Jason Xing <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2 2/2] igb: xsk: solve underflow ofnb_pktsin zerocopy modeFrom: Jason Xing <[email protected]>
There is no break time in the
while()loop, so every time at the end ofigb_xmit_zc(), underflow ofnb_pktswill occur, which renders the return value always false. But theoretically, the result should be set after callingxsk_tx_peek_release_desc_batch(). We can takei40e_xmit_zc()as a good example.Returning false means we're not done with transmission and we need one more poll, which is exactly what
igb_xmit_zc()always did before this patch. After this patch, the return value depends on thenb_pktsvalue.
Two cases might happen then:
1. if (nb_pkts< budget), it means we process all the possible data, so
return true and no more necessary poll will be triggered because of this.
2. if (nb_pkts== budget), it means we might have more data, so return false to let another poll run again.
Quoted 2 lines
Fixes f8e284a02afc ("igb: Add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>
Quoted 37 lines
---
v2[email protected]/
1. target net tree instead of net-next
2. use for loop instead--- drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ethernet/intel/igb/igb_xsk.c +1
-1@@ -482,7 +482,7 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool)if (!nb_pkts)return true; -while (nb_pkts-- >0 ) { +for (; i < nb_pkts; i++) { dma =xsk_buff_raw_get_dma (xsk_pool, descs[i].addr); xsk_buff_raw_dma_sync_for_device(xsk_pool, dma,descs[i].len);
drivers/net/ethernet/intel/igb/igb_xsk.c +0
-1@@ -512,7 +512,6 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool) total_bytes += descs[i].len; - i++; tx_ring->next_to_use++; tx_buffer_info->next_to_watch = tx_desc;if (
tx_ring->next_to_use==tx_ring->count)
--
2.41.3
Quoted 8 lines · Jason Xing
From: Jason Xing <[email protected]>
Fix two underflow issues around {stmmac_xdp|igb}_xmit_zc().
Jason Xing (2):
stmmac: xsk: fix underflow of budget in zerocopy mode
igb: xsk: solve underflow ofnb_pktsin zerocopy mode
Willem has pointed out it's technically not underflow but the negative overflow[1]. So I decided to send a V3 patch with this modified.
[1]: https://lore.kernel.org/all/[email protected]/
Thanks,
Jason