net: Fix rxq ref counting
authorTom Herbert <therbert@google.com>
Thu, 7 Oct 2010 10:09:10 +0000 (10:09 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Oct 2010 21:34:32 +0000 (14:34 -0700)
The rx->count reference is used to track reference counts to the
number of rx-queue kobjects created for the device.  This patch
eliminates initialization of the counter in netif_alloc_rx_queues
and instead increments the counter each time a kobject is created.
This is now symmetric with the decrement that is done when an object is
released.

Signed-off-by: Tom Herbert <therbert@google.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c
net/core/net-sysfs.c

index 4962c8afd606f6bca3efe043c1e264b43f5e7434..193eafaabd8867197903909e92cd956da95b5bc4 100644 (file)
@@ -5024,7 +5024,6 @@ static int netif_alloc_rx_queues(struct net_device *dev)
                        return -ENOMEM;
                }
                dev->_rx = rx;
-               atomic_set(&rx->count, count);
 
                /*
                 * Set a pointer to first element in the array which holds the
index fa81fd0a488f79e6f8730e63e3c6a6aed7a1774a..b143173e3eb2bd9259e1c0122800848146b4c136 100644 (file)
@@ -726,6 +726,7 @@ static struct kobj_type rx_queue_ktype = {
 static int rx_queue_add_kobject(struct net_device *net, int index)
 {
        struct netdev_rx_queue *queue = net->_rx + index;
+       struct netdev_rx_queue *first = queue->first;
        struct kobject *kobj = &queue->kobj;
        int error = 0;
 
@@ -738,6 +739,7 @@ static int rx_queue_add_kobject(struct net_device *net, int index)
        }
 
        kobject_uevent(kobj, KOBJ_ADD);
+       atomic_inc(&first->count);
 
        return error;
 }