Merge branch 'for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
[firefly-linux-kernel-4.4.55.git] / net / core / netprio_cgroup.c
index 3a9fd4826b75da9c6c11157f17db2c4d04f76bd5..ba6900f73900e0985bb65b9543e169717083d8b7 100644 (file)
@@ -23,9 +23,8 @@
 #include <net/sock.h>
 #include <net/netprio_cgroup.h>
 
-static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss,
-                                              struct cgroup *cgrp);
-static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp);
+static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp);
+static void cgrp_destroy(struct cgroup *cgrp);
 static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp);
 
 struct cgroup_subsys net_prio_subsys = {
@@ -58,11 +57,12 @@ static int get_prioidx(u32 *prio)
 
        spin_lock_irqsave(&prioidx_map_lock, flags);
        prioidx = find_first_zero_bit(prioidx_map, sizeof(unsigned long) * PRIOIDX_SZ);
+       if (prioidx == sizeof(unsigned long) * PRIOIDX_SZ) {
+               spin_unlock_irqrestore(&prioidx_map_lock, flags);
+               return -ENOSPC;
+       }
        set_bit(prioidx, prioidx_map);
        spin_unlock_irqrestore(&prioidx_map_lock, flags);
-       if (prioidx == sizeof(unsigned long) * PRIOIDX_SZ)
-               return -ENOSPC;
-
        atomic_set(&max_prioidx, prioidx);
        *prio = prioidx;
        return 0;
@@ -107,7 +107,7 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len)
 static void update_netdev_tables(void)
 {
        struct net_device *dev;
-       u32 max_len = atomic_read(&max_prioidx);
+       u32 max_len = atomic_read(&max_prioidx) + 1;
        struct netprio_map *map;
 
        rtnl_lock();
@@ -120,8 +120,7 @@ static void update_netdev_tables(void)
        rtnl_unlock();
 }
 
-static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss,
-                                                struct cgroup *cgrp)
+static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
 {
        struct cgroup_netprio_state *cs;
        int ret;
@@ -145,7 +144,7 @@ static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss,
        return &cs->css;
 }
 
-static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
+static void cgrp_destroy(struct cgroup *cgrp)
 {
        struct cgroup_netprio_state *cs;
        struct net_device *dev;
@@ -270,7 +269,6 @@ static int netprio_device_event(struct notifier_block *unused,
 {
        struct net_device *dev = ptr;
        struct netprio_map *old;
-       u32 max_len = atomic_read(&max_prioidx);
 
        /*
         * Note this is called with rtnl_lock held so we have update side
@@ -278,11 +276,6 @@ static int netprio_device_event(struct notifier_block *unused,
         */
 
        switch (event) {
-
-       case NETDEV_REGISTER:
-               if (max_len)
-                       extend_netdev_table(dev, max_len);
-               break;
        case NETDEV_UNREGISTER:
                old = rtnl_dereference(dev->priomap);
                RCU_INIT_POINTER(dev->priomap, NULL);