aboutsummaryrefslogtreecommitdiffstats
path: root/mm/huge_memory.c
diff options
context:
space:
mode:
authorAndrea Arcangeli <aarcange@redhat.com>2011-01-13 18:47:17 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 20:32:47 -0500
commita664b2d8555c659127bf8fe049a58449d394a707 (patch)
tree14771f4ab93a9dda98174f21e0361a77e2aebfa6 /mm/huge_memory.c
parent1ddd6db43a08cba56c7ee920800980862086f1c3 (diff)
thp: madvise(MADV_NOHUGEPAGE)
Add madvise MADV_NOHUGEPAGE to mark regions that are not important to be hugepage backed. Return -EINVAL if the vma is not of an anonymous type, or the feature isn't built into the kernel. Never silently return success. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/huge_memory.c')
-rw-r--r--mm/huge_memory.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f4f6041176a4..fce667c0281d 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -16,6 +16,7 @@
16#include <linux/kthread.h> 16#include <linux/kthread.h>
17#include <linux/khugepaged.h> 17#include <linux/khugepaged.h>
18#include <linux/freezer.h> 18#include <linux/freezer.h>
19#include <linux/mman.h>
19#include <asm/tlb.h> 20#include <asm/tlb.h>
20#include <asm/pgalloc.h> 21#include <asm/pgalloc.h>
21#include "internal.h" 22#include "internal.h"
@@ -1388,18 +1389,36 @@ out:
1388 return ret; 1389 return ret;
1389} 1390}
1390 1391
1391int hugepage_madvise(unsigned long *vm_flags) 1392int hugepage_madvise(unsigned long *vm_flags, int advice)
1392{ 1393{
1393 /* 1394 switch (advice) {
1394 * Be somewhat over-protective like KSM for now! 1395 case MADV_HUGEPAGE:
1395 */ 1396 /*
1396 if (*vm_flags & (VM_HUGEPAGE | VM_SHARED | VM_MAYSHARE | 1397 * Be somewhat over-protective like KSM for now!
1397 VM_PFNMAP | VM_IO | VM_DONTEXPAND | 1398 */
1398 VM_RESERVED | VM_HUGETLB | VM_INSERTPAGE | 1399 if (*vm_flags & (VM_HUGEPAGE |
1399 VM_MIXEDMAP | VM_SAO)) 1400 VM_SHARED | VM_MAYSHARE |
1400 return -EINVAL; 1401 VM_PFNMAP | VM_IO | VM_DONTEXPAND |
1401 1402 VM_RESERVED | VM_HUGETLB | VM_INSERTPAGE |
1402 *vm_flags |= VM_HUGEPAGE; 1403 VM_MIXEDMAP | VM_SAO))
1404 return -EINVAL;
1405 *vm_flags &= ~VM_NOHUGEPAGE;
1406 *vm_flags |= VM_HUGEPAGE;
1407 break;
1408 case MADV_NOHUGEPAGE:
1409 /*
1410 * Be somewhat over-protective like KSM for now!
1411 */
1412 if (*vm_flags & (VM_NOHUGEPAGE |
1413 VM_SHARED | VM_MAYSHARE |
1414 VM_PFNMAP | VM_IO | VM_DONTEXPAND |
1415 VM_RESERVED | VM_HUGETLB | VM_INSERTPAGE |
1416 VM_MIXEDMAP | VM_SAO))
1417 return -EINVAL;
1418 *vm_flags &= ~VM_HUGEPAGE;
1419 *vm_flags |= VM_NOHUGEPAGE;
1420 break;
1421 }
1403 1422
1404 return 0; 1423 return 0;
1405} 1424}