Merge tag 'nfsd-4.8' of git://linux-nfs.org/~bfields/linux
[linux-2.6-block.git] / mm / memcontrol.c
index c265212bec8c0f412e9f23e260a5ff0d490ea046..66beca1ad92ffcc16c3636c4e7e54c46bc89cc3f 100644 (file)
@@ -2559,6 +2559,15 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
                return 0;
 
        mctz = soft_limit_tree_node(pgdat->node_id);
+
+       /*
+        * Do not even bother to check the largest node if the root
+        * is empty. Do it lockless to prevent lock bouncing. Races
+        * are acceptable as soft limit is best effort anyway.
+        */
+       if (RB_EMPTY_ROOT(&mctz->rb_root))
+               return 0;
+
        /*
         * This loop can run a while, specially if mem_cgroup's continuously
         * keep exceeding their soft limit and putting the system under