Skip to contentSkip to conversation

Fix wrong offset for vma merge in mbind

PATCH In review Minchan Kim 2 participants 2 messages Jan 16, 2010 – Jan 18, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix wrong offset for vma merge in mbind

mm-fix-mbind-vma-merge-problem.patch added vma_merge in mbind to merge mergeable vmas.
But it passed wrong offset of vm_file.

This patch fixes it.

Cc KOSAKI Motohiro <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Hugh Dickins <[email protected]>
---
 mm/mempolicy.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
mm/mempolicy.c +3 -2
index 9751f3f..7e529d0 100644
@@ -570,6 +570,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
 	struct vm_area_struct *prev;
 	struct vm_area_struct *vma;
 	int err = 0;
+	pgoff_t pgoff;
 	unsigned long vmstart;
 	unsigned long vmend;
 
@@ -582,9 +583,9 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
 		vmstart = max(start, vma->vm_start);
 		vmend   = min(end, vma->vm_end);
 
+		pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
 		prev = vma_merge(mm, prev, vmstart, vmend, vma->vm_flags,
-				  vma->anon_vma, vma->vm_file, vma->vm_pgoff,
-				  new_pol);
+				  vma->anon_vma, vma->vm_file, pgoff, new_pol);
 		if (prev) {
 			vma = prev;
 			next = vma->vm_next;
Signature · 7 lines
1.6.3.3



-- 
Kind regards,
Minchan Kim
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines

mm-fix-mbind-vma-merge-problem.patch added vma_merge in mbind to merge mergeable vmas.
But it passed wrong offset of vm_file.

This patch fixes it.

Cc KOSAKI Motohiro <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Hugh Dickins <[email protected]>

Nice catch!

Quoted 37 lines
---
 mm/mempolicy.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
mm/mempolicy.c +3 -2
index 9751f3f..7e529d0 100644
@@ -570,6 +570,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
 	struct vm_area_struct *prev;
 	struct vm_area_struct *vma;
 	int err = 0;
+	pgoff_t pgoff;
 	unsigned long vmstart;
 	unsigned long vmend;
 
@@ -582,9 +583,9 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
 		vmstart = max(start, vma->vm_start);
 		vmend   = min(end, vma->vm_end);
 
+		pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
 		prev = vma_merge(mm, prev, vmstart, vmend, vma->vm_flags,
-				  vma->anon_vma, vma->vm_file, vma->vm_pgoff,
-				  new_pol);
+				  vma->anon_vma, vma->vm_file, pgoff, new_pol);
 		if (prev) {
 			vma = prev;
 			next = vma->vm_next;
Signature · 7 lines
1.6.3.3



-- 
Kind regards,
Minchan Kim