Skip to content

Commit accd7e2

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Avoid order-5 memory allocation for TPA data
The driver needs to keep track of all the possible concurrent TPA (GRO/LRO) completions on the aggregation ring. On P5 chips, the maximum number of concurrent TPA is 256 and the amount of memory we allocate is order-5 on systems using 4K pages. Memory allocation failure has been reported: NetworkManager: page allocation failure: order:5, mode:0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null),cpuset=/,mems_allowed=0-1 CPU: 15 PID: 2995 Comm: NetworkManager Kdump: loaded Not tainted 5.10.156 #1 Hardware name: Dell Inc. PowerEdge R660/0M1CC5, BIOS 0.2.25 08/12/2022 Call Trace: dump_stack+0x57/0x6e warn_alloc.cold.120+0x7b/0xdd ? _cond_resched+0x15/0x30 ? __alloc_pages_direct_compact+0x15f/0x170 __alloc_pages_slowpath.constprop.108+0xc58/0xc70 __alloc_pages_nodemask+0x2d0/0x300 kmalloc_order+0x24/0xe0 kmalloc_order_trace+0x19/0x80 bnxt_alloc_mem+0x1150/0x15c0 [bnxt_en] ? bnxt_get_func_stat_ctxs+0x13/0x60 [bnxt_en] __bnxt_open_nic+0x12e/0x780 [bnxt_en] bnxt_open+0x10b/0x240 [bnxt_en] __dev_open+0xe9/0x180 __dev_change_flags+0x1af/0x220 dev_change_flags+0x21/0x60 do_setlink+0x35c/0x1100 Instead of allocating this big chunk of memory and dividing it up for the concurrent TPA instances, allocate each small chunk separately for each TPA instance. This will reduce it to order-0 allocations. Fixes: 79632e9 ("bnxt_en: Expand bnxt_tpa_info struct to support 57500 chips.") Reviewed-by: Somnath Kotur <[email protected]> Reviewed-by: Damodharam Ammepalli <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f4b47a2 commit accd7e2

File tree

1 file changed

+12
-11
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+12
-11
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,16 +3145,18 @@ static int bnxt_alloc_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem)
31453145

31463146
static void bnxt_free_tpa_info(struct bnxt *bp)
31473147
{
3148-
int i;
3148+
int i, j;
31493149

31503150
for (i = 0; i < bp->rx_nr_rings; i++) {
31513151
struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
31523152

31533153
kfree(rxr->rx_tpa_idx_map);
31543154
rxr->rx_tpa_idx_map = NULL;
31553155
if (rxr->rx_tpa) {
3156-
kfree(rxr->rx_tpa[0].agg_arr);
3157-
rxr->rx_tpa[0].agg_arr = NULL;
3156+
for (j = 0; j < bp->max_tpa; j++) {
3157+
kfree(rxr->rx_tpa[j].agg_arr);
3158+
rxr->rx_tpa[j].agg_arr = NULL;
3159+
}
31583160
}
31593161
kfree(rxr->rx_tpa);
31603162
rxr->rx_tpa = NULL;
@@ -3163,14 +3165,13 @@ static void bnxt_free_tpa_info(struct bnxt *bp)
31633165

31643166
static int bnxt_alloc_tpa_info(struct bnxt *bp)
31653167
{
3166-
int i, j, total_aggs = 0;
3168+
int i, j;
31673169

31683170
bp->max_tpa = MAX_TPA;
31693171
if (bp->flags & BNXT_FLAG_CHIP_P5) {
31703172
if (!bp->max_tpa_v2)
31713173
return 0;
31723174
bp->max_tpa = max_t(u16, bp->max_tpa_v2, MAX_TPA_P5);
3173-
total_aggs = bp->max_tpa * MAX_SKB_FRAGS;
31743175
}
31753176

31763177
for (i = 0; i < bp->rx_nr_rings; i++) {
@@ -3184,12 +3185,12 @@ static int bnxt_alloc_tpa_info(struct bnxt *bp)
31843185

31853186
if (!(bp->flags & BNXT_FLAG_CHIP_P5))
31863187
continue;
3187-
agg = kcalloc(total_aggs, sizeof(*agg), GFP_KERNEL);
3188-
rxr->rx_tpa[0].agg_arr = agg;
3189-
if (!agg)
3190-
return -ENOMEM;
3191-
for (j = 1; j < bp->max_tpa; j++)
3192-
rxr->rx_tpa[j].agg_arr = agg + j * MAX_SKB_FRAGS;
3188+
for (j = 0; j < bp->max_tpa; j++) {
3189+
agg = kcalloc(MAX_SKB_FRAGS, sizeof(*agg), GFP_KERNEL);
3190+
if (!agg)
3191+
return -ENOMEM;
3192+
rxr->rx_tpa[j].agg_arr = agg;
3193+
}
31933194
rxr->rx_tpa_idx_map = kzalloc(sizeof(*rxr->rx_tpa_idx_map),
31943195
GFP_KERNEL);
31953196
if (!rxr->rx_tpa_idx_map)

0 commit comments

Comments
 (0)