Skip to content

Commit

Permalink
mm/mempolicy.c:offset_il_node() document and clarify
Browse files Browse the repository at this point in the history
This code was pretty obscure and was relying upon obscure side-effects
of next_node(-1, ...) and was relying upon NUMA_NO_NODE being equal to
-1.

Clean that all up and document the function's intent.

Acked-by: Vlastimil Babka <[email protected]>
Cc: Xishi Qiu <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: Laura Abbott <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
akpm00 authored and torvalds committed May 20, 2016
1 parent 54f18d3 commit fee83b3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit fee83b3

Please sign in to comment.