Commit 2b740303 authored by Souptick Joarder's avatar Souptick Joarder Committed by Linus Torvalds

mm: Change return type int to vm_fault_t for fault handlers

Use new return type vm_fault_t for fault handler.  For now, this is just
documenting that the function returns a VM_FAULT value rather than an
errno.  Once all instances are converted, vm_fault_t will become a
distinct type.

Ref-> commit 1c8f4220 ("mm: change return type to vm_fault_t")

The aim is to change the return type of finish_fault() and
handle_mm_fault() to vm_fault_t type.  As part of that clean up return
type of all other recursively called functions have been changed to
vm_fault_t type.

The places from where handle_mm_fault() is getting invoked will be
change to vm_fault_t type but in a separate patch.

vmf_error() is the newly introduce inline function in 4.17-rc6.

[akpm@linux-foundation.org: don't shadow outer local `ret' in __do_huge_pmd_anonymous_page()]
Link: http://lkml.kernel.org/r/20180604171727.GA20279@jordon-HP-15-Notebook-PCSigned-off-by: default avatarSouptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a99237af
...@@ -340,17 +340,15 @@ static inline bool userfaultfd_must_wait(struct userfaultfd_ctx *ctx, ...@@ -340,17 +340,15 @@ static inline bool userfaultfd_must_wait(struct userfaultfd_ctx *ctx,
* fatal_signal_pending()s, and the mmap_sem must be released before * fatal_signal_pending()s, and the mmap_sem must be released before
* returning it. * returning it.
*/ */
int handle_userfault(struct vm_fault *vmf, unsigned long reason) vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)
{ {
struct mm_struct *mm = vmf->vma->vm_mm; struct mm_struct *mm = vmf->vma->vm_mm;
struct userfaultfd_ctx *ctx; struct userfaultfd_ctx *ctx;
struct userfaultfd_wait_queue uwq; struct userfaultfd_wait_queue uwq;
int ret; vm_fault_t ret = VM_FAULT_SIGBUS;
bool must_wait, return_to_userland; bool must_wait, return_to_userland;
long blocking_state; long blocking_state;
ret = VM_FAULT_SIGBUS;
/* /*
* We don't do userfault handling for the final child pid update. * We don't do userfault handling for the final child pid update.
* *
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <linux/fs.h> /* only for vma_is_dax() */ #include <linux/fs.h> /* only for vma_is_dax() */
extern int do_huge_pmd_anonymous_page(struct vm_fault *vmf); extern vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf);
extern int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, extern int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr, pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr,
struct vm_area_struct *vma); struct vm_area_struct *vma);
...@@ -23,7 +23,7 @@ static inline void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud) ...@@ -23,7 +23,7 @@ static inline void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud)
} }
#endif #endif
extern int do_huge_pmd_wp_page(struct vm_fault *vmf, pmd_t orig_pmd); extern vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf, pmd_t orig_pmd);
extern struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, extern struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
unsigned long addr, unsigned long addr,
pmd_t *pmd, pmd_t *pmd,
...@@ -216,7 +216,7 @@ struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr, ...@@ -216,7 +216,7 @@ struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
struct page *follow_devmap_pud(struct vm_area_struct *vma, unsigned long addr, struct page *follow_devmap_pud(struct vm_area_struct *vma, unsigned long addr,
pud_t *pud, int flags); pud_t *pud, int flags);
extern int do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t orig_pmd); extern vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t orig_pmd);
extern struct page *huge_zero_page; extern struct page *huge_zero_page;
...@@ -321,7 +321,8 @@ static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, ...@@ -321,7 +321,8 @@ static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
return NULL; return NULL;
} }
static inline int do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t orig_pmd) static inline vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf,
pmd_t orig_pmd)
{ {
return 0; return 0;
} }
......
...@@ -105,7 +105,7 @@ void hugetlb_report_meminfo(struct seq_file *); ...@@ -105,7 +105,7 @@ void hugetlb_report_meminfo(struct seq_file *);
int hugetlb_report_node_meminfo(int, char *); int hugetlb_report_node_meminfo(int, char *);
void hugetlb_show_meminfo(void); void hugetlb_show_meminfo(void);
unsigned long hugetlb_total_pages(void); unsigned long hugetlb_total_pages(void);
int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long address, unsigned int flags); unsigned long address, unsigned int flags);
int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, pte_t *dst_pte, int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, pte_t *dst_pte,
struct vm_area_struct *dst_vma, struct vm_area_struct *dst_vma,
......
...@@ -728,10 +728,10 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma) ...@@ -728,10 +728,10 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
return pte; return pte;
} }
int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg, vm_fault_t alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
struct page *page); struct page *page);
int finish_fault(struct vm_fault *vmf); vm_fault_t finish_fault(struct vm_fault *vmf);
int finish_mkwrite_fault(struct vm_fault *vmf); vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf);
#endif #endif
/* /*
...@@ -1403,8 +1403,8 @@ int generic_error_remove_page(struct address_space *mapping, struct page *page); ...@@ -1403,8 +1403,8 @@ int generic_error_remove_page(struct address_space *mapping, struct page *page);
int invalidate_inode_page(struct page *page); int invalidate_inode_page(struct page *page);
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
extern int handle_mm_fault(struct vm_area_struct *vma, unsigned long address, extern vm_fault_t handle_mm_fault(struct vm_area_struct *vma,
unsigned int flags); unsigned long address, unsigned int flags);
extern int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, extern int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
unsigned long address, unsigned int fault_flags, unsigned long address, unsigned int fault_flags,
bool *unlocked); bool *unlocked);
...@@ -1413,7 +1413,7 @@ void unmap_mapping_pages(struct address_space *mapping, ...@@ -1413,7 +1413,7 @@ void unmap_mapping_pages(struct address_space *mapping,
void unmap_mapping_range(struct address_space *mapping, void unmap_mapping_range(struct address_space *mapping,
loff_t const holebegin, loff_t const holelen, int even_cows); loff_t const holebegin, loff_t const holelen, int even_cows);
#else #else
static inline int handle_mm_fault(struct vm_area_struct *vma, static inline vm_fault_t handle_mm_fault(struct vm_area_struct *vma,
unsigned long address, unsigned int flags) unsigned long address, unsigned int flags)
{ {
/* should never happen if there's no MMU */ /* should never happen if there's no MMU */
...@@ -2563,7 +2563,7 @@ static inline struct page *follow_page(struct vm_area_struct *vma, ...@@ -2563,7 +2563,7 @@ static inline struct page *follow_page(struct vm_area_struct *vma,
#define FOLL_COW 0x4000 /* internal GUP flag */ #define FOLL_COW 0x4000 /* internal GUP flag */
#define FOLL_ANON 0x8000 /* don't do file mappings */ #define FOLL_ANON 0x8000 /* don't do file mappings */
static inline int vm_fault_to_errno(int vm_fault, int foll_flags) static inline int vm_fault_to_errno(vm_fault_t vm_fault, int foll_flags)
{ {
if (vm_fault & VM_FAULT_OOM) if (vm_fault & VM_FAULT_OOM)
return -ENOMEM; return -ENOMEM;
......
...@@ -88,7 +88,7 @@ static inline bool mm_is_oom_victim(struct mm_struct *mm) ...@@ -88,7 +88,7 @@ static inline bool mm_is_oom_victim(struct mm_struct *mm)
* *
* Return 0 when the PF is safe VM_FAULT_SIGBUS otherwise. * Return 0 when the PF is safe VM_FAULT_SIGBUS otherwise.
*/ */
static inline int check_stable_address_space(struct mm_struct *mm) static inline vm_fault_t check_stable_address_space(struct mm_struct *mm)
{ {
if (unlikely(test_bit(MMF_UNSTABLE, &mm->flags))) if (unlikely(test_bit(MMF_UNSTABLE, &mm->flags)))
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/radix-tree.h> #include <linux/radix-tree.h>
#include <linux/bug.h> #include <linux/bug.h>
#include <linux/mm_types.h>
/* /*
* swapcache pages are stored in the swapper_space radix tree. We want to * swapcache pages are stored in the swapper_space radix tree. We want to
...@@ -134,7 +135,7 @@ static inline struct page *device_private_entry_to_page(swp_entry_t entry) ...@@ -134,7 +135,7 @@ static inline struct page *device_private_entry_to_page(swp_entry_t entry)
return pfn_to_page(swp_offset(entry)); return pfn_to_page(swp_offset(entry));
} }
int device_private_entry_fault(struct vm_area_struct *vma, vm_fault_t device_private_entry_fault(struct vm_area_struct *vma,
unsigned long addr, unsigned long addr,
swp_entry_t entry, swp_entry_t entry,
unsigned int flags, unsigned int flags,
...@@ -169,7 +170,7 @@ static inline struct page *device_private_entry_to_page(swp_entry_t entry) ...@@ -169,7 +170,7 @@ static inline struct page *device_private_entry_to_page(swp_entry_t entry)
return NULL; return NULL;
} }
static inline int device_private_entry_fault(struct vm_area_struct *vma, static inline vm_fault_t device_private_entry_fault(struct vm_area_struct *vma,
unsigned long addr, unsigned long addr,
swp_entry_t entry, swp_entry_t entry,
unsigned int flags, unsigned int flags,
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define UFFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK) #define UFFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
#define UFFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS) #define UFFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS)
extern int handle_userfault(struct vm_fault *vmf, unsigned long reason); extern vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason);
extern ssize_t mcopy_atomic(struct mm_struct *dst_mm, unsigned long dst_start, extern ssize_t mcopy_atomic(struct mm_struct *dst_mm, unsigned long dst_start,
unsigned long src_start, unsigned long len, unsigned long src_start, unsigned long len,
...@@ -77,7 +77,8 @@ extern void userfaultfd_unmap_complete(struct mm_struct *mm, ...@@ -77,7 +77,8 @@ extern void userfaultfd_unmap_complete(struct mm_struct *mm,
#else /* CONFIG_USERFAULTFD */ #else /* CONFIG_USERFAULTFD */
/* mm helpers */ /* mm helpers */
static inline int handle_userfault(struct vm_fault *vmf, unsigned long reason) static inline vm_fault_t handle_userfault(struct vm_fault *vmf,
unsigned long reason)
{ {
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
} }
......
...@@ -43,7 +43,7 @@ static unsigned long order_at(struct resource *res, unsigned long pgoff) ...@@ -43,7 +43,7 @@ static unsigned long order_at(struct resource *res, unsigned long pgoff)
pgoff += 1UL << order, order = order_at((res), pgoff)) pgoff += 1UL << order, order = order_at((res), pgoff))
#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) #if IS_ENABLED(CONFIG_DEVICE_PRIVATE)
int device_private_entry_fault(struct vm_area_struct *vma, vm_fault_t device_private_entry_fault(struct vm_area_struct *vma,
unsigned long addr, unsigned long addr,
swp_entry_t entry, swp_entry_t entry,
unsigned int flags, unsigned int flags,
......
...@@ -497,7 +497,7 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma, ...@@ -497,7 +497,7 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma,
unsigned long address, unsigned int *flags, int *nonblocking) unsigned long address, unsigned int *flags, int *nonblocking)
{ {
unsigned int fault_flags = 0; unsigned int fault_flags = 0;
int ret; vm_fault_t ret;
/* mlock all present pages, but do not fault in new pages */ /* mlock all present pages, but do not fault in new pages */
if ((*flags & (FOLL_POPULATE | FOLL_MLOCK)) == FOLL_MLOCK) if ((*flags & (FOLL_POPULATE | FOLL_MLOCK)) == FOLL_MLOCK)
...@@ -818,7 +818,7 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, ...@@ -818,7 +818,7 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
bool *unlocked) bool *unlocked)
{ {
struct vm_area_struct *vma; struct vm_area_struct *vma;
int ret, major = 0; vm_fault_t ret, major = 0;
if (unlocked) if (unlocked)
fault_flags |= FAULT_FLAG_ALLOW_RETRY; fault_flags |= FAULT_FLAG_ALLOW_RETRY;
......
...@@ -541,14 +541,14 @@ unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr, ...@@ -541,14 +541,14 @@ unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr,
} }
EXPORT_SYMBOL_GPL(thp_get_unmapped_area); EXPORT_SYMBOL_GPL(thp_get_unmapped_area);
static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page, static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf,
gfp_t gfp) struct page *page, gfp_t gfp)
{ {
struct vm_area_struct *vma = vmf->vma; struct vm_area_struct *vma = vmf->vma;
struct mem_cgroup *memcg; struct mem_cgroup *memcg;
pgtable_t pgtable; pgtable_t pgtable;
unsigned long haddr = vmf->address & HPAGE_PMD_MASK; unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
int ret = 0; vm_fault_t ret = 0;
VM_BUG_ON_PAGE(!PageCompound(page), page); VM_BUG_ON_PAGE(!PageCompound(page), page);
...@@ -584,15 +584,15 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page, ...@@ -584,15 +584,15 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
/* Deliver the page fault to userland */ /* Deliver the page fault to userland */
if (userfaultfd_missing(vma)) { if (userfaultfd_missing(vma)) {
int ret; vm_fault_t ret2;
spin_unlock(vmf->ptl); spin_unlock(vmf->ptl);
mem_cgroup_cancel_charge(page, memcg, true); mem_cgroup_cancel_charge(page, memcg, true);
put_page(page); put_page(page);
pte_free(vma->vm_mm, pgtable); pte_free(vma->vm_mm, pgtable);
ret = handle_userfault(vmf, VM_UFFD_MISSING); ret2 = handle_userfault(vmf, VM_UFFD_MISSING);
VM_BUG_ON(ret & VM_FAULT_FALLBACK); VM_BUG_ON(ret2 & VM_FAULT_FALLBACK);
return ret; return ret2;
} }
entry = mk_huge_pmd(page, vma->vm_page_prot); entry = mk_huge_pmd(page, vma->vm_page_prot);
...@@ -663,7 +663,7 @@ static bool set_huge_zero_page(pgtable_t pgtable, struct mm_struct *mm, ...@@ -663,7 +663,7 @@ static bool set_huge_zero_page(pgtable_t pgtable, struct mm_struct *mm,
return true; return true;
} }
int do_huge_pmd_anonymous_page(struct vm_fault *vmf) vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf)
{ {
struct vm_area_struct *vma = vmf->vma; struct vm_area_struct *vma = vmf->vma;
gfp_t gfp; gfp_t gfp;
...@@ -682,7 +682,7 @@ int do_huge_pmd_anonymous_page(struct vm_fault *vmf) ...@@ -682,7 +682,7 @@ int do_huge_pmd_anonymous_page(struct vm_fault *vmf)
pgtable_t pgtable; pgtable_t pgtable;
struct page *zero_page; struct page *zero_page;
bool set; bool set;
int ret; vm_fault_t ret;
pgtable = pte_alloc_one(vma->vm_mm, haddr); pgtable = pte_alloc_one(vma->vm_mm, haddr);
if (unlikely(!pgtable)) if (unlikely(!pgtable))
return VM_FAULT_OOM; return VM_FAULT_OOM;
...@@ -1118,15 +1118,16 @@ void huge_pmd_set_accessed(struct vm_fault *vmf, pmd_t orig_pmd) ...@@ -1118,15 +1118,16 @@ void huge_pmd_set_accessed(struct vm_fault *vmf, pmd_t orig_pmd)
spin_unlock(vmf->ptl); spin_unlock(vmf->ptl);
} }
static int do_huge_pmd_wp_page_fallback(struct vm_fault *vmf, pmd_t orig_pmd, static vm_fault_t do_huge_pmd_wp_page_fallback(struct vm_fault *vmf,
struct page *page) pmd_t orig_pmd, struct page *page)
{ {
struct vm_area_struct *vma = vmf->vma; struct vm_area_struct *vma = vmf->vma;
unsigned long haddr = vmf->address & HPAGE_PMD_MASK; unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
struct mem_cgroup *memcg; struct mem_cgroup *memcg;
pgtable_t pgtable; pgtable_t pgtable;
pmd_t _pmd; pmd_t _pmd;
int ret = 0, i; int i;
vm_fault_t ret = 0;
struct page **pages; struct page **pages;
unsigned long mmun_start; /* For mmu_notifiers */ unsigned long mmun_start; /* For mmu_notifiers */
unsigned long mmun_end; /* For mmu_notifiers */ unsigned long mmun_end; /* For mmu_notifiers */
...@@ -1236,7 +1237,7 @@ static int do_huge_pmd_wp_page_fallback(struct vm_fault *vmf, pmd_t orig_pmd, ...@@ -1236,7 +1237,7 @@ static int do_huge_pmd_wp_page_fallback(struct vm_fault *vmf, pmd_t orig_pmd,
goto out; goto out;
} }
int do_huge_pmd_wp_page(struct vm_fault *vmf, pmd_t orig_pmd) vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf, pmd_t orig_pmd)
{ {
struct vm_area_struct *vma = vmf->vma; struct vm_area_struct *vma = vmf->vma;
struct page *page = NULL, *new_page; struct page *page = NULL, *new_page;
...@@ -1245,7 +1246,7 @@ int do_huge_pmd_wp_page(struct vm_fault *vmf, pmd_t orig_pmd) ...@@ -1245,7 +1246,7 @@ int do_huge_pmd_wp_page(struct vm_fault *vmf, pmd_t orig_pmd)
unsigned long mmun_start; /* For mmu_notifiers */ unsigned long mmun_start; /* For mmu_notifiers */
unsigned long mmun_end; /* For mmu_notifiers */ unsigned long mmun_end; /* For mmu_notifiers */
gfp_t huge_gfp; /* for allocation and charge */ gfp_t huge_gfp; /* for allocation and charge */
int ret = 0; vm_fault_t ret = 0;
vmf->ptl = pmd_lockptr(vma->vm_mm, vmf->pmd); vmf->ptl = pmd_lockptr(vma->vm_mm, vmf->pmd);
VM_BUG_ON_VMA(!vma->anon_vma, vma); VM_BUG_ON_VMA(!vma->anon_vma, vma);
...@@ -1457,7 +1458,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, ...@@ -1457,7 +1458,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
} }
/* NUMA hinting page fault entry point for trans huge pmds */ /* NUMA hinting page fault entry point for trans huge pmds */
int do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t pmd) vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t pmd)
{ {
struct vm_area_struct *vma = vmf->vma; struct vm_area_struct *vma = vmf->vma;
struct anon_vma *anon_vma = NULL; struct anon_vma *anon_vma = NULL;
......
...@@ -3501,14 +3501,15 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -3501,14 +3501,15 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
* cannot race with other handlers or page migration. * cannot race with other handlers or page migration.
* Keep the pte_same checks anyway to make transition from the mutex easier. * Keep the pte_same checks anyway to make transition from the mutex easier.
*/ */
static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, static vm_fault_t hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long address, pte_t *ptep, unsigned long address, pte_t *ptep,
struct page *pagecache_page, spinlock_t *ptl) struct page *pagecache_page, spinlock_t *ptl)
{ {
pte_t pte; pte_t pte;
struct hstate *h = hstate_vma(vma); struct hstate *h = hstate_vma(vma);
struct page *old_page, *new_page; struct page *old_page, *new_page;
int ret = 0, outside_reserve = 0; int outside_reserve = 0;
vm_fault_t ret = 0;
unsigned long mmun_start; /* For mmu_notifiers */ unsigned long mmun_start; /* For mmu_notifiers */
unsigned long mmun_end; /* For mmu_notifiers */ unsigned long mmun_end; /* For mmu_notifiers */
unsigned long haddr = address & huge_page_mask(h); unsigned long haddr = address & huge_page_mask(h);
...@@ -3572,8 +3573,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -3572,8 +3573,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
return 0; return 0;
} }
ret = (PTR_ERR(new_page) == -ENOMEM) ? ret = vmf_error(PTR_ERR(new_page));
VM_FAULT_OOM : VM_FAULT_SIGBUS;
goto out_release_old; goto out_release_old;
} }
...@@ -3676,12 +3676,13 @@ int huge_add_to_page_cache(struct page *page, struct address_space *mapping, ...@@ -3676,12 +3676,13 @@ int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
return 0; return 0;
} }
static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
struct address_space *mapping, pgoff_t idx, struct vm_area_struct *vma,
unsigned long address, pte_t *ptep, unsigned int flags) struct address_space *mapping, pgoff_t idx,
unsigned long address, pte_t *ptep, unsigned int flags)
{ {
struct hstate *h = hstate_vma(vma); struct hstate *h = hstate_vma(vma);
int ret = VM_FAULT_SIGBUS; vm_fault_t ret = VM_FAULT_SIGBUS;
int anon_rmap = 0; int anon_rmap = 0;
unsigned long size; unsigned long size;
struct page *page; struct page *page;
...@@ -3744,11 +3745,7 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -3744,11 +3745,7 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
page = alloc_huge_page(vma, haddr, 0); page = alloc_huge_page(vma, haddr, 0);
if (IS_ERR(page)) { if (IS_ERR(page)) {
ret = PTR_ERR(page); ret = vmf_error(PTR_ERR(page));
if (ret == -ENOMEM)
ret = VM_FAULT_OOM;
else
ret = VM_FAULT_SIGBUS;
goto out; goto out;
} }
clear_huge_page(page, address, pages_per_huge_page(h)); clear_huge_page(page, address, pages_per_huge_page(h));
...@@ -3872,12 +3869,12 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm, ...@@ -3872,12 +3869,12 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
} }
#endif #endif
int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long address, unsigned int flags) unsigned long address, unsigned int flags)
{ {
pte_t *ptep, entry; pte_t *ptep, entry;
spinlock_t *ptl; spinlock_t *ptl;
int ret; vm_fault_t ret;
u32 hash; u32 hash;
pgoff_t idx; pgoff_t idx;
struct page *page = NULL; struct page *page = NULL;
...@@ -4207,7 +4204,7 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -4207,7 +4204,7 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
if (absent || is_swap_pte(huge_ptep_get(pte)) || if (absent || is_swap_pte(huge_ptep_get(pte)) ||
((flags & FOLL_WRITE) && ((flags & FOLL_WRITE) &&
!huge_pte_write(huge_ptep_get(pte)))) { !huge_pte_write(huge_ptep_get(pte)))) {
int ret; vm_fault_t ret;
unsigned int fault_flags = 0; unsigned int fault_flags = 0;
if (pte) if (pte)
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
void page_writeback_init(void); void page_writeback_init(void);
int do_swap_page(struct vm_fault *vmf); vm_fault_t do_swap_page(struct vm_fault *vmf);
void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma, void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
unsigned long floor, unsigned long ceiling); unsigned long floor, unsigned long ceiling);
......
...@@ -880,7 +880,8 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm, ...@@ -880,7 +880,8 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
unsigned long address, pmd_t *pmd, unsigned long address, pmd_t *pmd,
int referenced) int referenced)
{ {
int swapped_in = 0, ret = 0; int swapped_in = 0;
vm_fault_t ret = 0;
struct vm_fault vmf = { struct vm_fault vmf = {
.vma = vma, .vma = vma,
.address = address, .address = address,
......
This diff is collapsed.
...@@ -124,7 +124,7 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp, ...@@ -124,7 +124,7 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp,
static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
struct page **pagep, enum sgp_type sgp, struct page **pagep, enum sgp_type sgp,
gfp_t gfp, struct vm_area_struct *vma, gfp_t gfp, struct vm_area_struct *vma,
struct vm_fault *vmf, int *fault_type); struct vm_fault *vmf, vm_fault_t *fault_type);
int shmem_getpage(struct inode *inode, pgoff_t index, int shmem_getpage(struct inode *inode, pgoff_t index,
struct page **pagep, enum sgp_type sgp) struct page **pagep, enum sgp_type sgp)
...@@ -1620,7 +1620,8 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp, ...@@ -1620,7 +1620,8 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp,
*/ */
static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct page **pagep, enum sgp_type sgp, gfp_t gfp,
struct vm_area_struct *vma, struct vm_fault *vmf, int *fault_type) struct vm_area_struct *vma, struct vm_fault *vmf,
vm_fault_t *fault_type)
{ {
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
struct shmem_inode_info *info = SHMEM_I(inode); struct shmem_inode_info *info = SHMEM_I(inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment