Patchwork dev_alloc_skb: avoid using GFP_ATOMIC

login
register
mail settings
Submitter swalter@lexmark.com
Date Sept. 29, 2009, 4:43 p.m.
Message ID <1254242593-2279-1-git-send-email-swalter@lexmark.com>
Download mbox | patch
Permalink /patch/34442/
State Rejected
Delegated to: David Miller
Headers show

Comments

swalter@lexmark.com - Sept. 29, 2009, 4:43 p.m.
From: swalter <swalter@swalter-d630.(none)>


Signed-off-by: Steven Walter <swalter@lpdev.prtdev.lexmark.com>
---
 net/core/skbuff.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
stephen hemminger - Sept. 29, 2009, 4:58 p.m.
On Tue, 29 Sep 2009 12:43:13 -0400
swalter@lexmark.com wrote:

> From: swalter <swalter@swalter-d630.(none)>
> 
> 
> Signed-off-by: Steven Walter <swalter@lpdev.prtdev.lexmark.com>
> ---
>  net/core/skbuff.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 9e0597d..58ec625 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -306,7 +306,11 @@ struct sk_buff *dev_alloc_skb(unsigned int length)
>  	 * There is more code here than it seems:
>  	 * __dev_alloc_skb is an inline
>  	 */
> -	return __dev_alloc_skb(length, GFP_ATOMIC);
> +	if (in_interrupt()  ||  in_atomic()  ||  irqs_disabled()) {
> +		return __dev_alloc_skb(length, GFP_ATOMIC);
> +	} else {
> +		return __dev_alloc_skb(length, GFP_KERNEL);
> +	}
>  }
>  EXPORT_SYMBOL(dev_alloc_skb);
>  

No, this should be fixed by caller (using netdev_alloc_skb)
also, it may break cases like swap over NFS that want to get memory
when memory pool is low

Patch

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 9e0597d..58ec625 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -306,7 +306,11 @@  struct sk_buff *dev_alloc_skb(unsigned int length)
 	 * There is more code here than it seems:
 	 * __dev_alloc_skb is an inline
 	 */
-	return __dev_alloc_skb(length, GFP_ATOMIC);
+	if (in_interrupt()  ||  in_atomic()  ||  irqs_disabled()) {
+		return __dev_alloc_skb(length, GFP_ATOMIC);
+	} else {
+		return __dev_alloc_skb(length, GFP_KERNEL);
+	}
 }
 EXPORT_SYMBOL(dev_alloc_skb);