[Devel] [PATCH RHEL8 COMMIT] drivers/bnx2x: Limit setting of the max mtu

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 16 17:47:08 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.14
------>
commit 45850af69e311663b9edd639782e5749245b5099
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Fri Apr 16 17:47:08 2021 +0300

    drivers/bnx2x: Limit setting of the max mtu
    
    Limit max mtu so that rx_buf_size fits into single page.
    This must save us from allocation failures like this:
    
    kswapd0: page allocation failure: order:2, mode:0x4020
    Call Trace:
        dump_stack+0x19/0x1b
        warn_alloc_failed+0x110/0x180
        __alloc_pages_nodemask+0x7bf/0xc60
        alloc_pages_current+0x98/0x110
        kmalloc_order+0x18/0x40
        kmalloc_order_trace+0x26/0xa0
        __kmalloc+0x279/0x290
        bnx2x_frag_alloc.isra.61+0x2a/0x40 [bnx2x]
        bnx2x_rx_int+0x227/0x17c0 [bnx2x]
        bnx2x_poll+0x1dd/0x260 [bnx2x]
        net_rx_action+0x179/0x390
        __do_softirq+0x10f/0x2aa
        call_softirq+0x1c/0x30
        do_softirq+0x65/0xa0
        irq_exit+0x105/0x110
        do_IRQ+0x56/0xe0
        common_interrupt+0x6d/0x6d
    
    https://jira.sw.ru/browse/PSBM-77016
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
    
    (cherry picked from vz7 commit b28ad48b1942 ("drivers/bnx2x: Limit setting of
    the max mtu"))
    
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index cfda368d14d4..2b91e9c6a1af 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -4882,6 +4882,14 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu)
 		return -EAGAIN;
 	}
 
+	if (SKB_DATA_ALIGN(new_mtu + BNX2X_FW_RX_ALIGN_START +
+			IP_HEADER_ALIGNMENT_PADDING + ETH_OVERHEAD +
+			BNX2X_FW_RX_ALIGN_END) + NET_SKB_PAD > PAGE_SIZE) {
+		new_mtu = PAGE_SIZE - NET_SKB_PAD - BNX2X_FW_RX_ALIGN_END -
+			ETH_OVERHEAD - IP_HEADER_ALIGNMENT_PADDING -
+			BNX2X_FW_RX_ALIGN_START;
+	}
+
 	/* This does not race with packet allocation
 	 * because the actual alloc size is
 	 * only updated as part of load


More information about the Devel mailing list