Skip to content

Commit

Permalink
mm/mempolicy: return NULL if node is NUMA_NO_NODE in get_task_policy
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jianguo Wu authored and Linus Torvalds committed Sep 11, 2013
1 parent af0ed73 commit 1da6f0e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,19 @@ static struct mempolicy preferred_node_policy[MAX_NUMNODES];
static struct mempolicy *get_task_policy(struct task_struct *p)
{
struct mempolicy *pol = p->mempolicy;
int node;

if (!pol) {
node = numa_node_id();
if (node != NUMA_NO_NODE)
pol = &preferred_node_policy[node];
int node = numa_node_id();

/* preferred_node_policy is not initialised early in boot */
if (!pol->mode)
pol = NULL;
if (node != NUMA_NO_NODE) {
pol = &preferred_node_policy[node];
/*
* preferred_node_policy is not initialised early in
* boot
*/
if (!pol->mode)
pol = NULL;
}
}

return pol;
Expand Down

0 comments on commit 1da6f0e

Please sign in to comment.