Skip to content

Commit f15ca78

Browse files
oleg-nesterovtorvalds
authored andcommitted
mempolicy: change get_task_policy() to return default_policy rather than NULL
Every caller of get_task_policy() falls back to default_policy if it returns NULL. Change get_task_policy() to do this. Signed-off-by: Oleg Nesterov <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Cc: David Rientjes <[email protected]> Cc: KOSAKI Motohiro <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Cyrill Gorcunov <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Naoya Horiguchi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2386740 commit f15ca78

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

mm/mempolicy.c

+13-18
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,20 @@ static struct mempolicy preferred_node_policy[MAX_NUMNODES];
126126
static struct mempolicy *get_task_policy(struct task_struct *p)
127127
{
128128
struct mempolicy *pol = p->mempolicy;
129+
int node;
129130

130-
if (!pol) {
131-
int node = numa_node_id();
131+
if (pol)
132+
return pol;
132133

133-
if (node != NUMA_NO_NODE) {
134-
pol = &preferred_node_policy[node];
135-
/*
136-
* preferred_node_policy is not initialised early in
137-
* boot
138-
*/
139-
if (!pol->mode)
140-
pol = NULL;
141-
}
134+
node = numa_node_id();
135+
if (node != NUMA_NO_NODE) {
136+
pol = &preferred_node_policy[node];
137+
/* preferred_node_policy is not initialised early in boot */
138+
if (pol->mode)
139+
return pol;
142140
}
143141

144-
return pol;
142+
return &default_policy;
145143
}
146144

147145
static const struct mempolicy_operations {
@@ -1644,14 +1642,14 @@ struct mempolicy *get_vma_policy(struct task_struct *task,
16441642
mpol_get(pol);
16451643
}
16461644
}
1647-
if (!pol)
1648-
pol = &default_policy;
1645+
16491646
return pol;
16501647
}
16511648

16521649
bool vma_policy_mof(struct task_struct *task, struct vm_area_struct *vma)
16531650
{
16541651
struct mempolicy *pol = get_task_policy(task);
1652+
16551653
if (vma) {
16561654
if (vma->vm_ops && vma->vm_ops->get_policy) {
16571655
bool ret = false;
@@ -1667,9 +1665,6 @@ bool vma_policy_mof(struct task_struct *task, struct vm_area_struct *vma)
16671665
}
16681666
}
16691667

1670-
if (!pol)
1671-
return default_policy.flags & MPOL_F_MOF;
1672-
16731668
return pol->flags & MPOL_F_MOF;
16741669
}
16751670

@@ -2077,7 +2072,7 @@ struct page *alloc_pages_current(gfp_t gfp, unsigned order)
20772072
struct page *page;
20782073
unsigned int cpuset_mems_cookie;
20792074

2080-
if (!pol || in_interrupt() || (gfp & __GFP_THISNODE))
2075+
if (in_interrupt() || (gfp & __GFP_THISNODE))
20812076
pol = &default_policy;
20822077

20832078
retry_cpuset:

0 commit comments

Comments
 (0)