From mboxrd@z Thu Jan 1 00:00:00 1970 From: Edward Cree Subject: [RFC PATCH v2 net-next 09/12] net: don't bother calling list RX functions on empty lists Date: Tue, 26 Jun 2018 19:21:00 +0100 Message-ID: <00c765d3-e893-daa0-e5bb-790b1b790f29@solarflare.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: To: , Return-path: Received: from dispatch1-us1.ppe-hosted.com ([67.231.154.164]:39970 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751803AbeFZSVG (ORCPT ); Tue, 26 Jun 2018 14:21:06 -0400 In-Reply-To: Content-Language: en-GB Sender: netdev-owner@vger.kernel.org List-ID: Generally the check should be very cheap, as the sk_buff_head is in cache. Signed-off-by: Edward Cree --- 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);