From: Eric Dumazet <eric.dumazet@gmail.com>
To: Tom Herbert <therbert@google.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH] Fix locking in flush_backlog
Date: Tue, 23 Mar 2010 07:29:17 +0100 [thread overview]
Message-ID: <1269325757.3043.11.camel@edumazet-laptop> (raw)
In-Reply-To: <alpine.DEB.1.00.1003222257470.3718@pokey.mtv.corp.google.com>
Le lundi 22 mars 2010 à 23:04 -0700, Tom Herbert a écrit :
> Need to take spinlocks when dequeuing from input_pkt_queue in
> flush_backlog. Also, with the spinlock the backlog queues can
> be flushed directly from netdev_run_todo.
>
> Signed-off-by: Tom Herbert <therbert@google.com>
> ---
> diff --git a/net/core/dev.c b/net/core/dev.c
> index a03aab4..e7db656 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -2765,20 +2765,6 @@ int netif_receive_skb(struct sk_buff *skb)
> }
> EXPORT_SYMBOL(netif_receive_skb);
>
> -/* Network device is going away, flush any packets still pending */
> -static void flush_backlog(void *arg)
> -{
> - struct net_device *dev = arg;
> - struct softnet_data *queue = &__get_cpu_var(softnet_data);
> - struct sk_buff *skb, *tmp;
> -
> - skb_queue_walk_safe(&queue->input_pkt_queue, skb, tmp)
> - if (skb->dev == dev) {
> - __skb_unlink(skb, &queue->input_pkt_queue);
> - kfree_skb(skb);
> - }
> -}
> -
> static int napi_gro_complete(struct sk_buff *skb)
> {
> struct packet_type *ptype;
> @@ -5545,6 +5531,7 @@ void netdev_run_todo(void)
> while (!list_empty(&list)) {
> struct net_device *dev
> = list_first_entry(&list, struct net_device, todo_list);
> + int i;
> list_del(&dev->todo_list);
>
> if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
> @@ -5556,7 +5543,22 @@ void netdev_run_todo(void)
>
> dev->reg_state = NETREG_UNREGISTERED;
>
> - on_each_cpu(flush_backlog, dev, 1);
> + /* Flush backlog queues of any pending packets */
> + for_each_online_cpu(i) {
> + struct softnet_data *queue = &per_cpu(softnet_data, i);
> + struct sk_buff *skb, *tmp;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&queue->input_pkt_queue.lock, flags);
> + skb_queue_walk_safe(&queue->input_pkt_queue, skb, tmp)
> + if (skb->dev == dev) {
> + __skb_unlink(skb,
> + &queue->input_pkt_queue);
> + kfree_skb(skb);
> + }
> + spin_unlock_irqrestore(&queue->input_pkt_queue.lock,
> + flags);
> + }
>
> netdev_wait_allrefs(dev);
>
OK (this is a patch for net-next-2.6)
Could you please keep the function, to ease netdev_run_todo() review ?
Thanks
next prev parent reply other threads:[~2010-03-23 6:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-23 6:04 [PATCH] Fix locking in flush_backlog Tom Herbert
2010-03-23 6:29 ` Eric Dumazet [this message]
2010-03-23 15:56 ` Tom Herbert
2010-03-23 16:14 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1269325757.3043.11.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=therbert@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox