mm: memcontrol: simplify soft limit tree init code
authorJohannes Weiner <hannes@cmpxchg.org>
Wed, 11 Feb 2015 23:26:30 +0000 (15:26 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 12 Feb 2015 01:06:03 +0000 (17:06 -0800)
- No need to test the node for N_MEMORY.  node_online() is enough for
  node fallback to work in slab, use NUMA_NO_NODE for everything else.

- Remove the BUG_ON() for allocation failure.  A NULL pointer crash is
  just as descriptive, and the absent return value check is obvious.

- Move local variables to the inner-most blocks.

- Point to the tree structure after its initialized, not before, it's
  just more logical that way.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Vladimir Davydov <vdavydov@parallels.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memcontrol.c

index fbf64e6f64e42cbdd9a23a006ef578cf7888b74f..2efec685793b6e5606228bd27c0d72428cceb79d 100644 (file)
@@ -4509,24 +4509,23 @@ EXPORT_SYMBOL(parent_mem_cgroup);
 
 static void __init mem_cgroup_soft_limit_tree_init(void)
 {
-       struct mem_cgroup_tree_per_node *rtpn;
-       struct mem_cgroup_tree_per_zone *rtpz;
-       int tmp, node, zone;
+       int node;
 
        for_each_node(node) {
-               tmp = node;
-               if (!node_state(node, N_NORMAL_MEMORY))
-                       tmp = -1;
-               rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, tmp);
-               BUG_ON(!rtpn);
+               struct mem_cgroup_tree_per_node *rtpn;
+               int zone;
 
-               soft_limit_tree.rb_tree_per_node[node] = rtpn;
+               rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL,
+                                   node_online(node) ? node : NUMA_NO_NODE);
 
                for (zone = 0; zone < MAX_NR_ZONES; zone++) {
+                       struct mem_cgroup_tree_per_zone *rtpz;
+
                        rtpz = &rtpn->rb_tree_per_zone[zone];
                        rtpz->rb_root = RB_ROOT;
                        spin_lock_init(&rtpz->lock);
                }
+               soft_limit_tree.rb_tree_per_node[node] = rtpn;
        }
 }