Skip to contentSkip to conversation

dev_alloc_skb: avoid using GFP_ATOMIC

PATCH In review [email protected] 2 participants 2 messages Sep 29, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dev_alloc_skb: avoid using GFP_ATOMIC

From: swalter <swalter@swalter-d630.(none)>

---
 net/core/skbuff.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
net/core/skbuff.c +5 -1
index 9e0597d..58ec625 100644
@@ -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);
 
Signature · 1 line
1.6.2.3.g5bbe6
#1 lore raw
Quoted 15 lines · On Tue, 29 Sep 2009 12:43:13 -0400 [email protected] wrote:

From: swalter <swalter@swalter-d630.(none)>

---
 net/core/skbuff.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
net/core/skbuff.c +0 -0
index 9e0597d..58ec625 100644
@@ -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

net/core/skbuff.c struct sk_buff *dev_alloc_skb(unsigned int length) · line 316

Quoted 10 lines
net/core/skbuff.c +5 -1
 	 */
-	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