]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - mm/mempolicy.c
mm/mempolicy.c:offset_il_node() document and clarify
[mirror_ubuntu-zesty-kernel.git] / mm / mempolicy.c
index 8d369cee0cd68f7b640f48f63d1fdb5d7fc62dd1..7f80ebcd655241051d1b8948ffe736e6b18c5ef7 100644 (file)
@@ -1758,23 +1758,25 @@ unsigned int mempolicy_slab_node(void)
        }
 }
 
-/* Do static interleaving for a VMA with known offset. */
+/*
+ * Do static interleaving for a VMA with known offset @n.  Returns the n'th
+ * node in pol->v.nodes (starting from n=0), wrapping around if n exceeds the
+ * number of present nodes.
+ */
 static unsigned offset_il_node(struct mempolicy *pol,
-               struct vm_area_struct *vma, unsigned long off)
+                              struct vm_area_struct *vma, unsigned long n)
 {
        unsigned nnodes = nodes_weight(pol->v.nodes);
        unsigned target;
-       int c;
-       int nid = NUMA_NO_NODE;
+       int i;
+       int nid;
 
        if (!nnodes)
                return numa_node_id();
-       target = (unsigned int)off % nnodes;
-       c = 0;
-       do {
+       target = (unsigned int)n % nnodes;
+       nid = first_node(pol->v.nodes);
+       for (i = 0; i < target; i++)
                nid = next_node(nid, pol->v.nodes);
-               c++;
-       } while (c <= target);
        return nid;
 }