Commit 1da6f0e1b316d0215989fe4d7c657edead1fdea7

Authored by Jianguo Wu
Committed by Linus Torvalds
1 parent af0ed73e69

mm/mempolicy: return NULL if node is NUMA_NO_NODE in get_task_policy

If node == NUMA_NO_NODE, pol is NULL, we should return NULL instead of
do "if (!pol->mode)" check.

[akpm@linux-foundation.org: reorganise code]
Signed-off-by: Jianguo Wu <wujianguo@huawei.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 10 additions and 7 deletions Side-by-side Diff

... ... @@ -123,16 +123,19 @@
123 123 static struct mempolicy *get_task_policy(struct task_struct *p)
124 124 {
125 125 struct mempolicy *pol = p->mempolicy;
126   - int node;
127 126  
128 127 if (!pol) {
129   - node = numa_node_id();
130   - if (node != NUMA_NO_NODE)
131   - pol = &preferred_node_policy[node];
  128 + int node = numa_node_id();
132 129  
133   - /* preferred_node_policy is not initialised early in boot */
134   - if (!pol->mode)
135   - pol = NULL;
  130 + if (node != NUMA_NO_NODE) {
  131 + pol = &preferred_node_policy[node];
  132 + /*
  133 + * preferred_node_policy is not initialised early in
  134 + * boot
  135 + */
  136 + if (!pol->mode)
  137 + pol = NULL;
  138 + }
136 139 }
137 140  
138 141 return pol;