diff options
author | Eric B Munson <ebmunson@us.ibm.com> | 2009-09-21 20:03:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-22 10:17:41 -0400 |
commit | 6bfde05bf5c9682e255c6a2c669dc80f91af6296 (patch) | |
tree | 3ff62bb87fc12c1ce808a54f789c42c35be7c049 /include/linux/hugetlb.h | |
parent | f8dbf0a7a4c5d98e8b70da9f7f4f6a89f3b7a7bb (diff) |
hugetlbfs: allow the creation of files suitable for MAP_PRIVATE on the vfs internal mount
This patchset adds a flag to mmap that allows the user to request that an
anonymous mapping be backed with huge pages. This mapping will borrow
functionality from the huge page shm code to create a file on the kernel
internal mount and use it to approximate an anonymous mapping. The
MAP_HUGETLB flag is a modifier to MAP_ANONYMOUS and will not work without
both flags being preset.
A new flag is necessary because there is no other way to hook into huge
pages without creating a file on a hugetlbfs mount which wouldn't be
MAP_ANONYMOUS.
To userspace, this mapping will behave just like an anonymous mapping
because the file is not accessible outside of the kernel.
This patchset is meant to simplify the programming model. Presently there
is a large chunk of boiler platecode, contained in libhugetlbfs, required
to create private, hugepage backed mappings. This patch set would allow
use of hugepages without linking to libhugetlbfs or having hugetblfs
mounted.
Unification of the VM code would provide these same benefits, but it has
been resisted each time that it has been suggested for several reasons: it
would break PAGE_SIZE assumptions across the kernel, it makes page-table
abstractions really expensive, and it does not provide any benefit on
architectures that do not support huge pages, incurring fast path
penalties without providing any benefit on these architectures.
This patch:
There are two means of creating mappings backed by huge pages:
1. mmap() a file created on hugetlbfs
2. Use shm which creates a file on an internal mount which essentially
maps it MAP_SHARED
The internal mount is only used for shared mappings but there is very
little that stops it being used for private mappings. This patch extends
hugetlbfs_file_setup() to deal with the creation of files that will be
mapped MAP_PRIVATE on the internal hugetlbfs mount. This extended API is
used in a subsequent patch to implement the MAP_HUGETLB mmap() flag.
Signed-off-by: Eric Munson <ebmunson@us.ibm.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Adam Litke <agl@us.ibm.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/hugetlb.h')
-rw-r--r-- | include/linux/hugetlb.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index e7f0fabfa1c2..f6505ad86657 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h | |||
@@ -112,6 +112,14 @@ 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 | enum { | ||
116 | /* | ||
117 | * The file will be used as an shm file so shmfs accounting rules | ||
118 | * apply | ||
119 | */ | ||
120 | HUGETLB_SHMFS_INODE = 1, | ||
121 | }; | ||
122 | |||
115 | #ifdef CONFIG_HUGETLBFS | 123 | #ifdef CONFIG_HUGETLBFS |
116 | struct hugetlbfs_config { | 124 | struct hugetlbfs_config { |
117 | uid_t uid; | 125 | uid_t uid; |
@@ -150,7 +158,7 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb) | |||
150 | extern const struct file_operations hugetlbfs_file_operations; | 158 | extern const struct file_operations hugetlbfs_file_operations; |
151 | extern struct vm_operations_struct hugetlb_vm_ops; | 159 | extern struct vm_operations_struct hugetlb_vm_ops; |
152 | struct file *hugetlb_file_setup(const char *name, size_t size, int acct, | 160 | struct file *hugetlb_file_setup(const char *name, size_t size, int acct, |
153 | struct user_struct **user); | 161 | struct user_struct **user, int creat_flags); |
154 | int hugetlb_get_quota(struct address_space *mapping, long delta); | 162 | int hugetlb_get_quota(struct address_space *mapping, long delta); |
155 | void hugetlb_put_quota(struct address_space *mapping, long delta); | 163 | void hugetlb_put_quota(struct address_space *mapping, long delta); |
156 | 164 | ||
@@ -172,7 +180,7 @@ static inline void set_file_hugepages(struct file *file) | |||
172 | 180 | ||
173 | #define is_file_hugepages(file) 0 | 181 | #define is_file_hugepages(file) 0 |
174 | #define set_file_hugepages(file) BUG() | 182 | #define set_file_hugepages(file) BUG() |
175 | #define hugetlb_file_setup(name,size,acct,user) ERR_PTR(-ENOSYS) | 183 | #define hugetlb_file_setup(name,size,acct,user,creat) ERR_PTR(-ENOSYS) |
176 | 184 | ||
177 | #endif /* !CONFIG_HUGETLBFS */ | 185 | #endif /* !CONFIG_HUGETLBFS */ |
178 | 186 | ||