]> git.karo-electronics.de Git - linux-beck.git/blobdiff - mm/page_alloc.c
mm, page_alloc: fix fast-path race with cpuset update or removal
[linux-beck.git] / mm / page_alloc.c
index 593a11d8bc6ba193a862570773ca97b1629c9162..dedadb4a779f7daf27870d4d0f0370c2b18559fc 100644 (file)
@@ -3783,9 +3783,17 @@ retry_cpuset:
        /*
         * Restore the original nodemask if it was potentially replaced with
         * &cpuset_current_mems_allowed to optimize the fast-path attempt.
+        * Also recalculate the starting point for the zonelist iterator or
+        * we could end up iterating over non-eligible zones endlessly.
         */
-       if (cpusets_enabled())
+       if (unlikely(ac.nodemask != nodemask)) {
                ac.nodemask = nodemask;
+               ac.preferred_zoneref = first_zones_zonelist(ac.zonelist,
+                                               ac.high_zoneidx, ac.nodemask);
+               if (!ac.preferred_zoneref->zone)
+                       goto no_zone;
+       }
+
        page = __alloc_pages_slowpath(alloc_mask, order, &ac);
 
 no_zone: