mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
mm: kill vma flag VM_CAN_NONLINEAR
Move actual pte filling for non-linear file mappings into the new special vma operation: ->remap_pages(). Filesystems must implement this method to get non-linear mapping support, if it uses filemap_fault() then generic_file_remap_pages() can be used. Now device drivers can implement this method and obtain nonlinear vma support. Change-Id: Ifbbbdfcdf871a8173856a13087400885357f95ee Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Carsten Otte <cotte@de.ibm.com> Cc: Chris Metcalf <cmetcalf@tilera.com> #arch/tile Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Eric Paris <eparis@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Hugh Dickins <hughd@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Morris <james.l.morris@oracle.com> Cc: Jason Baron <jbaron@redhat.com> Cc: Kentaro Takeda <takedakn@nttdata.co.jp> Cc: Matt Helsley <matthltc@us.ibm.com> Cc: Nick Piggin <npiggin@kernel.dk> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Robert Richter <robert.richter@amd.com> Cc: Suresh Siddha <suresh.b.siddha@intel.com> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Venkatesh Pallipadi <venki@google.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
5063bb6474
commit
7c58c4e397
23 changed files with 40 additions and 24 deletions
|
@ -338,7 +338,6 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
|
|||
fput(vma->vm_file);
|
||||
vma->vm_file = asma->file;
|
||||
}
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
asma->vm_start = vma->vm_start;
|
||||
|
||||
out:
|
||||
|
|
|
@ -735,6 +735,7 @@ v9fs_cached_file_write(struct file *filp, const char __user * data,
|
|||
static const struct vm_operations_struct v9fs_file_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = v9fs_vm_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1581,6 +1581,7 @@ out:
|
|||
static const struct vm_operations_struct btrfs_file_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = btrfs_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
static int btrfs_file_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||
|
@ -1592,7 +1593,6 @@ static int btrfs_file_mmap(struct file *filp, struct vm_area_struct *vma)
|
|||
|
||||
file_accessed(filp);
|
||||
vma->vm_ops = &btrfs_file_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1234,6 +1234,7 @@ out:
|
|||
static struct vm_operations_struct ceph_vmops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = ceph_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
int ceph_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
|
@ -1244,6 +1245,5 @@ int ceph_mmap(struct file *file, struct vm_area_struct *vma)
|
|||
return -ENOEXEC;
|
||||
file_accessed(file);
|
||||
vma->vm_ops = &ceph_vmops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2611,6 +2611,7 @@ cifs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
|
|||
static struct vm_operations_struct cifs_file_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = cifs_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
|
|
|
@ -144,6 +144,7 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
|
|||
static const struct vm_operations_struct ext4_file_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = ext4_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
|
@ -154,7 +155,6 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
|
|||
return -ENOEXEC;
|
||||
file_accessed(file);
|
||||
vma->vm_ops = &ext4_file_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1421,6 +1421,7 @@ static const struct vm_operations_struct fuse_file_vm_ops = {
|
|||
.close = fuse_vma_close,
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = fuse_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
|
|
|
@ -469,6 +469,7 @@ out:
|
|||
static const struct vm_operations_struct gfs2_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = gfs2_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -503,7 +504,6 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma)
|
|||
return error;
|
||||
}
|
||||
vma->vm_ops = &gfs2_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -553,6 +553,7 @@ out:
|
|||
static const struct vm_operations_struct nfs_file_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = nfs_vm_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
static int nfs_need_sync_write(struct file *filp, struct inode *inode)
|
||||
|
|
|
@ -126,13 +126,13 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
|
|||
static const struct vm_operations_struct nilfs_file_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = nilfs_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
static int nilfs_file_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
{
|
||||
file_accessed(file);
|
||||
vma->vm_ops = &nilfs_file_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,7 @@ out:
|
|||
static const struct vm_operations_struct ocfs2_file_vm_ops = {
|
||||
.fault = ocfs2_fault,
|
||||
.page_mkwrite = ocfs2_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
|
@ -186,7 +187,6 @@ int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
|
|||
ocfs2_inode_unlock(file->f_dentry->d_inode, lock_level);
|
||||
out:
|
||||
vma->vm_ops = &ocfs2_file_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,6 @@ static int sdcardfs_mmap(struct file *file, struct vm_area_struct *vma)
|
|||
*/
|
||||
file_accessed(file);
|
||||
vma->vm_ops = &sdcardfs_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
|
||||
file->f_mapping->a_ops = &sdcardfs_aops; /* set our aops */
|
||||
if (!SDCARDFS_F(file)->lower_vm_ops) /* save for our ->fault */
|
||||
|
|
|
@ -85,6 +85,7 @@ const struct address_space_operations sdcardfs_aops = {
|
|||
const struct vm_operations_struct sdcardfs_vm_ops = {
|
||||
.fault = sdcardfs_fault,
|
||||
.page_mkwrite = sdcardfs_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
.open = sdcardfs_vm_open,
|
||||
.close = sdcardfs_vm_close,
|
||||
};
|
||||
|
|
|
@ -1536,6 +1536,7 @@ out_unlock:
|
|||
static const struct vm_operations_struct ubifs_file_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = ubifs_vm_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
static int ubifs_file_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
|
|
|
@ -990,7 +990,6 @@ xfs_file_mmap(
|
|||
struct vm_area_struct *vma)
|
||||
{
|
||||
vma->vm_ops = &xfs_file_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
|
||||
file_accessed(filp);
|
||||
return 0;
|
||||
|
@ -1044,4 +1043,5 @@ const struct file_operations xfs_dir_file_operations = {
|
|||
static const struct vm_operations_struct xfs_file_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.page_mkwrite = xfs_vm_page_mkwrite,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
|
|
@ -2459,6 +2459,8 @@ extern int sb_min_blocksize(struct super_block *, int);
|
|||
|
||||
extern int generic_file_mmap(struct file *, struct vm_area_struct *);
|
||||
extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
|
||||
extern int generic_file_remap_pages(struct vm_area_struct *, unsigned long addr,
|
||||
unsigned long size, pgoff_t pgoff);
|
||||
extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
|
||||
int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk);
|
||||
extern ssize_t generic_file_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t);
|
||||
|
|
|
@ -128,7 +128,6 @@ extern unsigned int kobjsize(const void *objp);
|
|||
#define VM_INSERTPAGE 0x02000000 /* The vma has had "vm_insert_page()" done on it */
|
||||
#define VM_NODUMP 0x04000000 /* Do not include in the core dump */
|
||||
|
||||
#define VM_CAN_NONLINEAR 0x08000000 /* Has ->fault & does nonlinear pages */
|
||||
#define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
|
||||
#define VM_SAO 0x20000000 /* Strong Access Ordering (powerpc) */
|
||||
#define VM_PFN_AT_MMAP 0x40000000 /* PFNMAP vma that is fully mapped at mmap time */
|
||||
|
@ -196,8 +195,7 @@ static inline int is_pfn_mapping(struct vm_area_struct *vma)
|
|||
* of VM_FAULT_xxx flags that give details about how the fault was handled.
|
||||
*
|
||||
* pgoff should be used in favour of virtual_address, if possible. If pgoff
|
||||
* is used, one may set VM_CAN_NONLINEAR in the vma->vm_flags to get nonlinear
|
||||
* mapping support.
|
||||
* is used, one may implement ->remap_pages to get nonlinear mapping support.
|
||||
*/
|
||||
struct vm_fault {
|
||||
unsigned int flags; /* FAULT_FLAG_xxx flags */
|
||||
|
@ -255,6 +253,9 @@ struct vm_operations_struct {
|
|||
int (*migrate)(struct vm_area_struct *vma, const nodemask_t *from,
|
||||
const nodemask_t *to, unsigned long flags);
|
||||
#endif
|
||||
/* called by sys_remap_file_pages() to populate non-linear mapping */
|
||||
int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
|
||||
unsigned long size, pgoff_t pgoff);
|
||||
};
|
||||
|
||||
struct mmu_gather;
|
||||
|
|
|
@ -1753,6 +1753,7 @@ EXPORT_SYMBOL(filemap_fault);
|
|||
|
||||
const struct vm_operations_struct generic_file_vm_ops = {
|
||||
.fault = filemap_fault,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
/* This is used for a general mmap of a disk file */
|
||||
|
@ -1765,7 +1766,6 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
|
|||
return -ENOEXEC;
|
||||
file_accessed(file);
|
||||
vma->vm_ops = &generic_file_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -304,6 +304,7 @@ out:
|
|||
|
||||
static const struct vm_operations_struct xip_file_vm_ops = {
|
||||
.fault = xip_file_fault,
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
int xip_file_mmap(struct file * file, struct vm_area_struct * vma)
|
||||
|
@ -312,7 +313,7 @@ int xip_file_mmap(struct file * file, struct vm_area_struct * vma)
|
|||
|
||||
file_accessed(file);
|
||||
vma->vm_ops = &xip_file_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR | VM_MIXEDMAP;
|
||||
vma->vm_flags |= VM_MIXEDMAP;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(xip_file_mmap);
|
||||
|
|
14
mm/fremap.c
14
mm/fremap.c
|
@ -5,6 +5,7 @@
|
|||
*
|
||||
* started by Ingo Molnar, Copyright (C) 2002, 2003
|
||||
*/
|
||||
#include <linux/export.h>
|
||||
#include <linux/backing-dev.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/swap.h>
|
||||
|
@ -80,9 +81,10 @@ out:
|
|||
return err;
|
||||
}
|
||||
|
||||
static int populate_range(struct mm_struct *mm, struct vm_area_struct *vma,
|
||||
unsigned long addr, unsigned long size, pgoff_t pgoff)
|
||||
int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
|
||||
unsigned long size, pgoff_t pgoff)
|
||||
{
|
||||
struct mm_struct *mm = vma->vm_mm;
|
||||
int err;
|
||||
|
||||
do {
|
||||
|
@ -95,9 +97,9 @@ static int populate_range(struct mm_struct *mm, struct vm_area_struct *vma,
|
|||
pgoff++;
|
||||
} while (size);
|
||||
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(generic_file_remap_pages);
|
||||
|
||||
/**
|
||||
* sys_remap_file_pages - remap arbitrary pages of an existing VM_SHARED vma
|
||||
|
@ -167,7 +169,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
|
|||
if (vma->vm_private_data && !(vma->vm_flags & VM_NONLINEAR))
|
||||
goto out;
|
||||
|
||||
if (!(vma->vm_flags & VM_CAN_NONLINEAR))
|
||||
if (!vma->vm_ops->remap_pages)
|
||||
goto out;
|
||||
|
||||
if (start < vma->vm_start || start + size > vma->vm_end)
|
||||
|
@ -229,7 +231,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
|
|||
}
|
||||
|
||||
mmu_notifier_invalidate_range_start(mm, start, start + size);
|
||||
err = populate_range(mm, vma, start, size, pgoff);
|
||||
err = vma->vm_ops->remap_pages(vma, start, size, pgoff);
|
||||
mmu_notifier_invalidate_range_end(mm, start, start + size);
|
||||
if (!err && !(flags & MAP_NONBLOCK)) {
|
||||
if (vma->vm_flags & VM_LOCKED) {
|
||||
|
|
|
@ -698,8 +698,7 @@ static inline int is_mergeable_vma(struct vm_area_struct *vma,
|
|||
struct file *file, unsigned long vm_flags,
|
||||
const char __user *anon_name)
|
||||
{
|
||||
/* VM_CAN_NONLINEAR may get set later by f_op->mmap() */
|
||||
if ((vma->vm_flags ^ vm_flags) & ~VM_CAN_NONLINEAR)
|
||||
if (vma->vm_flags ^ vm_flags)
|
||||
return 0;
|
||||
if (vma->vm_file != file)
|
||||
return 0;
|
||||
|
|
|
@ -2002,6 +2002,14 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
|||
}
|
||||
EXPORT_SYMBOL(filemap_fault);
|
||||
|
||||
int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
|
||||
unsigned long size, pgoff_t pgoff)
|
||||
{
|
||||
BUG();
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(generic_file_remap_pages);
|
||||
|
||||
static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
|
||||
unsigned long addr, void *buf, int len, int write)
|
||||
{
|
||||
|
|
|
@ -1235,7 +1235,6 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
|
|||
{
|
||||
file_accessed(file);
|
||||
vma->vm_ops = &shmem_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2665,6 +2664,7 @@ static const struct vm_operations_struct shmem_vm_ops = {
|
|||
.set_policy = shmem_set_policy,
|
||||
.get_policy = shmem_get_policy,
|
||||
#endif
|
||||
.remap_pages = generic_file_remap_pages,
|
||||
};
|
||||
|
||||
static struct dentry *shmem_mount(struct file_system_type *fs_type,
|
||||
|
@ -2853,7 +2853,6 @@ void shmem_set_file(struct vm_area_struct *vma, struct file *file)
|
|||
fput(vma->vm_file);
|
||||
vma->vm_file = file;
|
||||
vma->vm_ops = &shmem_vm_ops;
|
||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue