Merge branch 'akpm' (patches from Andrew)
Merge updates from Andrew Morton: - a few misc bits - ocfs2 - most(?) of MM * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (125 commits) thp: fix comments of __pmd_trans_huge_lock() cgroup: remove unnecessary 0 check from css_from_id() cgroup: fix idr leak for the first cgroup root mm: memcontrol: fix documentation for compound parameter mm: memcontrol: remove BUG_ON in uncharge_list mm: fix build warnings in <linux/compaction.h> mm, thp: convert from optimistic swapin collapsing to conservative mm, thp: fix comment inconsistency for swapin readahead functions thp: update Documentation/{vm/transhuge,filesystems/proc}.txt shmem: split huge pages beyond i_size under memory pressure thp: introduce CONFIG_TRANSPARENT_HUGE_PAGECACHE khugepaged: add support of collapse for tmpfs/shmem pages shmem: make shmem_inode_info::lock irq-safe khugepaged: move up_read(mmap_sem) out of khugepaged_alloc_page() thp: extract khugepaged from mm/huge_memory.c shmem, thp: respect MADV_{NO,}HUGEPAGE for file mappings shmem: add huge pages support shmem: get_unmapped_area align huge page shmem: prepare huge= mount option and sysfs knob mm, rmap: account shmem thp pages ...
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/backing-dev.h>
|
||||
#include <linux/shmem_fs.h>
|
||||
#include <linux/splice.h>
|
||||
#include <linux/pfn.h>
|
||||
#include <linux/export.h>
|
||||
@@ -657,6 +658,28 @@ static int mmap_zero(struct file *file, struct vm_area_struct *vma)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned long get_unmapped_area_zero(struct file *file,
|
||||
unsigned long addr, unsigned long len,
|
||||
unsigned long pgoff, unsigned long flags)
|
||||
{
|
||||
#ifdef CONFIG_MMU
|
||||
if (flags & MAP_SHARED) {
|
||||
/*
|
||||
* mmap_zero() will call shmem_zero_setup() to create a file,
|
||||
* so use shmem's get_unmapped_area in case it can be huge;
|
||||
* and pass NULL for file as in mmap.c's get_unmapped_area(),
|
||||
* so as not to confuse shmem with our handle on "/dev/zero".
|
||||
*/
|
||||
return shmem_get_unmapped_area(NULL, addr, len, pgoff, flags);
|
||||
}
|
||||
|
||||
/* Otherwise flags & MAP_PRIVATE: with no shmem object beneath it */
|
||||
return current->mm->get_unmapped_area(file, addr, len, pgoff, flags);
|
||||
#else
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
|
||||
static ssize_t write_full(struct file *file, const char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
@@ -764,6 +787,7 @@ static const struct file_operations zero_fops = {
|
||||
.read_iter = read_iter_zero,
|
||||
.write_iter = write_iter_zero,
|
||||
.mmap = mmap_zero,
|
||||
.get_unmapped_area = get_unmapped_area_zero,
|
||||
#ifndef CONFIG_MMU
|
||||
.mmap_capabilities = zero_mmap_capabilities,
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user