Merge tag 'acpi-5.15-rc1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux-2.6-microblaze.git] / mm / mempolicy.c
index eb95578..1592b08 100644 (file)
@@ -1649,43 +1649,6 @@ SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,
        return kernel_get_mempolicy(policy, nmask, maxnode, addr, flags);
 }
 
-#ifdef CONFIG_COMPAT
-
-COMPAT_SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,
-                      compat_ulong_t __user *, nmask,
-                      compat_ulong_t, maxnode,
-                      compat_ulong_t, addr, compat_ulong_t, flags)
-{
-       return kernel_get_mempolicy(policy, (unsigned long __user *)nmask,
-                                   maxnode, addr, flags);
-}
-
-COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask,
-                      compat_ulong_t, maxnode)
-{
-       return kernel_set_mempolicy(mode, (unsigned long __user *)nmask, maxnode);
-}
-
-COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len,
-                      compat_ulong_t, mode, compat_ulong_t __user *, nmask,
-                      compat_ulong_t, maxnode, compat_ulong_t, flags)
-{
-       return kernel_mbind(start, len, mode, (unsigned long __user *)nmask,
-                           maxnode, flags);
-}
-
-COMPAT_SYSCALL_DEFINE4(migrate_pages, compat_pid_t, pid,
-                      compat_ulong_t, maxnode,
-                      const compat_ulong_t __user *, old_nodes,
-                      const compat_ulong_t __user *, new_nodes)
-{
-       return kernel_migrate_pages(pid, maxnode,
-                                   (const unsigned long __user *)old_nodes,
-                                   (const unsigned long __user *)new_nodes);
-}
-
-#endif /* CONFIG_COMPAT */
-
 bool vma_migratable(struct vm_area_struct *vma)
 {
        if (vma->vm_flags & (VM_IO | VM_PFNMAP))
@@ -1913,17 +1876,26 @@ unsigned int mempolicy_slab_node(void)
  */
 static unsigned offset_il_node(struct mempolicy *pol, unsigned long n)
 {
-       unsigned nnodes = nodes_weight(pol->nodes);
-       unsigned target;
+       nodemask_t nodemask = pol->nodes;
+       unsigned int target, nnodes;
        int i;
        int nid;
+       /*
+        * The barrier will stabilize the nodemask in a register or on
+        * the stack so that it will stop changing under the code.
+        *
+        * Between first_node() and next_node(), pol->nodes could be changed
+        * by other threads. So we put pol->nodes in a local stack.
+        */
+       barrier();
 
+       nnodes = nodes_weight(nodemask);
        if (!nnodes)
                return numa_node_id();
        target = (unsigned int)n % nnodes;
-       nid = first_node(pol->nodes);
+       nid = first_node(nodemask);
        for (i = 0; i < target; i++)
-               nid = next_node(nid, pol->nodes);
+               nid = next_node(nid, nodemask);
        return nid;
 }