From mboxrd@z Thu Jan 1 00:00:00 1970 From: Edward Cree Subject: [RFC PATCH v2 net-next 03/12] net: core: unwrap skb list receive slightly further Date: Tue, 26 Jun 2018 19:18:15 +0100 Message-ID: <3a61c96c-13fc-f342-71bb-9d9aadeb4ed8@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]:57748 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752645AbeFZSSe (ORCPT ); Tue, 26 Jun 2018 14:18:34 -0400 In-Reply-To: Content-Language: en-GB Sender: netdev-owner@vger.kernel.org List-ID: Adds iterator skb_queue_for_each() to run over a list without modifying it. Signed-off-by: Edward Cree --- include/linux/skbuff.h | 16 ++++++++++++++++ include/trace/events/net.h | 7 +++++++ net/core/dev.c | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index c86885954994..a8c16c6700f3 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1626,6 +1626,22 @@ static inline struct sk_buff *skb_peek_tail(const struct sk_buff_head *list_) } /** + * skb_queue_for_each - iterate over an skb queue + * @pos: the &struct sk_buff to use as a loop cursor. + * @head: the &struct sk_buff_head for your list. + * + * The reference count is not incremented and the reference is therefore + * volatile; the list lock is not taken either. Use with caution. + * + * The list must not be modified (though the individual skbs can be) + * within the loop body. + * + * After loop completion, @pos will be %NULL. + */ +#define skb_queue_for_each(pos, head) \ + for (pos = skb_peek(head); pos != NULL; pos = skb_peek_next(pos, head)) + +/** * skb_queue_len - get queue length * @list_: list to measure * diff --git a/include/trace/events/net.h b/include/trace/events/net.h index 9c886739246a..00aa72ce0e7c 100644 --- a/include/trace/events/net.h +++ b/include/trace/events/net.h @@ -223,6 +223,13 @@ DEFINE_EVENT(net_dev_rx_verbose_template, netif_receive_skb_entry, TP_ARGS(skb) ); +DEFINE_EVENT(net_dev_rx_verbose_template, netif_receive_skb_list_entry, + + TP_PROTO(const struct sk_buff *skb), + + TP_ARGS(skb) +); + DEFINE_EVENT(net_dev_rx_verbose_template, netif_rx_entry, TP_PROTO(const struct sk_buff *skb), diff --git a/net/core/dev.c b/net/core/dev.c index 473e24e31e38..0ab16941a651 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4807,8 +4807,10 @@ void netif_receive_skb_list(struct sk_buff_head *list) { struct sk_buff *skb; + skb_queue_for_each(skb, list) + trace_netif_receive_skb_list_entry(skb); while ((skb = __skb_dequeue(list)) != NULL) - netif_receive_skb(skb); + netif_receive_skb_internal(skb); } EXPORT_SYMBOL(netif_receive_skb_list);