[RFC PATCH 1/3] mm/map_contig: Add VM_CONTIG flag to vma struct

From: Mike Kravetz
Date: Wed Oct 11 2017 - 21:47:15 EST


Add the flag VM_CONTIG to vma structure to identify vmas which are
backed by contiguous memory allocations. This flag is not propogated
to child processes, so be sure to clear at fork time.

Signed-off-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
---
include/linux/mm.h | 1 +
kernel/fork.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 065d99deb847..db82f172fbd1 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -189,6 +189,7 @@ extern unsigned int kobjsize(const void *objp);
#define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
#define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
+#define VM_CONTIG 0x00800000 /* Contiguous page backing */
#define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
#define VM_WIPEONFORK 0x02000000 /* Wipe VMA contents in child. */
#define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
diff --git a/kernel/fork.c b/kernel/fork.c
index e702cb9ffbd8..d93b022e4909 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -665,7 +665,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
goto fail_nomem_anon_vma_fork;
} else if (anon_vma_fork(tmp, mpnt))
goto fail_nomem_anon_vma_fork;
- tmp->vm_flags &= ~(VM_LOCKED | VM_LOCKONFAULT);
+ tmp->vm_flags &= ~(VM_LOCKED | VM_LOCKONFAULT | VM_CONTIG);
tmp->vm_next = tmp->vm_prev = NULL;
file = tmp->vm_file;
if (file) {
--
2.13.6