mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
mm: new arch_remap() hook
Some architectures would like to be triggered when a memory area is moved through the mremap system call. This patch introduces a new arch_remap() mm hook which is placed in the path of mremap, and is called before the old area is unmapped (and the arch_unmap() hook is called). Signed-off-by: Laurent Dufour <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Pavel Emelyanov <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Ingo Molnar <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
2ae416b142
commit
4abad2ca4a
2 changed files with 20 additions and 6 deletions
17
mm/mremap.c
17
mm/mremap.c
|
|
@ -22,6 +22,7 @@
|
|||
#include <linux/mmu_notifier.h>
|
||||
#include <linux/sched/sysctl.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/mm-arch-hooks.h>
|
||||
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/tlbflush.h>
|
||||
|
|
@ -286,13 +287,17 @@ static unsigned long move_vma(struct vm_area_struct *vma,
|
|||
old_len = new_len;
|
||||
old_addr = new_addr;
|
||||
new_addr = -ENOMEM;
|
||||
} else if (vma->vm_file && vma->vm_file->f_op->mremap) {
|
||||
err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
|
||||
if (err < 0) {
|
||||
move_page_tables(new_vma, new_addr, vma, old_addr,
|
||||
moved_len, true);
|
||||
return err;
|
||||
} else {
|
||||
if (vma->vm_file && vma->vm_file->f_op->mremap) {
|
||||
err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
|
||||
if (err < 0) {
|
||||
move_page_tables(new_vma, new_addr, vma,
|
||||
old_addr, moved_len, true);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
arch_remap(mm, old_addr, old_addr + old_len,
|
||||
new_addr, new_addr + new_len);
|
||||
}
|
||||
|
||||
/* Conceal VM_ACCOUNT so old reservation is not undone */
|
||||
|
|
|
|||
Loading…
Reference in a new issue