]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - mm/mempolicy.c
mm, mempolicy: clean up __GFP_THISNODE confusion in policy_zonelist
[mirror_ubuntu-zesty-kernel.git] / mm / mempolicy.c
index a6a27e5d6b141da21d528c2e7400f0891d52c6a3..4d58021dba344fb3519786adb172ddca5b40b11d 100644 (file)
@@ -1679,25 +1679,17 @@ static nodemask_t *policy_nodemask(gfp_t gfp, struct mempolicy *policy)
 static struct zonelist *policy_zonelist(gfp_t gfp, struct mempolicy *policy,
        int nd)
 {
-       switch (policy->mode) {
-       case MPOL_PREFERRED:
-               if (!(policy->flags & MPOL_F_LOCAL))
-                       nd = policy->v.preferred_node;
-               break;
-       case MPOL_BIND:
+       if (policy->mode == MPOL_PREFERRED && !(policy->flags & MPOL_F_LOCAL))
+               nd = policy->v.preferred_node;
+       else {
                /*
-                * Normally, MPOL_BIND allocations are node-local within the
-                * allowed nodemask.  However, if __GFP_THISNODE is set and the
-                * current node isn't part of the mask, we use the zonelist for
-                * the first node in the mask instead.
+                * __GFP_THISNODE shouldn't even be used with the bind policy
+                * because we might easily break the expectation to stay on the
+                * requested node and not break the policy.
                 */
-               if (unlikely(gfp & __GFP_THISNODE) &&
-                               unlikely(!node_isset(nd, policy->v.nodes)))
-                       nd = first_node(policy->v.nodes);
-               break;
-       default:
-               BUG();
+               WARN_ON_ONCE(policy->mode == MPOL_BIND && (gfp & __GFP_THISNODE));
        }
+
        return node_zonelist(nd, gfp);
 }