linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmap: fix loop when adjusting vma
@ 2011-11-11 12:53 Hillf Danton
  2011-11-11 17:24 ` Andrea Arcangeli
  0 siblings, 1 reply; 2+ messages in thread
From: Hillf Danton @ 2011-11-11 12:53 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andrea Arcangeli, Hugh Dickins, Johannes Weiner, LKML, linux-mm

If we have more work to do after one vma is removed, we have to reload @end in
case it is clobbered, then try again.

Thanks

Signed-off-by: Hillf Danton <dhillf@gmail.com>
---

--- a/mm/mmap.c	Fri Nov 11 20:35:46 2011
+++ b/mm/mmap.c	Fri Nov 11 20:41:32 2011
@@ -490,6 +490,7 @@ __vma_unlink(struct mm_struct *mm, struc
 int vma_adjust(struct vm_area_struct *vma, unsigned long start,
 	unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert)
 {
+	unsigned long saved_end = end;
 	struct mm_struct *mm = vma->vm_mm;
 	struct vm_area_struct *next = vma->vm_next;
 	struct vm_area_struct *importer = NULL;
@@ -634,7 +635,14 @@ again:			remove_next = 1 + (end > next->
 		 */
 		if (remove_next == 2) {
 			next = vma->vm_next;
-			goto again;
+			if (next) {
+				/*
+				 * we have more work, reload @end in case
+				 * it is clobbered.
+				 */
+				end = saved_end;
+				goto again;
+			}
 		}
 	}

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mmap: fix loop when adjusting vma
  2011-11-11 12:53 [PATCH] mmap: fix loop when adjusting vma Hillf Danton
@ 2011-11-11 17:24 ` Andrea Arcangeli
  0 siblings, 0 replies; 2+ messages in thread
From: Andrea Arcangeli @ 2011-11-11 17:24 UTC (permalink / raw)
  To: Hillf Danton; +Cc: Andrew Morton, Hugh Dickins, Johannes Weiner, LKML, linux-mm

On Fri, Nov 11, 2011 at 08:53:23PM +0800, Hillf Danton wrote:
> --- a/mm/mmap.c	Fri Nov 11 20:35:46 2011
> +++ b/mm/mmap.c	Fri Nov 11 20:41:32 2011
> @@ -490,6 +490,7 @@ __vma_unlink(struct mm_struct *mm, struc
>  int vma_adjust(struct vm_area_struct *vma, unsigned long start,
>  	unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert)
>  {
> +	unsigned long saved_end = end;
>  	struct mm_struct *mm = vma->vm_mm;
>  	struct vm_area_struct *next = vma->vm_next;
>  	struct vm_area_struct *importer = NULL;
> @@ -634,7 +635,14 @@ again:			remove_next = 1 + (end > next->
>  		 */
>  		if (remove_next == 2) {
>  			next = vma->vm_next;
> -			goto again;
> +			if (next) {
> +				/*
> +				 * we have more work, reload @end in case
> +				 * it is clobbered.
> +				 */
> +				end = saved_end;
> +				goto again;
> +			}
>  		}

Doesn't matter if it's clobbered, remove_next will be set to 1 and
that's all we care about. Caller should use vma->vm_next->vm_end as
"end" anyway for case 6 so it wouldn't be set to 2. Also next can't be
NULL if remove_next == 2. So I don't think this is necessary.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2011-11-11 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-11 12:53 [PATCH] mmap: fix loop when adjusting vma Hillf Danton
2011-11-11 17:24 ` Andrea Arcangeli

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