linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jianguo Wu <wujianguo@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Rik van Riel <riel@redhat.com>, Hugh Dickins <hughd@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Hanjun Guo <guohanjun@huawei.com>
Subject: Re: [PATCH] mm/mempolicy: return NULL if node is NUMA_NO_NODE in get_task_policy
Date: Wed, 7 Aug 2013 08:54:39 +0800	[thread overview]
Message-ID: <52019ACF.1020006@huawei.com> (raw)
In-Reply-To: <20130806140326.1d0d75874e6be221a432c3bc@linux-foundation.org>

Hi Andrew,

On 2013/8/7 5:03, Andrew Morton wrote:

> On Tue, 6 Aug 2013 12:06:56 +0800 Jianguo Wu <wujianguo@huawei.com> wrote:
> 
>> If node == NUMA_NO_NODE, pol is NULL, we should return NULL instead of
>> do "if (!pol->mode)" check.
>>
>> Signed-off-by: Jianguo Wu <wujianguo@huawei.com>
>> ---
>>  mm/mempolicy.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
>> index 4baf12e..e0e3398 100644
>> --- a/mm/mempolicy.c
>> +++ b/mm/mempolicy.c
>> @@ -129,6 +129,8 @@ static struct mempolicy *get_task_policy(struct task_struct *p)
>>  		node = numa_node_id();
>>  		if (node != NUMA_NO_NODE)
>>  			pol = &preferred_node_policy[node];
>> +		else
>> +			return NULL;
>>  
>>  		/* preferred_node_policy is not initialised early in boot */
>>  		if (!pol->mode)
> 
> Well yes, it'll dereference a null pointer
> 
> This is neater, I think:
> 

Yes, this is more readable, Thanks.

> --- a/mm/mempolicy.c~mm-mempolicy-return-null-if-node-is-numa_no_node-in-get_task_policy
> +++ a/mm/mempolicy.c
> @@ -123,16 +123,19 @@ static struct mempolicy preferred_node_p
>  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;
> _
> 
> 
> .
> 



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2013-08-07  0:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06  4:06 Jianguo Wu
2013-08-06 21:03 ` Andrew Morton
2013-08-07  0:54   ` Jianguo Wu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52019ACF.1020006@huawei.com \
    --to=wujianguo@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=guohanjun@huawei.com \
    --cc=hughd@google.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=riel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox