Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 278273
b: refs/heads/master
c: 927fbec
h: refs/heads/master
i:
  278271: 218f088
v: v3
  • Loading branch information
Tom Herbert authored and David S. Miller committed Nov 29, 2011
1 parent 1beea05 commit 3099382
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c5d67bd78c5dc540e3461c36fb3d389fbe0de4c3
refs/heads/master: 927fbec13e40648d3c87cbb1daaac5b1fb9c8775
89 changes: 47 additions & 42 deletions trunk/net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,52 @@ static DEFINE_MUTEX(xps_map_mutex);
#define xmap_dereference(P) \
rcu_dereference_protected((P), lockdep_is_held(&xps_map_mutex))

static void xps_queue_release(struct netdev_queue *queue)
{
struct net_device *dev = queue->dev;
struct xps_dev_maps *dev_maps;
struct xps_map *map;
unsigned long index;
int i, pos, nonempty = 0;

index = get_netdev_queue_index(queue);

mutex_lock(&xps_map_mutex);
dev_maps = xmap_dereference(dev->xps_maps);

if (dev_maps) {
for_each_possible_cpu(i) {
map = xmap_dereference(dev_maps->cpu_map[i]);
if (!map)
continue;

for (pos = 0; pos < map->len; pos++)
if (map->queues[pos] == index)
break;

if (pos < map->len) {
if (map->len > 1)
map->queues[pos] =
map->queues[--map->len];
else {
RCU_INIT_POINTER(dev_maps->cpu_map[i],
NULL);
kfree_rcu(map, rcu);
map = NULL;
}
}
if (map)
nonempty = 1;
}

if (!nonempty) {
RCU_INIT_POINTER(dev->xps_maps, NULL);
kfree_rcu(dev_maps, rcu);
}
}
mutex_unlock(&xps_map_mutex);
}

static ssize_t store_xps_map(struct netdev_queue *queue,
struct netdev_queue_attribute *attribute,
const char *buf, size_t len)
Expand Down Expand Up @@ -1054,49 +1100,8 @@ static struct attribute *netdev_queue_default_attrs[] = {
static void netdev_queue_release(struct kobject *kobj)
{
struct netdev_queue *queue = to_netdev_queue(kobj);
struct net_device *dev = queue->dev;
struct xps_dev_maps *dev_maps;
struct xps_map *map;
unsigned long index;
int i, pos, nonempty = 0;

index = get_netdev_queue_index(queue);

mutex_lock(&xps_map_mutex);
dev_maps = xmap_dereference(dev->xps_maps);

if (dev_maps) {
for_each_possible_cpu(i) {
map = xmap_dereference(dev_maps->cpu_map[i]);
if (!map)
continue;

for (pos = 0; pos < map->len; pos++)
if (map->queues[pos] == index)
break;

if (pos < map->len) {
if (map->len > 1)
map->queues[pos] =
map->queues[--map->len];
else {
RCU_INIT_POINTER(dev_maps->cpu_map[i],
NULL);
kfree_rcu(map, rcu);
map = NULL;
}
}
if (map)
nonempty = 1;
}

if (!nonempty) {
RCU_INIT_POINTER(dev->xps_maps, NULL);
kfree_rcu(dev_maps, rcu);
}
}

mutex_unlock(&xps_map_mutex);
xps_queue_release(queue);

memset(kobj, 0, sizeof(*kobj));
dev_put(queue->dev);
Expand Down

0 comments on commit 3099382

Please sign in to comment.