thp: madvise(MADV_HUGEPAGE)
[linux-2.6.git] / mm / huge_memory.c
index 7635079..620891f 100644 (file)
@@ -896,6 +896,22 @@ out:
        return ret;
 }
 
+int hugepage_madvise(unsigned long *vm_flags)
+{
+       /*
+        * Be somewhat over-protective like KSM for now!
+        */
+       if (*vm_flags & (VM_HUGEPAGE | VM_SHARED  | VM_MAYSHARE   |
+                        VM_PFNMAP   | VM_IO      | VM_DONTEXPAND |
+                        VM_RESERVED | VM_HUGETLB | VM_INSERTPAGE |
+                        VM_MIXEDMAP | VM_SAO))
+               return -EINVAL;
+
+       *vm_flags |= VM_HUGEPAGE;
+
+       return 0;
+}
+
 void __split_huge_page_pmd(struct mm_struct *mm, pmd_t *pmd)
 {
        struct page *page;