Thread (21 messages) read the whole thread 21 messages, 5 authors, 2018-06-27
STALE2957d

[RFC PATCH v2 net-next 09/12] net: don't bother calling list RX functions on empty lists

From: Edward Cree <hidden>
Date: 2018-06-26 18:21:06
Subsystem: networking [general], networking [ipv4/ipv6], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern, Ido Schimmel, Linus Torvalds

Generally the check should be very cheap, as the sk_buff_head is in cache.

Signed-off-by: Edward Cree <redacted>
---
 net/core/dev.c      | 8 ++++++--
 net/ipv4/ip_input.c | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index f0eb00e9fb57..11f80d4502b9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4780,7 +4780,8 @@ static void __netif_receive_skb_list(struct sk_buff_head *list)
 	while ((skb = __skb_dequeue(list)) != NULL) {
 		if ((sk_memalloc_socks() && skb_pfmemalloc(skb)) != pfmemalloc) {
 			/* Handle the previous sublist */
-			__netif_receive_skb_list_core(&sublist, pfmemalloc);
+			if (!skb_queue_empty(&sublist))
+				__netif_receive_skb_list_core(&sublist, pfmemalloc);
 			pfmemalloc = !pfmemalloc;
 			/* See comments in __netif_receive_skb */
 			if (pfmemalloc)
@@ -4792,7 +4793,8 @@ static void __netif_receive_skb_list(struct sk_buff_head *list)
 		__skb_queue_tail(&sublist, skb);
 	}
 	/* Handle the last sublist */
-	__netif_receive_skb_list_core(&sublist, pfmemalloc);
+	if (!skb_queue_empty(&sublist))
+		__netif_receive_skb_list_core(&sublist, pfmemalloc);
 	/* Restore pflags */
 	if (pfmemalloc)
 		memalloc_noreclaim_restore(noreclaim_flag);
@@ -4968,6 +4970,8 @@ void netif_receive_skb_list(struct sk_buff_head *list)
 {
 	struct sk_buff *skb;
 
+	if (skb_queue_empty(list))
+		return;
 	skb_queue_for_each(skb, list)
 		trace_netif_receive_skb_list_entry(skb);
 	netif_receive_skb_list_internal(list);
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 63d4dfdb1766..65a5ed9e4b3c 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -570,6 +570,8 @@ static void ip_sublist_rcv(struct sk_buff_head *list, struct net_device *dev,
 {
 	struct sk_buff_head sublist;
 
+	if (skb_queue_empty(list))
+		return;
 	NF_HOOK_LIST(NFPROTO_IPV4, NF_INET_PRE_ROUTING, net, NULL,
 		     list, &sublist, dev, NULL, ip_rcv_finish);
 	ip_list_rcv_finish(net, NULL, &sublist);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help