aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/hugetlb.h7
-rw-r--r--mm/mmap.c18
2 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index f6505ad86657..176e7ee73eff 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -112,12 +112,19 @@ static inline void hugetlb_report_meminfo(struct seq_file *m)
112 112
113#endif /* !CONFIG_HUGETLB_PAGE */ 113#endif /* !CONFIG_HUGETLB_PAGE */
114 114
115#define HUGETLB_ANON_FILE "anon_hugepage"
116
115enum { 117enum {
116 /* 118 /*
117 * The file will be used as an shm file so shmfs accounting rules 119 * The file will be used as an shm file so shmfs accounting rules
118 * apply 120 * apply
119 */ 121 */
120 HUGETLB_SHMFS_INODE = 1, 122 HUGETLB_SHMFS_INODE = 1,
123 /*
124 * The file is being created on the internal vfs mount and shmfs
125 * accounting rules do not apply
126 */
127 HUGETLB_ANONHUGE_INODE = 2,
121}; 128};
122 129
123#ifdef CONFIG_HUGETLBFS 130#ifdef CONFIG_HUGETLBFS
diff --git a/mm/mmap.c b/mm/mmap.c
index 1aeef6625e6a..21d4029a07b3 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -949,6 +949,24 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
949 if (mm->map_count > sysctl_max_map_count) 949 if (mm->map_count > sysctl_max_map_count)
950 return -ENOMEM; 950 return -ENOMEM;
951 951
952 if (flags & MAP_HUGETLB) {
953 struct user_struct *user = NULL;
954 if (file)
955 return -EINVAL;
956
957 /*
958 * VM_NORESERVE is used because the reservations will be
959 * taken when vm_ops->mmap() is called
960 * A dummy user value is used because we are not locking
961 * memory so no accounting is necessary
962 */
963 len = ALIGN(len, huge_page_size(&default_hstate));
964 file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, VM_NORESERVE,
965 &user, HUGETLB_ANONHUGE_INODE);
966 if (IS_ERR(file))
967 return PTR_ERR(file);
968 }
969
952 /* Obtain the address to map to. we verify (or select) it and ensure 970 /* Obtain the address to map to. we verify (or select) it and ensure
953 * that it represents a valid section of the address space. 971 * that it represents a valid section of the address space.
954 */ 972 */