Skip to content

Commit

Permalink
mm, fs: reduce fault, page_mkwrite, and pfn_mkwrite to take only vmf
Browse files Browse the repository at this point in the history
->fault(), ->page_mkwrite(), and ->pfn_mkwrite() calls do not need to
take a vma and vmf parameter when the vma already resides in vmf.

Remove the vma parameter to simplify things.

[[email protected]: fix ARM build]
  Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/148521301778.19116.10840599906674778980.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Dave Jiang <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
Reviewed-by: Ross Zwisler <[email protected]>
Cc: Theodore Ts'o <[email protected]>
Cc: Darrick J. Wong <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: Dan Williams <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
davejiang authored and torvalds committed Feb 25, 2017
1 parent 374ad05 commit 11bac80
Show file tree
Hide file tree
Showing 87 changed files with 283 additions and 290 deletions.
4 changes: 2 additions & 2 deletions arch/powerpc/kvm/book3s_64_vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ static void release_spapr_tce_table(struct rcu_head *head)
kfree(stt);
}

static int kvm_spapr_tce_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int kvm_spapr_tce_fault(struct vm_fault *vmf)
{
struct kvmppc_spapr_tce_table *stt = vma->vm_file->private_data;
struct kvmppc_spapr_tce_table *stt = vmf->vma->vm_file->private_data;
struct page *page;

if (vmf->pgoff >= kvmppc_tce_pages(stt->size))
Expand Down
39 changes: 19 additions & 20 deletions arch/powerpc/platforms/cell/spufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ spufs_mem_write(struct file *file, const char __user *buffer,
}

static int
spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
spufs_mem_mmap_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct spu_context *ctx = vma->vm_file->private_data;
unsigned long pfn, offset;

Expand Down Expand Up @@ -311,12 +312,11 @@ static const struct file_operations spufs_mem_fops = {
.mmap = spufs_mem_mmap,
};

static int spufs_ps_fault(struct vm_area_struct *vma,
struct vm_fault *vmf,
static int spufs_ps_fault(struct vm_fault *vmf,
unsigned long ps_offs,
unsigned long ps_size)
{
struct spu_context *ctx = vma->vm_file->private_data;
struct spu_context *ctx = vmf->vma->vm_file->private_data;
unsigned long area, offset = vmf->pgoff << PAGE_SHIFT;
int ret = 0;

Expand Down Expand Up @@ -354,7 +354,7 @@ static int spufs_ps_fault(struct vm_area_struct *vma,
down_read(&current->mm->mmap_sem);
} else {
area = ctx->spu->problem_phys + ps_offs;
vm_insert_pfn(vma, vmf->address, (area + offset) >> PAGE_SHIFT);
vm_insert_pfn(vmf->vma, vmf->address, (area + offset) >> PAGE_SHIFT);
spu_context_trace(spufs_ps_fault__insert, ctx, ctx->spu);
}

Expand All @@ -367,10 +367,9 @@ static int spufs_ps_fault(struct vm_area_struct *vma,
}

#if SPUFS_MMAP_4K
static int spufs_cntl_mmap_fault(struct vm_area_struct *vma,
struct vm_fault *vmf)
static int spufs_cntl_mmap_fault(struct vm_fault *vmf)
{
return spufs_ps_fault(vma, vmf, 0x4000, SPUFS_CNTL_MAP_SIZE);
return spufs_ps_fault(vmf, 0x4000, SPUFS_CNTL_MAP_SIZE);
}

static const struct vm_operations_struct spufs_cntl_mmap_vmops = {
Expand Down Expand Up @@ -1067,15 +1066,15 @@ static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
}

static int
spufs_signal1_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
spufs_signal1_mmap_fault(struct vm_fault *vmf)
{
#if SPUFS_SIGNAL_MAP_SIZE == 0x1000
return spufs_ps_fault(vma, vmf, 0x14000, SPUFS_SIGNAL_MAP_SIZE);
return spufs_ps_fault(vmf, 0x14000, SPUFS_SIGNAL_MAP_SIZE);
#elif SPUFS_SIGNAL_MAP_SIZE == 0x10000
/* For 64k pages, both signal1 and signal2 can be used to mmap the whole
* signal 1 and 2 area
*/
return spufs_ps_fault(vma, vmf, 0x10000, SPUFS_SIGNAL_MAP_SIZE);
return spufs_ps_fault(vmf, 0x10000, SPUFS_SIGNAL_MAP_SIZE);
#else
#error unsupported page size
#endif
Expand Down Expand Up @@ -1205,15 +1204,15 @@ static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,

#if SPUFS_MMAP_4K
static int
spufs_signal2_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
spufs_signal2_mmap_fault(struct vm_fault *vmf)
{
#if SPUFS_SIGNAL_MAP_SIZE == 0x1000
return spufs_ps_fault(vma, vmf, 0x1c000, SPUFS_SIGNAL_MAP_SIZE);
return spufs_ps_fault(vmf, 0x1c000, SPUFS_SIGNAL_MAP_SIZE);
#elif SPUFS_SIGNAL_MAP_SIZE == 0x10000
/* For 64k pages, both signal1 and signal2 can be used to mmap the whole
* signal 1 and 2 area
*/
return spufs_ps_fault(vma, vmf, 0x10000, SPUFS_SIGNAL_MAP_SIZE);
return spufs_ps_fault(vmf, 0x10000, SPUFS_SIGNAL_MAP_SIZE);
#else
#error unsupported page size
#endif
Expand Down Expand Up @@ -1334,9 +1333,9 @@ DEFINE_SPUFS_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,

#if SPUFS_MMAP_4K
static int
spufs_mss_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
spufs_mss_mmap_fault(struct vm_fault *vmf)
{
return spufs_ps_fault(vma, vmf, 0x0000, SPUFS_MSS_MAP_SIZE);
return spufs_ps_fault(vmf, 0x0000, SPUFS_MSS_MAP_SIZE);
}

static const struct vm_operations_struct spufs_mss_mmap_vmops = {
Expand Down Expand Up @@ -1396,9 +1395,9 @@ static const struct file_operations spufs_mss_fops = {
};

static int
spufs_psmap_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
spufs_psmap_mmap_fault(struct vm_fault *vmf)
{
return spufs_ps_fault(vma, vmf, 0x0000, SPUFS_PS_MAP_SIZE);
return spufs_ps_fault(vmf, 0x0000, SPUFS_PS_MAP_SIZE);
}

static const struct vm_operations_struct spufs_psmap_mmap_vmops = {
Expand Down Expand Up @@ -1456,9 +1455,9 @@ static const struct file_operations spufs_psmap_fops = {

#if SPUFS_MMAP_4K
static int
spufs_mfc_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
spufs_mfc_mmap_fault(struct vm_fault *vmf)
{
return spufs_ps_fault(vma, vmf, 0x3000, SPUFS_MFC_MAP_SIZE);
return spufs_ps_fault(vmf, 0x3000, SPUFS_MFC_MAP_SIZE);
}

static const struct vm_operations_struct spufs_mfc_mmap_vmops = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -3342,7 +3342,7 @@ static void binder_vma_close(struct vm_area_struct *vma)
binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES);
}

static int binder_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int binder_vm_fault(struct vm_fault *vmf)
{
return VM_FAULT_SIGBUS;
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/char/agp/alpha-agp.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@

#include "agp.h"

static int alpha_core_agp_vm_fault(struct vm_area_struct *vma,
struct vm_fault *vmf)
static int alpha_core_agp_vm_fault(struct vm_fault *vmf)
{
alpha_agp_info *agp = agp_bridge->dev_private_data;
dma_addr_t dma_addr;
unsigned long pa;
struct page *page;

dma_addr = vmf->address - vma->vm_start + agp->aperture.bus_base;
dma_addr = vmf->address - vmf->vma->vm_start + agp->aperture.bus_base;
pa = agp->ops->translate(agp, dma_addr);

if (pa == (unsigned long)-EINVAL)
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/mspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ mspec_close(struct vm_area_struct *vma)
* Creates a mspec page and maps it to user space.
*/
static int
mspec_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
mspec_fault(struct vm_fault *vmf)
{
unsigned long paddr, maddr;
unsigned long pfn;
pgoff_t index = vmf->pgoff;
struct vma_data *vdata = vma->vm_private_data;
struct vma_data *vdata = vmf->vma->vm_private_data;

maddr = (volatile unsigned long) vdata->maddr[index];
if (maddr == 0) {
Expand Down Expand Up @@ -227,7 +227,7 @@ mspec_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
* be because another thread has installed the pte first, so it
* is no problem.
*/
vm_insert_pfn(vma, vmf->address, pfn);
vm_insert_pfn(vmf->vma, vmf->address, pfn);

return VM_FAULT_NOPAGE;
}
Expand Down
12 changes: 6 additions & 6 deletions drivers/dax/dax.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,16 +419,15 @@ static phys_addr_t pgoff_to_phys(struct dax_dev *dax_dev, pgoff_t pgoff,
return -1;
}

static int __dax_dev_fault(struct dax_dev *dax_dev, struct vm_area_struct *vma,
struct vm_fault *vmf)
static int __dax_dev_fault(struct dax_dev *dax_dev, struct vm_fault *vmf)
{
struct device *dev = &dax_dev->dev;
struct dax_region *dax_region;
int rc = VM_FAULT_SIGBUS;
phys_addr_t phys;
pfn_t pfn;

if (check_vma(dax_dev, vma, __func__))
if (check_vma(dax_dev, vmf->vma, __func__))
return VM_FAULT_SIGBUS;

dax_region = dax_dev->region;
Expand All @@ -446,7 +445,7 @@ static int __dax_dev_fault(struct dax_dev *dax_dev, struct vm_area_struct *vma,

pfn = phys_to_pfn_t(phys, dax_region->pfn_flags);

rc = vm_insert_mixed(vma, vmf->address, pfn);
rc = vm_insert_mixed(vmf->vma, vmf->address, pfn);

if (rc == -ENOMEM)
return VM_FAULT_OOM;
Expand All @@ -456,8 +455,9 @@ static int __dax_dev_fault(struct dax_dev *dax_dev, struct vm_area_struct *vma,
return VM_FAULT_NOPAGE;
}

static int dax_dev_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int dax_dev_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
int rc;
struct file *filp = vma->vm_file;
struct dax_dev *dax_dev = filp->private_data;
Expand All @@ -466,7 +466,7 @@ static int dax_dev_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
current->comm, (vmf->flags & FAULT_FLAG_WRITE)
? "write" : "read", vma->vm_start, vma->vm_end);
rcu_read_lock();
rc = __dax_dev_fault(dax_dev, vma, vmf);
rc = __dax_dev_fault(dax_dev, vmf);
rcu_read_unlock();

return rc;
Expand Down
9 changes: 5 additions & 4 deletions drivers/gpu/drm/armada/armada_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
#include <drm/armada_drm.h>
#include "armada_ioctlP.h"

static int armada_gem_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int armada_gem_vm_fault(struct vm_fault *vmf)
{
struct armada_gem_object *obj = drm_to_armada_gem(vma->vm_private_data);
struct drm_gem_object *gobj = vmf->vma->vm_private_data;
struct armada_gem_object *obj = drm_to_armada_gem(gobj);
unsigned long pfn = obj->phys_addr >> PAGE_SHIFT;
int ret;

pfn += (vmf->address - vma->vm_start) >> PAGE_SHIFT;
ret = vm_insert_pfn(vma, vmf->address, pfn);
pfn += (vmf->address - vmf->vma->vm_start) >> PAGE_SHIFT;
ret = vm_insert_pfn(vmf->vma, vmf->address, pfn);

switch (ret) {
case 0:
Expand Down
32 changes: 17 additions & 15 deletions drivers/gpu/drm/drm_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ static pgprot_t drm_dma_prot(uint32_t map_type, struct vm_area_struct *vma)
* map, get the page, increment the use count and return it.
*/
#if IS_ENABLED(CONFIG_AGP)
static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int drm_do_vm_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct drm_file *priv = vma->vm_file->private_data;
struct drm_device *dev = priv->minor->dev;
struct drm_local_map *map = NULL;
Expand Down Expand Up @@ -168,7 +169,7 @@ static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
return VM_FAULT_SIGBUS; /* Disallow mremap */
}
#else
static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int drm_do_vm_fault(struct vm_fault *vmf)
{
return VM_FAULT_SIGBUS;
}
Expand All @@ -184,8 +185,9 @@ static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
* Get the mapping, find the real physical page to map, get the page, and
* return it.
*/
static int drm_do_vm_shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int drm_do_vm_shm_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct drm_local_map *map = vma->vm_private_data;
unsigned long offset;
unsigned long i;
Expand Down Expand Up @@ -280,14 +282,14 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
/**
* \c fault method for DMA virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \return pointer to the page structure.
*
* Determine the page number from the page offset and get it from drm_device_dma::pagelist.
*/
static int drm_do_vm_dma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int drm_do_vm_dma_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct drm_file *priv = vma->vm_file->private_data;
struct drm_device *dev = priv->minor->dev;
struct drm_device_dma *dma = dev->dma;
Expand Down Expand Up @@ -315,14 +317,14 @@ static int drm_do_vm_dma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
/**
* \c fault method for scatter-gather virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \return pointer to the page structure.
*
* Determine the map offset from the page offset and get it from drm_sg_mem::pagelist.
*/
static int drm_do_vm_sg_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int drm_do_vm_sg_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct drm_local_map *map = vma->vm_private_data;
struct drm_file *priv = vma->vm_file->private_data;
struct drm_device *dev = priv->minor->dev;
Expand All @@ -347,24 +349,24 @@ static int drm_do_vm_sg_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
return 0;
}

static int drm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int drm_vm_fault(struct vm_fault *vmf)
{
return drm_do_vm_fault(vma, vmf);
return drm_do_vm_fault(vmf);
}

static int drm_vm_shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int drm_vm_shm_fault(struct vm_fault *vmf)
{
return drm_do_vm_shm_fault(vma, vmf);
return drm_do_vm_shm_fault(vmf);
}

static int drm_vm_dma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int drm_vm_dma_fault(struct vm_fault *vmf)
{
return drm_do_vm_dma_fault(vma, vmf);
return drm_do_vm_dma_fault(vmf);
}

static int drm_vm_sg_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
static int drm_vm_sg_fault(struct vm_fault *vmf)
{
return drm_do_vm_sg_fault(vma, vmf);
return drm_do_vm_sg_fault(vmf);
}

/** AGP virtual memory operations */
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/etnaviv/etnaviv_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
struct drm_file *file);

int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma);
int etnaviv_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
int etnaviv_gem_fault(struct vm_fault *vmf);
int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset);
struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj);
void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj);
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/etnaviv/etnaviv_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma)
return obj->ops->mmap(obj, vma);
}

int etnaviv_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
int etnaviv_gem_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct drm_gem_object *obj = vma->vm_private_data;
struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
struct page **pages, *page;
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/exynos/exynos_drm_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,9 @@ int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv,
return ret;
}

int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
int exynos_drm_gem_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct drm_gem_object *obj = vma->vm_private_data;
struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj);
unsigned long pfn;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/exynos/exynos_drm_gem.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv,
uint64_t *offset);

/* page fault handler and mmap fault address(virtual) to physical memory. */
int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
int exynos_drm_gem_fault(struct vm_fault *vmf);

/* set vm_flags and we can change the vm attribute to other one at here. */
int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
Expand Down
Loading

0 comments on commit 11bac80

Please sign in to comment.