mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-19 17:37:45 +07:00
mm/mempolicy.c:offset_il_node() document and clarify
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 <vbabka@suse.cz> Cc: Xishi Qiu <qiuxishi@huawei.com> Cc: Joonsoo Kim <js1304@gmail.com> Cc: David Rientjes <rientjes@google.com> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
54f18d3526
commit
fee83b3aba
@ -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,
|
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 nnodes = nodes_weight(pol->v.nodes);
|
||||||
unsigned target;
|
unsigned target;
|
||||||
int c;
|
int i;
|
||||||
int nid = NUMA_NO_NODE;
|
int nid;
|
||||||
|
|
||||||
if (!nnodes)
|
if (!nnodes)
|
||||||
return numa_node_id();
|
return numa_node_id();
|
||||||
target = (unsigned int)off % nnodes;
|
target = (unsigned int)n % nnodes;
|
||||||
c = 0;
|
nid = first_node(pol->v.nodes);
|
||||||
do {
|
for (i = 0; i < target; i++)
|
||||||
nid = next_node(nid, pol->v.nodes);
|
nid = next_node(nid, pol->v.nodes);
|
||||||
c++;
|
|
||||||
} while (c <= target);
|
|
||||||
return nid;
|
return nid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user