linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 13/14] mm: mempolicy: Check return code of check_range
@ 2010-09-05 18:33 Kulikov Vasiliy
  2010-09-05 22:04 ` David Rientjes
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Kulikov Vasiliy @ 2010-09-05 18:33 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Vasiliy Kulikov, Andrew Morton, KOSAKI Motohiro, Lee Schermerhorn,
	Christoph Lameter, David Rientjes, linux-kernel, linux-mm

From: Vasiliy Kulikov <segooon@gmail.com>

Function check_range may return ERR_PTR(...). Check for it.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
 Compile tested.

 mm/mempolicy.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index f969da5..b73f02c 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -924,12 +924,15 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest,
 	nodemask_t nmask;
 	LIST_HEAD(pagelist);
 	int err = 0;
+	struct vm_area_struct *vma;
 
 	nodes_clear(nmask);
 	node_set(source, nmask);
 
-	check_range(mm, mm->mmap->vm_start, mm->task_size, &nmask,
+	vma = check_range(mm, mm->mmap->vm_start, mm->task_size, &nmask,
 			flags | MPOL_MF_DISCONTIG_OK, &pagelist);
+	if (IS_ERR(vma))
+		return PTR_ERR(vma);
 
 	if (!list_empty(&pagelist))
 		err = migrate_pages(&pagelist, new_node_page, dest, 0);
-- 
1.7.0.4

--
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>

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 13/14] mm: mempolicy: Check return code of check_range
  2010-09-05 18:33 [PATCH 13/14] mm: mempolicy: Check return code of check_range Kulikov Vasiliy
@ 2010-09-05 22:04 ` David Rientjes
  2010-09-05 23:15 ` Christoph Lameter
  2010-09-06  0:41 ` KOSAKI Motohiro
  2 siblings, 0 replies; 9+ messages in thread
From: David Rientjes @ 2010-09-05 22:04 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Andrew Morton, KOSAKI Motohiro, Lee Schermerhorn,
	Christoph Lameter, linux-kernel, linux-mm

On Sun, 5 Sep 2010, Kulikov Vasiliy wrote:

> From: Vasiliy Kulikov <segooon@gmail.com>
> 
> Function check_range may return ERR_PTR(...). Check for it.
> 
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>

Acked-by: David Rientjes <rientjes@google.com>

--
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 13/14] mm: mempolicy: Check return code of check_range
  2010-09-05 18:33 [PATCH 13/14] mm: mempolicy: Check return code of check_range Kulikov Vasiliy
  2010-09-05 22:04 ` David Rientjes
@ 2010-09-05 23:15 ` Christoph Lameter
  2010-09-06  0:41 ` KOSAKI Motohiro
  2 siblings, 0 replies; 9+ messages in thread
From: Christoph Lameter @ 2010-09-05 23:15 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Andrew Morton, KOSAKI Motohiro, Lee Schermerhorn,
	David Rientjes, linux-kernel, linux-mm


Reviewed-by: Christoph Lameter <cl@linux.com>


--
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 13/14] mm: mempolicy: Check return code of check_range
  2010-09-05 18:33 [PATCH 13/14] mm: mempolicy: Check return code of check_range Kulikov Vasiliy
  2010-09-05 22:04 ` David Rientjes
  2010-09-05 23:15 ` Christoph Lameter
@ 2010-09-06  0:41 ` KOSAKI Motohiro
  2010-09-06  9:02   ` David Rientjes
  2010-09-07  1:59   ` Christoph Lameter
  2 siblings, 2 replies; 9+ messages in thread
From: KOSAKI Motohiro @ 2010-09-06  0:41 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kosaki.motohiro, kernel-janitors, Andrew Morton, Lee Schermerhorn,
	Christoph Lameter, David Rientjes, linux-kernel, linux-mm

> From: Vasiliy Kulikov <segooon@gmail.com>
> 
> Function check_range may return ERR_PTR(...). Check for it.

When happen this issue?

afaik, check_range return error when following condition.
 1) mm->mmap->vm_start argument is incorrect
 2) don't have neigher MPOL_MF_STATS, MPOL_MF_MOVE and MPOL_MF_MOVE_ALL

I think both case is not happen in real. Am I overlooking anything?


> 
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
> ---
>  Compile tested.
> 
>  mm/mempolicy.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index f969da5..b73f02c 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -924,12 +924,15 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest,
>  	nodemask_t nmask;
>  	LIST_HEAD(pagelist);
>  	int err = 0;
> +	struct vm_area_struct *vma;
>  
>  	nodes_clear(nmask);
>  	node_set(source, nmask);
>  
> -	check_range(mm, mm->mmap->vm_start, mm->task_size, &nmask,
> +	vma = check_range(mm, mm->mmap->vm_start, mm->task_size, &nmask,
>  			flags | MPOL_MF_DISCONTIG_OK, &pagelist);
> +	if (IS_ERR(vma))
> +		return PTR_ERR(vma);
>  
>  	if (!list_empty(&pagelist))
>  		err = migrate_pages(&pagelist, new_node_page, dest, 0);
> -- 
> 1.7.0.4
> 



--
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 13/14] mm: mempolicy: Check return code of check_range
  2010-09-06  0:41 ` KOSAKI Motohiro
@ 2010-09-06  9:02   ` David Rientjes
  2010-09-06 14:18     ` Kulikov Vasiliy
  2010-09-07  0:02     ` KOSAKI Motohiro
  2010-09-07  1:59   ` Christoph Lameter
  1 sibling, 2 replies; 9+ messages in thread
From: David Rientjes @ 2010-09-06  9:02 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: Kulikov Vasiliy, kernel-janitors, Andrew Morton, Lee Schermerhorn,
	Christoph Lameter, linux-kernel, linux-mm

On Mon, 6 Sep 2010, KOSAKI Motohiro wrote:

> > From: Vasiliy Kulikov <segooon@gmail.com>
> > 
> > Function check_range may return ERR_PTR(...). Check for it.
> 
> When happen this issue?
> 
> afaik, check_range return error when following condition.
>  1) mm->mmap->vm_start argument is incorrect
>  2) don't have neigher MPOL_MF_STATS, MPOL_MF_MOVE and MPOL_MF_MOVE_ALL
> 
> I think both case is not happen in real. Am I overlooking anything?
> 

There's no reason not to check the return value of a function when the 
implementation of either could change at any time.  migrate_to_node() is 
certainly not in any fastpath where we can't sacrifice a branch for more 
robust code.

--
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 13/14] mm: mempolicy: Check return code of check_range
  2010-09-06  9:02   ` David Rientjes
@ 2010-09-06 14:18     ` Kulikov Vasiliy
  2010-09-07  0:02     ` KOSAKI Motohiro
  1 sibling, 0 replies; 9+ messages in thread
From: Kulikov Vasiliy @ 2010-09-06 14:18 UTC (permalink / raw)
  To: David Rientjes
  Cc: KOSAKI Motohiro, kernel-janitors, Andrew Morton, Lee Schermerhorn,
	Christoph Lameter, linux-kernel, linux-mm

On Mon, Sep 06, 2010 at 02:02 -0700, David Rientjes wrote:
> On Mon, 6 Sep 2010, KOSAKI Motohiro wrote:
> 
> > > From: Vasiliy Kulikov <segooon@gmail.com>
> > > 
> > > Function check_range may return ERR_PTR(...). Check for it.
> > 
> > When happen this issue?
> > 
> > afaik, check_range return error when following condition.
> >  1) mm->mmap->vm_start argument is incorrect
> >  2) don't have neigher MPOL_MF_STATS, MPOL_MF_MOVE and MPOL_MF_MOVE_ALL
> > 
> > I think both case is not happen in real. Am I overlooking anything?
> > 
> 
> There's no reason not to check the return value of a function when the 
> implementation of either could change at any time.  migrate_to_node() is 
> certainly not in any fastpath where we can't sacrifice a branch for more 
> robust code.

Agreed, if you know that the caller must check input data and must not
check return code, it's better to make this function return void.

-- 
Vasiliy

--
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 13/14] mm: mempolicy: Check return code of check_range
  2010-09-06  9:02   ` David Rientjes
  2010-09-06 14:18     ` Kulikov Vasiliy
@ 2010-09-07  0:02     ` KOSAKI Motohiro
  1 sibling, 0 replies; 9+ messages in thread
From: KOSAKI Motohiro @ 2010-09-07  0:02 UTC (permalink / raw)
  To: David Rientjes
  Cc: kosaki.motohiro, Kulikov Vasiliy, kernel-janitors, Andrew Morton,
	Lee Schermerhorn, Christoph Lameter, linux-kernel, linux-mm

> On Mon, 6 Sep 2010, KOSAKI Motohiro wrote:
> 
> > > From: Vasiliy Kulikov <segooon@gmail.com>
> > > 
> > > Function check_range may return ERR_PTR(...). Check for it.
> > 
> > When happen this issue?
> > 
> > afaik, check_range return error when following condition.
> >  1) mm->mmap->vm_start argument is incorrect
> >  2) don't have neigher MPOL_MF_STATS, MPOL_MF_MOVE and MPOL_MF_MOVE_ALL
> > 
> > I think both case is not happen in real. Am I overlooking anything?
> > 
> 
> There's no reason not to check the return value of a function when the 
> implementation of either could change at any time.  migrate_to_node() is 
> certainly not in any fastpath where we can't sacrifice a branch for more 
> robust code.

I was not against this change. I was asking patch effectness.



--
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 13/14] mm: mempolicy: Check return code of check_range
  2010-09-06  0:41 ` KOSAKI Motohiro
  2010-09-06  9:02   ` David Rientjes
@ 2010-09-07  1:59   ` Christoph Lameter
  2010-09-07  2:04     ` KOSAKI Motohiro
  1 sibling, 1 reply; 9+ messages in thread
From: Christoph Lameter @ 2010-09-07  1:59 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: Kulikov Vasiliy, kernel-janitors, Andrew Morton, Lee Schermerhorn,
	David Rientjes, linux-kernel, linux-mm

On Mon, 6 Sep 2010, KOSAKI Motohiro wrote:

> I think both case is not happen in real. Am I overlooking anything?

Its good to check the return code regardless. There is a lot of tinkering
going on with that code.

--
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 13/14] mm: mempolicy: Check return code of check_range
  2010-09-07  1:59   ` Christoph Lameter
@ 2010-09-07  2:04     ` KOSAKI Motohiro
  0 siblings, 0 replies; 9+ messages in thread
From: KOSAKI Motohiro @ 2010-09-07  2:04 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: kosaki.motohiro, Kulikov Vasiliy, kernel-janitors, Andrew Morton,
	Lee Schermerhorn, David Rientjes, linux-kernel, linux-mm

> On Mon, 6 Sep 2010, KOSAKI Motohiro wrote:
> 
> > I think both case is not happen in real. Am I overlooking anything?
> 
> Its good to check the return code regardless. There is a lot of tinkering
> going on with that code.

OK. so, I'm convinced this is not -stable material.

	Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>


--
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-09-07  2:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-05 18:33 [PATCH 13/14] mm: mempolicy: Check return code of check_range Kulikov Vasiliy
2010-09-05 22:04 ` David Rientjes
2010-09-05 23:15 ` Christoph Lameter
2010-09-06  0:41 ` KOSAKI Motohiro
2010-09-06  9:02   ` David Rientjes
2010-09-06 14:18     ` Kulikov Vasiliy
2010-09-07  0:02     ` KOSAKI Motohiro
2010-09-07  1:59   ` Christoph Lameter
2010-09-07  2:04     ` KOSAKI Motohiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).