mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
hugetlb: add MAP_HUGETLB for mmaping pseudo-anonymous huge page regions
Add a flag for mmap that will be used to request a huge page region that will look like anonymous memory to userspace. This is accomplished by using a file on the internal vfsmount. MAP_HUGETLB is a modifier of MAP_ANONYMOUS and so must be specified with it. The region will behave the same as a MAP_ANONYMOUS region using small pages. [[email protected]: fix arch definitions of MAP_HUGETLB] Signed-off-by: Eric B Munson <[email protected]> Acked-by: David Rientjes <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Adam Litke <[email protected]> Cc: David Gibson <[email protected]> Cc: Lee Schermerhorn <[email protected]> Cc: Nick Piggin <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Arnd Bergmann <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
90f72aa58b
commit
4e52780d41
2 changed files with 25 additions and 0 deletions
18
mm/mmap.c
18
mm/mmap.c
|
|
@ -949,6 +949,24 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
|
|||
if (mm->map_count > sysctl_max_map_count)
|
||||
return -ENOMEM;
|
||||
|
||||
if (flags & MAP_HUGETLB) {
|
||||
struct user_struct *user = NULL;
|
||||
if (file)
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* VM_NORESERVE is used because the reservations will be
|
||||
* taken when vm_ops->mmap() is called
|
||||
* A dummy user value is used because we are not locking
|
||||
* memory so no accounting is necessary
|
||||
*/
|
||||
len = ALIGN(len, huge_page_size(&default_hstate));
|
||||
file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, VM_NORESERVE,
|
||||
&user, HUGETLB_ANONHUGE_INODE);
|
||||
if (IS_ERR(file))
|
||||
return PTR_ERR(file);
|
||||
}
|
||||
|
||||
/* Obtain the address to map to. we verify (or select) it and ensure
|
||||
* that it represents a valid section of the address space.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue