net: suppress warnings on dev_alloc_skb
Subsystems (2)
PATCH 1/1 net: suppress warnings on dev_alloc_skb
Noticed an allocation failure in a network driver the other day on a 32 bit system:
DMA-API: debugging out of memory - disabling
bnx2fc: adapter_lookup: hba NULL
lldpad: page allocation failure. order:0, mode:0x4120
Pid: 4556, comm: lldpad Not tainted 2.6.32-639.el6.i686.debug #1
Call Trace: [<c08a4086>] ? printk+0x19/0x23 [<c05166a4>] ? __alloc_pages_nodemask+0x664/0x830 [<c0649d02>] ? free_object+0x82/0xa0 [<fb4e2c9b>] ? ixgbe_alloc_rx_buffers+0x10b/0x1d0 [ixgbe] [<fb4e2fff>] ? ixgbe_configure_rx_ring+0x29f/0x420 [ixgbe] [<fb4e228c>] ? ixgbe_configure_tx_ring+0x15c/0x220 [ixgbe] [<fb4e3709>] ? ixgbe_configure+0x589/0xc00 [ixgbe] [<fb4e7be7>] ? ixgbe_open+0xa7/0x5c0 [ixgbe] [<fb503ce6>] ? ixgbe_init_interrupt_scheme+0x5b6/0x970 [ixgbe] [<fb4e8e54>] ? ixgbe_setup_tc+0x1a4/0x260 [ixgbe] [<fb505a9f>] ? ixgbe_dcbnl_set_state+0x7f/0x90 [ixgbe] [<c088d80d>] ? dcb_doit+0x10ed/0x16d0
...
Thought that perhaps the big splat in the logs wasn't really necessecary, as all call sites for dev_alloc_skb:
a) check the return code for the function
and
b) either print their own error message or have a recovery path that makes the warning moot.
So, I added __GFP_NOWARN to the gfp_flags, to be added unless DEBUG was enabled, in which case getting the splat makes a bit more sense
applies to the net tree
--- include/linux/skbuff.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/skbuff.h +4 -0
@@ -2452,6 +2452,10 @@ static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,*/ gfp_mask |= __GFP_COLD | __GFP_COMP | __GFP_MEMALLOC; +#ifndef DEBUG + gfp_mask |= __GFP_NOWARN; +#endif +return alloc_pages_node (NUMA_NO_NODE , gfp_mask, order); }
Signature · 1 line
2.5.5
Quoted 20 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
DMA-API: debugging out of memory - disabling
bnx2fc:adapter_lookup: hba NULL
lldpad: page allocation failure. order:0, mode:0x4120
Pid: 4556, comm: lldpad Not tainted 2.6.32-639.el6.i686.debug #1Call Trace: [<c08a4086>] ? printk+0x19/0x23 [<c05166a4>] ? __alloc_pages_nodemask+0x664/0x830 [<c0649d02>] ? free_object+0x82/0xa0 [<fb4e2c9b>] ? ixgbe_alloc_rx_buffers+0x10b/0x1d0 [ixgbe] [<fb4e2fff>] ? ixgbe_configure_rx_ring+0x29f/0x420 [ixgbe] [<fb4e228c>] ? ixgbe_configure_tx_ring+0x15c/0x220 [ixgbe] [<fb4e3709>] ? ixgbe_configure+0x589/0xc00 [ixgbe] [<fb4e7be7>] ? ixgbe_open+0xa7/0x5c0 [ixgbe] [<fb503ce6>] ? ixgbe_init_interrupt_scheme+0x5b6/0x970 [ixgbe] [<fb4e8e54>] ? ixgbe_setup_tc+0x1a4/0x260 [ixgbe] [<fb505a9f>] ? ixgbe_dcbnl_set_state+0x7f/0x90 [ixgbe] [<c088d80d>] ? dcb_doit+0x10ed/0x16d0
Quoted 1 line
...
Well, maybe this call site (via ixgbe_configure_rx_ring()) should be using GFP_KERNEL instead of GFP_ATOMIC.
Otherwise, if you are unlucky, not a single page would be allocated and RX ring buffer would be empty.
So the 'fix' could be limited to GFP_ATOMIC callers ?
include/linux/skbuff.h +2 -2
@@ -2467,7 +2467,7 @@ static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,static inline struct page *dev_alloc_pages (unsigned int order) { -return __dev_alloc_pages (GFP_ATOMIC , order); +return __dev_alloc_pages (GFP_ATOMIC | __GFP_NOWARN, order); }/**
@@ -2485,7 +2485,7 @@ static inline struct page *__dev_alloc_page(gfp_t gfp_mask)static inline struct page *dev_alloc_page (void ) { -return __dev_alloc_page (GFP_ATOMIC ); +return dev_alloc_pages (0 ); }/**
Quoted 24 lines · Eric Dumazet
Quoted 20 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
DMA-API: debugging out of memory - disabling
bnx2fc:adapter_lookup: hba NULL
lldpad: page allocation failure. order:0, mode:0x4120
Pid: 4556, comm: lldpad Not tainted 2.6.32-639.el6.i686.debug #1Call Trace: [<c08a4086>] ? printk+0x19/0x23 [<c05166a4>] ? __alloc_pages_nodemask+0x664/0x830 [<c0649d02>] ? free_object+0x82/0xa0 [<fb4e2c9b>] ? ixgbe_alloc_rx_buffers+0x10b/0x1d0 [ixgbe] [<fb4e2fff>] ? ixgbe_configure_rx_ring+0x29f/0x420 [ixgbe] [<fb4e228c>] ? ixgbe_configure_tx_ring+0x15c/0x220 [ixgbe] [<fb4e3709>] ? ixgbe_configure+0x589/0xc00 [ixgbe] [<fb4e7be7>] ? ixgbe_open+0xa7/0x5c0 [ixgbe] [<fb503ce6>] ? ixgbe_init_interrupt_scheme+0x5b6/0x970 [ixgbe] [<fb4e8e54>] ? ixgbe_setup_tc+0x1a4/0x260 [ixgbe] [<fb505a9f>] ? ixgbe_dcbnl_set_state+0x7f/0x90 [ixgbe] [<c088d80d>] ? dcb_doit+0x10ed/0x16d0Quoted 1 line
...
Quoted 2 lines
Well, maybe this call site (via
ixgbe_configure_rx_ring()) should be usingGFP_KERNELinstead ofGFP_ATOMIC.
The problem is the ixgbe driver is using the same function for allocating memory in the softirq and in the init. As such it has to default to GFP_ATOMIC so that it doesn't screw up the NAPI allocation case.
Quoted 21 lines
Otherwise, if you are unlucky, not a single page would be allocated and RX ring buffer would be empty.
So the 'fix' could be limited to
GFP_ATOMICcallers ?include/linux/skbuff.h +1
-1@@ -2467,7 +2467,7 @@ static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,static inline struct page *dev_alloc_pages (unsigned int order) { -return __dev_alloc_pages (GFP_ATOMIC , order); +return __dev_alloc_pages (GFP_ATOMIC | __GFP_NOWARN, order); }/**
include/linux/skbuff.h static inline struct page *__dev_alloc_page(gfp_t gfp_mask) · line 2491
Quoted 8 lines
include/linux/skbuff.h +1
-1@@ -2485,7 +2485,7 @@ static inline struct page *__dev_alloc_page(gfp_t gfp_mask)static inline struct page *dev_alloc_page (void ) { -return __dev_alloc_page (GFP_ATOMIC ); +return dev_alloc_pages (0 ); }/**
I agree. This is likely a much better way to go.
- Alex
Quoted 25 lines · Alexander Duyck
Quoted 24 lines · Eric Dumazet
Quoted 21 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
DMA-API: debugging out of memory - disabling
bnx2fc:adapter_lookup: hba NULL
lldpad: page allocation failure. order:0, mode:0x4120
Pid: 4556, comm: lldpad Not tainted 2.6.32-639.el6.i686.debug #1Call Trace: [<c08a4086>] ? printk+0x19/0x23 [<c05166a4>] ? __alloc_pages_nodemask+0x664/0x830 [<c0649d02>] ? free_object+0x82/0xa0 [<fb4e2c9b>] ? ixgbe_alloc_rx_buffers+0x10b/0x1d0 [ixgbe] [<fb4e2fff>] ? ixgbe_configure_rx_ring+0x29f/0x420 [ixgbe] [<fb4e228c>] ? ixgbe_configure_tx_ring+0x15c/0x220 [ixgbe] [<fb4e3709>] ? ixgbe_configure+0x589/0xc00 [ixgbe] [<fb4e7be7>] ? ixgbe_open+0xa7/0x5c0 [ixgbe] [<fb503ce6>] ? ixgbe_init_interrupt_scheme+0x5b6/0x970 [ixgbe] [<fb4e8e54>] ? ixgbe_setup_tc+0x1a4/0x260 [ixgbe] [<fb505a9f>] ? ixgbe_dcbnl_set_state+0x7f/0x90 [ixgbe] [<c088d80d>] ? dcb_doit+0x10ed/0x16d0...
Quoted 8 lines
Quoted 2 lines
Well, maybe this call site (via
ixgbe_configure_rx_ring()) should be usingGFP_KERNELinstead ofGFP_ATOMIC.The problem is the ixgbe driver is using the same function for allocating memory in the softirq and in the init. As such it has to default to
GFP_ATOMICso that it doesn't screw up the NAPI allocation case.
I suppose a happy medium would be to extend dev_alloc_pages to accept a gfp argument, and then have the function itself only set __GFP_NOWARN, if ATOMIC is also set?
Neil
Quoted 35 lines · Neil Horman
Quoted 25 lines · Alexander Duyck
Quoted 24 lines · Eric Dumazet
Quoted 21 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
DMA-API: debugging out of memory - disabling
bnx2fc:adapter_lookup: hba NULL
lldpad: page allocation failure. order:0, mode:0x4120
Pid: 4556, comm: lldpad Not tainted 2.6.32-639.el6.i686.debug #1Call Trace: [<c08a4086>] ? printk+0x19/0x23 [<c05166a4>] ? __alloc_pages_nodemask+0x664/0x830 [<c0649d02>] ? free_object+0x82/0xa0 [<fb4e2c9b>] ? ixgbe_alloc_rx_buffers+0x10b/0x1d0 [ixgbe] [<fb4e2fff>] ? ixgbe_configure_rx_ring+0x29f/0x420 [ixgbe] [<fb4e228c>] ? ixgbe_configure_tx_ring+0x15c/0x220 [ixgbe] [<fb4e3709>] ? ixgbe_configure+0x589/0xc00 [ixgbe] [<fb4e7be7>] ? ixgbe_open+0xa7/0x5c0 [ixgbe] [<fb503ce6>] ? ixgbe_init_interrupt_scheme+0x5b6/0x970 [ixgbe] [<fb4e8e54>] ? ixgbe_setup_tc+0x1a4/0x260 [ixgbe] [<fb505a9f>] ? ixgbe_dcbnl_set_state+0x7f/0x90 [ixgbe] [<c088d80d>] ? dcb_doit+0x10ed/0x16d0...
Quoted 8 lines
Quoted 2 lines
Well, maybe this call site (via
ixgbe_configure_rx_ring()) should be usingGFP_KERNELinstead ofGFP_ATOMIC.The problem is the ixgbe driver is using the same function for allocating memory in the softirq and in the init. As such it has to default to
GFP_ATOMICso that it doesn't screw up the NAPI allocation case.
Quoted 3 lines
I suppose a happy medium would be to extend
dev_alloc_pagesto accept a gfp argument, and then have the function itself only set__GFP_NOWARN, if ATOMIC is also set?
Why bother? I really think Eric's patch is the way to go.
We can already pass gfp flags to __dev_alloc_pages so if we need to pass flags we can use that. Otherwise for the users of dev_alloc_page and dev_alloc_pages we can just pass GFP_ATOMIC | __GFP_NOWARN like Eric did in his example patch.
- Alex
Quoted 40 lines · Alexander Duyck
Quoted 35 lines · Neil Horman
Quoted 25 lines · Alexander Duyck
Quoted 24 lines · Eric Dumazet
Quoted 21 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
DMA-API: debugging out of memory - disabling
bnx2fc:adapter_lookup: hba NULL
lldpad: page allocation failure. order:0, mode:0x4120
Pid: 4556, comm: lldpad Not tainted 2.6.32-639.el6.i686.debug #1Call Trace: [<c08a4086>] ? printk+0x19/0x23 [<c05166a4>] ? __alloc_pages_nodemask+0x664/0x830 [<c0649d02>] ? free_object+0x82/0xa0 [<fb4e2c9b>] ? ixgbe_alloc_rx_buffers+0x10b/0x1d0 [ixgbe] [<fb4e2fff>] ? ixgbe_configure_rx_ring+0x29f/0x420 [ixgbe] [<fb4e228c>] ? ixgbe_configure_tx_ring+0x15c/0x220 [ixgbe] [<fb4e3709>] ? ixgbe_configure+0x589/0xc00 [ixgbe] [<fb4e7be7>] ? ixgbe_open+0xa7/0x5c0 [ixgbe] [<fb503ce6>] ? ixgbe_init_interrupt_scheme+0x5b6/0x970 [ixgbe] [<fb4e8e54>] ? ixgbe_setup_tc+0x1a4/0x260 [ixgbe] [<fb505a9f>] ? ixgbe_dcbnl_set_state+0x7f/0x90 [ixgbe] [<c088d80d>] ? dcb_doit+0x10ed/0x16d0...
Quoted 8 lines
Quoted 2 lines
Well, maybe this call site (via
ixgbe_configure_rx_ring()) should be usingGFP_KERNELinstead ofGFP_ATOMIC.The problem is the ixgbe driver is using the same function for allocating memory in the softirq and in the init. As such it has to default to
GFP_ATOMICso that it doesn't screw up the NAPI allocation case.Quoted 3 lines
I suppose a happy medium would be to extend
dev_alloc_pagesto accept a gfp argument, and then have the function itself only set__GFP_NOWARN, if ATOMIC is also set?
Quoted 9 lines
Why bother? I really think Eric's patch is the way to go.
We can already pass gfp flags to
__dev_alloc_pagesso if we need to pass flags we can use that. Otherwise for the users ofdev_alloc_pageanddev_alloc_pageswe can just passGFP_ATOMIC|__GFP_NOWARNlike Eric did in his example patch.- Alex
Oh, my bad, I misread what he was saying. Yeah, thats the way to go.
Neil
Quoted 1 line · Neil Horman
Oh, my bad, I misread what he was saying. Yeah, thats the way to go.
Please submit a v2 ;)
Thanks
Quoted 8 lines · Eric Dumazet
Quoted 1 line · Neil Horman
Oh, my bad, I misread what he was saying. Yeah, thats the way to go.
Please submit a v2 ;)
Thanks
Will do shortly :)
Neil
Quoted 3 lines
PATCH v2 1/1 net: suppress warnings on dev_alloc_skb
In reply to Neil HormanNoticed an allocation failure in a network driver the other day on a 32 bit system:
DMA-API: debugging out of memory - disabling
bnx2fc: adapter_lookup: hba NULL
lldpad: page allocation failure. order:0, mode:0x4120
Pid: 4556, comm: lldpad Not tainted 2.6.32-639.el6.i686.debug #1
Call Trace: [<c08a4086>] ? printk+0x19/0x23 [<c05166a4>] ? __alloc_pages_nodemask+0x664/0x830 [<c0649d02>] ? free_object+0x82/0xa0 [<fb4e2c9b>] ? ixgbe_alloc_rx_buffers+0x10b/0x1d0 [ixgbe] [<fb4e2fff>] ? ixgbe_configure_rx_ring+0x29f/0x420 [ixgbe] [<fb4e228c>] ? ixgbe_configure_tx_ring+0x15c/0x220 [ixgbe] [<fb4e3709>] ? ixgbe_configure+0x589/0xc00 [ixgbe] [<fb4e7be7>] ? ixgbe_open+0xa7/0x5c0 [ixgbe] [<fb503ce6>] ? ixgbe_init_interrupt_scheme+0x5b6/0x970 [ixgbe] [<fb4e8e54>] ? ixgbe_setup_tc+0x1a4/0x260 [ixgbe] [<fb505a9f>] ? ixgbe_dcbnl_set_state+0x7f/0x90 [ixgbe] [<c088d80d>] ? dcb_doit+0x10ed/0x16d0
...
Thought that perhaps the big splat in the logs wasn't really necessecary, as all call sites for dev_alloc_skb:
a) check the return code for the function
and
b) either print their own error message or have a recovery path that makes the warning moot.
Fix it by modifying dev_alloc_pages to pass __GFP_NOWARN as a gfp flag to suppress the warning
applies to the net tree
---
Change notes
v2) Modified patch to only apply to dev_alloc_pages, so that callers have the option to get the warning by using the non-wrapped __dev_alloc_pages as per suggestion from Eric D.
--- include/linux/skbuff.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/skbuff.h +2 -2
@@ -2457,7 +2457,7 @@ static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,static inline struct page *dev_alloc_pages (unsigned int order) { -return __dev_alloc_pages (GFP_ATOMIC , order); +return __dev_alloc_pages (GFP_ATOMIC | __GFP_NOWARN, order); }/**
@@ -2475,7 +2475,7 @@ static inline struct page *__dev_alloc_page(gfp_t gfp_mask)static inline struct page *dev_alloc_page (void ) { -return __dev_alloc_page (GFP_ATOMIC ); +return dev_alloc_pages (0 ); }/**
Signature · 1 line
2.5.5
Quoted 7 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
Signed-off-by Neil Horman <[email protected]>CC "David S. Miller" <[email protected]>CC Eric Dumazet <[email protected]>CC Alexander Duyck <[email protected]>
Thanks Neil
Quoted 2 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
Presumably driver could fall back to HIGH memory allocation for the page frag.
Quoted 7 lines · Eric Dumazet
Quoted 2 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
Presumably driver could fall back to HIGH memory allocation for the page frag.
Is that safe on a 32 bit system?
Neil
Quoted 3 lines
Quoted 10 lines · Neil Horman
Quoted 7 lines · Eric Dumazet
Quoted 2 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
Presumably driver could fall back to HIGH memory allocation for the page frag.
Is that safe on a 32 bit system?
Neil
This should be.
Unless a bug somewhere was added, since most dev are using 64bit kernels these days.
All frag consumers use the appropriate kmap_atomic()/kunmap_atomic() pairs before copying data from a page frag. Meaning the page can be in HIGH memory.
Quoted 12 lines · Eric Dumazet
Quoted 10 lines · Neil Horman
Quoted 7 lines · Eric Dumazet
Quoted 2 lines · Neil Horman
Noticed an allocation failure in a network driver the other day on a 32 bit system:
Presumably driver could fall back to HIGH memory allocation for the page frag.
Is that safe on a 32 bit system?
Neil
Quoted 9 lines
This should be.
Unless a bug somewhere was added, since most dev are using 64bit kernels these days.
All frag consumers use the appropriate kmap_atomic()/kunmap_atomic() pairs before copying data from a page frag. Meaning the page can be in HIGH memory.
Ok, understood, I'll look into a fallback option soon Neil
Quoted 6 lines
From: Neil Horman <[email protected]>
Date: Thu, 19 May 2016 11:30:54 -0400
Quoted 2 lines
Noticed an allocation failure in a network driver the other day on a 32 bit system:
...
Quoted 10 lines
Thought that perhaps the big splat in the logs wasn't really necessecary, as all call sites for
dev_alloc_skb:a) check the return code for the function
and
b) either print their own error message or have a recovery path that makes the warning moot.
Quoted 6 lines
Fix it by modifying
dev_alloc_pagesto pass__GFP_NOWARNas a gfp flag to suppress the warningapplies to the net tree
Signed-off-by Neil Horman <[email protected]>
Applied, thanks Neil.