linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] migration: migrate_vmas should check "vma"
@ 2009-01-28  7:26 Daisuke Nishimura
  2009-01-28 16:42 ` Christoph Lameter
  0 siblings, 1 reply; 6+ messages in thread
From: Daisuke Nishimura @ 2009-01-28  7:26 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Christoph Lameter, LKML, linux-mm, nishimura

migrate_vmas() should check "vma" not "vma->vm_next" for for-loop condition.

Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
---
 mm/migrate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 2bb4e1d..a9eff3f 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1129,7 +1129,7 @@ int migrate_vmas(struct mm_struct *mm, const nodemask_t *to,
  	struct vm_area_struct *vma;
  	int err = 0;
 
- 	for(vma = mm->mmap; vma->vm_next && !err; vma = vma->vm_next) {
+	for (vma = mm->mmap; vma && !err; vma = vma->vm_next) {
  		if (vma->vm_ops && vma->vm_ops->migrate) {
  			err = vma->vm_ops->migrate(vma, to, from, flags);
  			if (err)

--
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] 6+ messages in thread

* Re: [PATCH] migration: migrate_vmas should check "vma"
  2009-01-28  7:26 [PATCH] migration: migrate_vmas should check "vma" Daisuke Nishimura
@ 2009-01-28 16:42 ` Christoph Lameter
  2009-01-28 16:55   ` Johannes Weiner
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Lameter @ 2009-01-28 16:42 UTC (permalink / raw)
  To: Daisuke Nishimura; +Cc: Andrew Morton, LKML, linux-mm

On Wed, 28 Jan 2009, Daisuke Nishimura wrote:

> migrate_vmas() should check "vma" not "vma->vm_next" for for-loop condition.

The loop condition is checked before vma = vma->vm_next. So the last
iteration of the loop will now be run with vma = NULL?

--
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] 6+ messages in thread

* Re: [PATCH] migration: migrate_vmas should check "vma"
  2009-01-28 16:42 ` Christoph Lameter
@ 2009-01-28 16:55   ` Johannes Weiner
  2009-01-29  1:16     ` Daisuke Nishimura
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Weiner @ 2009-01-28 16:55 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: Daisuke Nishimura, Andrew Morton, LKML, linux-mm

On Wed, Jan 28, 2009 at 11:42:36AM -0500, Christoph Lameter wrote:
> On Wed, 28 Jan 2009, Daisuke Nishimura wrote:
> 
> > migrate_vmas() should check "vma" not "vma->vm_next" for for-loop condition.
> 
> The loop condition is checked before vma = vma->vm_next. So the last
> iteration of the loop will now be run with vma = NULL?

No, the condition is always checked before the body is executed.  The
assignment to vma->vm_next happens at the end of every body.

Try this:

		int a = 2;

		for (puts("init"); puts("cond"), a; puts("next"))
			a--;

	Hannes

--
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] 6+ messages in thread

* Re: [PATCH] migration: migrate_vmas should check "vma"
  2009-01-28 16:55   ` Johannes Weiner
@ 2009-01-29  1:16     ` Daisuke Nishimura
  2009-01-29  8:18       ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Daisuke Nishimura @ 2009-01-29  1:16 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Johannes Weiner, Andrew Morton, LKML, linux-mm, nishimura

On Wed, 28 Jan 2009 17:55:12 +0100, Johannes Weiner <hannes@cmpxchg.org> wrote:
> On Wed, Jan 28, 2009 at 11:42:36AM -0500, Christoph Lameter wrote:
> > On Wed, 28 Jan 2009, Daisuke Nishimura wrote:
> > 
> > > migrate_vmas() should check "vma" not "vma->vm_next" for for-loop condition.
> > 
> > The loop condition is checked before vma = vma->vm_next. So the last
> > iteration of the loop will now be run with vma = NULL?
> 
> No, the condition is always checked before the body is executed.  The
> assignment to vma->vm_next happens at the end of every body.
> 
So, I think in current code the loop body is not executed
about the last vma in the list.


Thanks,
Daisuke Nishimura.

> Try this:
> 
> 		int a = 2;
> 
> 		for (puts("init"); puts("cond"), a; puts("next"))
> 			a--;
> 
> 	Hannes

--
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] 6+ messages in thread

* Re: [PATCH] migration: migrate_vmas should check "vma"
  2009-01-29  1:16     ` Daisuke Nishimura
@ 2009-01-29  8:18       ` Andrew Morton
  2009-01-30  0:30         ` Daisuke Nishimura
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2009-01-29  8:18 UTC (permalink / raw)
  To: Daisuke Nishimura; +Cc: Christoph Lameter, Johannes Weiner, LKML, linux-mm

On Thu, 29 Jan 2009 10:16:23 +0900 Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:

> On Wed, 28 Jan 2009 17:55:12 +0100, Johannes Weiner <hannes@cmpxchg.org> wrote:
> > On Wed, Jan 28, 2009 at 11:42:36AM -0500, Christoph Lameter wrote:
> > > On Wed, 28 Jan 2009, Daisuke Nishimura wrote:
> > > 
> > > > migrate_vmas() should check "vma" not "vma->vm_next" for for-loop condition.
> > > 
> > > The loop condition is checked before vma = vma->vm_next. So the last
> > > iteration of the loop will now be run with vma = NULL?
> > 
> > No, the condition is always checked before the body is executed.  The
> > assignment to vma->vm_next happens at the end of every body.
> > 
> So, I think in current code the loop body is not executed
> about the last vma in the list.
> 

Yep.

Is this serious enough to bother fixing in 2.6.29?

--
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] 6+ messages in thread

* Re: [PATCH] migration: migrate_vmas should check "vma"
  2009-01-29  8:18       ` Andrew Morton
@ 2009-01-30  0:30         ` Daisuke Nishimura
  0 siblings, 0 replies; 6+ messages in thread
From: Daisuke Nishimura @ 2009-01-30  0:30 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Christoph Lameter, Johannes Weiner, LKML, linux-mm, nishimura

On Thu, 29 Jan 2009 00:18:49 -0800, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Thu, 29 Jan 2009 10:16:23 +0900 Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
> 
> > On Wed, 28 Jan 2009 17:55:12 +0100, Johannes Weiner <hannes@cmpxchg.org> wrote:
> > > On Wed, Jan 28, 2009 at 11:42:36AM -0500, Christoph Lameter wrote:
> > > > On Wed, 28 Jan 2009, Daisuke Nishimura wrote:
> > > > 
> > > > > migrate_vmas() should check "vma" not "vma->vm_next" for for-loop condition.
> > > > 
> > > > The loop condition is checked before vma = vma->vm_next. So the last
> > > > iteration of the loop will now be run with vma = NULL?
> > > 
> > > No, the condition is always checked before the body is executed.  The
> > > assignment to vma->vm_next happens at the end of every body.
> > > 
> > So, I think in current code the loop body is not executed
> > about the last vma in the list.
> > 
> 
> Yep.
> 
> Is this serious enough to bother fixing in 2.6.29?
IIUC, there is no user of vm_ops->migrate() now, so this bug causes
no practical problems.

I think it's trival and simple enough to go in .29, but I don't have
any objection if you postpone this patch.


Thanks,
Daisuke Nishimura.

--
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] 6+ messages in thread

end of thread, other threads:[~2009-01-30  0:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-28  7:26 [PATCH] migration: migrate_vmas should check "vma" Daisuke Nishimura
2009-01-28 16:42 ` Christoph Lameter
2009-01-28 16:55   ` Johannes Weiner
2009-01-29  1:16     ` Daisuke Nishimura
2009-01-29  8:18       ` Andrew Morton
2009-01-30  0:30         ` Daisuke Nishimura

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox