* success so it is time to admit defeat. We will skip the OOM killer
         * because it is very likely that the caller has a more reasonable
         * fallback than shooting a random task.
+        *
+        * The OOM killer may not free memory on a specific node.
         */
-       if (gfp_mask & __GFP_RETRY_MAYFAIL)
+       if (gfp_mask & (__GFP_RETRY_MAYFAIL | __GFP_THISNODE))
                goto out;
        /* The OOM killer does not needlessly kill tasks for lowmem */
        if (ac->highest_zoneidx < ZONE_NORMAL)
         * failures more gracefully we should just bail out here.
         */
 
-       /* The OOM killer may not free memory on a specific node */
-       if (gfp_mask & __GFP_THISNODE)
-               goto out;
-
        /* Exhausted what can be done so it's blame time */
        if (out_of_memory(&oc) || WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL)) {
                *did_some_progress = 1;