* [PATCH v2] Fix locking in flush_backlog
@ 2010-03-23 23:39 Tom Herbert
2010-03-24 5:34 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Tom Herbert @ 2010-03-23 23:39 UTC (permalink / raw)
To: davem, netdev
Need to take spinlocks when dequeuing from input_pkt_queue in flush_backlog.
Also, flush_backlog can now be called 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
diff --git a/net/core/dev.c b/net/core/dev.c
index a03aab4..5e3dc28 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2766,17 +2766,19 @@ 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)
+static void flush_backlog(struct net_device *dev, int cpu)
{
- struct net_device *dev = arg;
- struct softnet_data *queue = &__get_cpu_var(softnet_data);
+ struct softnet_data *queue = &per_cpu(softnet_data, cpu);
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);
}
static int napi_gro_complete(struct sk_buff *skb)
@@ -5545,6 +5547,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 +5559,8 @@ void netdev_run_todo(void)
dev->reg_state = NETREG_UNREGISTERED;
- on_each_cpu(flush_backlog, dev, 1);
+ for_each_online_cpu(i)
+ flush_backlog(dev, i);
netdev_wait_allrefs(dev);
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] Fix locking in flush_backlog
2010-03-23 23:39 [PATCH v2] Fix locking in flush_backlog Tom Herbert
@ 2010-03-24 5:34 ` Eric Dumazet
2010-03-24 6:17 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2010-03-24 5:34 UTC (permalink / raw)
To: Tom Herbert; +Cc: davem, netdev
Le mardi 23 mars 2010 à 16:39 -0700, Tom Herbert a écrit :
> Need to take spinlocks when dequeuing from input_pkt_queue in flush_backlog.
> Also, flush_backlog can now be called directly from netdev_run_todo.
>
> Signed-off-by: Tom Herbert <therbert@google.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Thanks Tom
> ---
> diff --git a/net/core/dev.c b/net/core/dev.c
> diff --git a/net/core/dev.c b/net/core/dev.c
> index a03aab4..5e3dc28 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -2766,17 +2766,19 @@ 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)
> +static void flush_backlog(struct net_device *dev, int cpu)
> {
> - struct net_device *dev = arg;
> - struct softnet_data *queue = &__get_cpu_var(softnet_data);
> + struct softnet_data *queue = &per_cpu(softnet_data, cpu);
> 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);
> }
>
> static int napi_gro_complete(struct sk_buff *skb)
> @@ -5545,6 +5547,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 +5559,8 @@ void netdev_run_todo(void)
>
> dev->reg_state = NETREG_UNREGISTERED;
>
> - on_each_cpu(flush_backlog, dev, 1);
> + for_each_online_cpu(i)
> + flush_backlog(dev, i);
>
> netdev_wait_allrefs(dev);
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] Fix locking in flush_backlog
2010-03-24 5:34 ` Eric Dumazet
@ 2010-03-24 6:17 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2010-03-24 6:17 UTC (permalink / raw)
To: eric.dumazet; +Cc: therbert, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 24 Mar 2010 06:34:42 +0100
> Le mardi 23 mars 2010 à 16:39 -0700, Tom Herbert a écrit :
>> Need to take spinlocks when dequeuing from input_pkt_queue in flush_backlog.
>> Also, flush_backlog can now be called directly from netdev_run_todo.
>>
>> Signed-off-by: Tom Herbert <therbert@google.com>
>
> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied, thanks everyone.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-24 6:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-23 23:39 [PATCH v2] Fix locking in flush_backlog Tom Herbert
2010-03-24 5:34 ` Eric Dumazet
2010-03-24 6:17 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox