Commit f9d86a60 authored by Wei Yang's avatar Wei Yang Committed by Linus Torvalds

mm/mmap: leave adjust_next as virtual address instead of page frame number

Instead of converting adjust_next between bytes and pages number, let's
just store the virtual address into adjust_next.

Also, this patch fixes one typo in the comment of vma_adjust_trans_huge().

[vbabka@suse.cz: changelog tweak]
Signed-off-by: default avatarWei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Link: http://lkml.kernel.org/r/20200828081031.11306-1-richard.weiyang@linux.alibaba.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a08d93e5
...@@ -2306,13 +2306,13 @@ void vma_adjust_trans_huge(struct vm_area_struct *vma, ...@@ -2306,13 +2306,13 @@ void vma_adjust_trans_huge(struct vm_area_struct *vma,
/* /*
* If we're also updating the vma->vm_next->vm_start, if the new * If we're also updating the vma->vm_next->vm_start, if the new
* vm_next->vm_start isn't page aligned and it could previously * vm_next->vm_start isn't hpage aligned and it could previously
* contain an hugepage: check if we need to split an huge pmd. * contain an hugepage: check if we need to split an huge pmd.
*/ */
if (adjust_next > 0) { if (adjust_next > 0) {
struct vm_area_struct *next = vma->vm_next; struct vm_area_struct *next = vma->vm_next;
unsigned long nstart = next->vm_start; unsigned long nstart = next->vm_start;
nstart += adjust_next << PAGE_SHIFT; nstart += adjust_next;
if (nstart & ~HPAGE_PMD_MASK && if (nstart & ~HPAGE_PMD_MASK &&
(nstart & HPAGE_PMD_MASK) >= next->vm_start && (nstart & HPAGE_PMD_MASK) >= next->vm_start &&
(nstart & HPAGE_PMD_MASK) + HPAGE_PMD_SIZE <= next->vm_end) (nstart & HPAGE_PMD_MASK) + HPAGE_PMD_SIZE <= next->vm_end)
......
...@@ -758,7 +758,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, ...@@ -758,7 +758,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
* vma expands, overlapping part of the next: * vma expands, overlapping part of the next:
* mprotect case 5 shifting the boundary up. * mprotect case 5 shifting the boundary up.
*/ */
adjust_next = (end - next->vm_start) >> PAGE_SHIFT; adjust_next = (end - next->vm_start);
exporter = next; exporter = next;
importer = vma; importer = vma;
VM_WARN_ON(expand != importer); VM_WARN_ON(expand != importer);
...@@ -768,7 +768,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, ...@@ -768,7 +768,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
* split_vma inserting another: so it must be * split_vma inserting another: so it must be
* mprotect case 4 shifting the boundary down. * mprotect case 4 shifting the boundary down.
*/ */
adjust_next = -((vma->vm_end - end) >> PAGE_SHIFT); adjust_next = -(vma->vm_end - end);
exporter = vma; exporter = vma;
importer = next; importer = next;
VM_WARN_ON(expand != importer); VM_WARN_ON(expand != importer);
...@@ -840,8 +840,8 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, ...@@ -840,8 +840,8 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
} }
vma->vm_pgoff = pgoff; vma->vm_pgoff = pgoff;
if (adjust_next) { if (adjust_next) {
next->vm_start += adjust_next << PAGE_SHIFT; next->vm_start += adjust_next;
next->vm_pgoff += adjust_next; next->vm_pgoff += adjust_next >> PAGE_SHIFT;
} }
if (root) { if (root) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment