aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mempolicy.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/mempolicy.c')
-rw-r--r--mm/mempolicy.c46
1 files changed, 6 insertions, 40 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index e3ab02822799..78e1472933ea 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -795,36 +795,6 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
795 return err; 795 return err;
796} 796}
797 797
798/*
799 * Update task->flags PF_MEMPOLICY bit: set iff non-default
800 * mempolicy. Allows more rapid checking of this (combined perhaps
801 * with other PF_* flag bits) on memory allocation hot code paths.
802 *
803 * If called from outside this file, the task 'p' should -only- be
804 * a newly forked child not yet visible on the task list, because
805 * manipulating the task flags of a visible task is not safe.
806 *
807 * The above limitation is why this routine has the funny name
808 * mpol_fix_fork_child_flag().
809 *
810 * It is also safe to call this with a task pointer of current,
811 * which the static wrapper mpol_set_task_struct_flag() does,
812 * for use within this file.
813 */
814
815void mpol_fix_fork_child_flag(struct task_struct *p)
816{
817 if (p->mempolicy)
818 p->flags |= PF_MEMPOLICY;
819 else
820 p->flags &= ~PF_MEMPOLICY;
821}
822
823static void mpol_set_task_struct_flag(void)
824{
825 mpol_fix_fork_child_flag(current);
826}
827
828/* Set the process memory policy */ 798/* Set the process memory policy */
829static long do_set_mempolicy(unsigned short mode, unsigned short flags, 799static long do_set_mempolicy(unsigned short mode, unsigned short flags,
830 nodemask_t *nodes) 800 nodemask_t *nodes)
@@ -861,7 +831,6 @@ static long do_set_mempolicy(unsigned short mode, unsigned short flags,
861 } 831 }
862 old = current->mempolicy; 832 old = current->mempolicy;
863 current->mempolicy = new; 833 current->mempolicy = new;
864 mpol_set_task_struct_flag();
865 if (new && new->mode == MPOL_INTERLEAVE && 834 if (new && new->mode == MPOL_INTERLEAVE &&
866 nodes_weight(new->v.nodes)) 835 nodes_weight(new->v.nodes))
867 current->il_next = first_node(new->v.nodes); 836 current->il_next = first_node(new->v.nodes);
@@ -1782,21 +1751,18 @@ static unsigned interleave_nodes(struct mempolicy *policy)
1782/* 1751/*
1783 * Depending on the memory policy provide a node from which to allocate the 1752 * Depending on the memory policy provide a node from which to allocate the
1784 * next slab entry. 1753 * next slab entry.
1785 * @policy must be protected by freeing by the caller. If @policy is
1786 * the current task's mempolicy, this protection is implicit, as only the
1787 * task can change it's policy. The system default policy requires no
1788 * such protection.
1789 */ 1754 */
1790unsigned slab_node(void) 1755unsigned int mempolicy_slab_node(void)
1791{ 1756{
1792 struct mempolicy *policy; 1757 struct mempolicy *policy;
1758 int node = numa_mem_id();
1793 1759
1794 if (in_interrupt()) 1760 if (in_interrupt())
1795 return numa_node_id(); 1761 return node;
1796 1762
1797 policy = current->mempolicy; 1763 policy = current->mempolicy;
1798 if (!policy || policy->flags & MPOL_F_LOCAL) 1764 if (!policy || policy->flags & MPOL_F_LOCAL)
1799 return numa_node_id(); 1765 return node;
1800 1766
1801 switch (policy->mode) { 1767 switch (policy->mode) {
1802 case MPOL_PREFERRED: 1768 case MPOL_PREFERRED:
@@ -1816,11 +1782,11 @@ unsigned slab_node(void)
1816 struct zonelist *zonelist; 1782 struct zonelist *zonelist;
1817 struct zone *zone; 1783 struct zone *zone;
1818 enum zone_type highest_zoneidx = gfp_zone(GFP_KERNEL); 1784 enum zone_type highest_zoneidx = gfp_zone(GFP_KERNEL);
1819 zonelist = &NODE_DATA(numa_node_id())->node_zonelists[0]; 1785 zonelist = &NODE_DATA(node)->node_zonelists[0];
1820 (void)first_zones_zonelist(zonelist, highest_zoneidx, 1786 (void)first_zones_zonelist(zonelist, highest_zoneidx,
1821 &policy->v.nodes, 1787 &policy->v.nodes,
1822 &zone); 1788 &zone);
1823 return zone ? zone->node : numa_node_id(); 1789 return zone ? zone->node : node;
1824 } 1790 }
1825 1791
1826 default: 1792 default: