[ovs-dev] [PATCH] datapath: Disable preemption updating per-CPU data in dp_dev_recv().

Justin Pettit jpettit at nicira.com
Wed Jan 13 10:39:20 PST 2010


Seems reasonable to me.

--Justin


On Jan 13, 2010, at 10:32 AM, Ben Pfaff wrote:

> dp_dev_recv() is called from do_output(), which can be called from
> execute_actions(), which can be called from process context with
> preemption enabled, so it needs to disabled preemption before it can
> access per-CPU data.
> 
> Build tested on a few different kernels.
> 
> Bug #2316.
> 
> Reported-by: John Galgay <john at galgay.net>
> CC: Dan Wendlandt <dan at nicira.com>
> ---
> datapath/dp_dev.c |    8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/datapath/dp_dev.c b/datapath/dp_dev.c
> index 284a6b5..ee77971 100644
> --- a/datapath/dp_dev.c
> +++ b/datapath/dp_dev.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2009 Nicira Networks.
> + * Copyright (c) 2009, 2010 Nicira Networks.
>  * Distributed under the terms of the GNU GPL version 2.
>  *
>  * Significant portions of this file may be copied from parts of the Linux
> @@ -10,6 +10,7 @@
> #include <linux/netdevice.h>
> #include <linux/etherdevice.h>
> #include <linux/ethtool.h>
> +#include <linux/preempt.h>
> #include <linux/rcupdate.h>
> #include <linux/skbuff.h>
> #include <linux/workqueue.h>
> @@ -52,6 +53,7 @@ static struct net_device_stats *dp_dev_get_stats(struct net_device *netdev)
> int dp_dev_recv(struct net_device *netdev, struct sk_buff *skb) 
> {
> 	struct dp_dev *dp_dev = dp_dev_priv(netdev);
> +	struct pcpu_lstats *lstats;
> 	struct pcpu_lstats *lb_stats;
> 	int len;
> 	len = skb->len;
> @@ -62,9 +64,13 @@ int dp_dev_recv(struct net_device *netdev, struct sk_buff *skb)
> 	else
> 		netif_rx_ni(skb);
> 	netdev->last_rx = jiffies;
> +
> +	preempt_disable();
> 	lb_stats = per_cpu_ptr(dp_dev->lstats, smp_processor_id());
> 	lb_stats->rx_packets++;
> 	lb_stats->rx_bytes += len;
> +	preempt_enable();
> +
> 	return len;
> }
> 
> -- 
> 1.6.3.3
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list