aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mempolicy.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/mempolicy.c')
-rw-r--r--mm/mempolicy.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index a683a66599b1..71430d440822 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -976,6 +976,36 @@ static unsigned interleave_nodes(struct mempolicy *policy)
976 return nid; 976 return nid;
977} 977}
978 978
979/*
980 * Depending on the memory policy provide a node from which to allocate the
981 * next slab entry.
982 */
983unsigned slab_node(struct mempolicy *policy)
984{
985 if (in_interrupt())
986 return numa_node_id();
987
988 switch (policy->policy) {
989 case MPOL_INTERLEAVE:
990 return interleave_nodes(policy);
991
992 case MPOL_BIND:
993 /*
994 * Follow bind policy behavior and start allocation at the
995 * first node.
996 */
997 return policy->v.zonelist->zones[0]->zone_pgdat->node_id;
998
999 case MPOL_PREFERRED:
1000 if (policy->v.preferred_node >= 0)
1001 return policy->v.preferred_node;
1002 /* Fall through */
1003
1004 default:
1005 return numa_node_id();
1006 }
1007}
1008
979/* Do static interleaving for a VMA with known offset. */ 1009/* Do static interleaving for a VMA with known offset. */
980static unsigned offset_il_node(struct mempolicy *pol, 1010static unsigned offset_il_node(struct mempolicy *pol,
981 struct vm_area_struct *vma, unsigned long off) 1011 struct vm_area_struct *vma, unsigned long off)