From: Souptick Joarder <jrdr.linux@gmail.com>
To: willy@infradead.org, akpm@linux-foundation.org
Cc: linux-mm@kvack.org
Subject: [PATCH] mm: Change return type to vm_fault_t
Date: Thu, 8 Mar 2018 18:35:23 +0530 [thread overview]
Message-ID: <20180308130523.GA30642@jordon-HP-15-Notebook-PC> (raw)
Use new return type vm_fault_t for fault handler
in struct vm_operations_struct.
vmf_insert_mixed(), vmf_insert_pfn() and vmf_insert_page()
are newly added inline wrapper functions.
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
include/linux/mm.h | 47 +++++++++++++++++++++++++++++++++++++++++++----
include/linux/mm_types.h | 2 ++
2 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ad06d42..a4d8853 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -379,17 +379,18 @@ struct vm_operations_struct {
void (*close)(struct vm_area_struct * area);
int (*split)(struct vm_area_struct * area, unsigned long addr);
int (*mremap)(struct vm_area_struct * area);
- int (*fault)(struct vm_fault *vmf);
- int (*huge_fault)(struct vm_fault *vmf, enum page_entry_size pe_size);
+ vm_fault_t (*fault)(struct vm_fault *vmf);
+ vm_fault_t (*huge_fault)(struct vm_fault *vmf,
+ enum page_entry_size pe_size);
void (*map_pages)(struct vm_fault *vmf,
pgoff_t start_pgoff, pgoff_t end_pgoff);
/* notification that a previously read-only page is about to become
* writable, if an error is returned it will cause a SIGBUS */
- int (*page_mkwrite)(struct vm_fault *vmf);
+ vm_fault_t (*page_mkwrite)(struct vm_fault *vmf);
/* same as page_mkwrite when using VM_PFNMAP|VM_MIXEDMAP */
- int (*pfn_mkwrite)(struct vm_fault *vmf);
+ vm_fault_t (*pfn_mkwrite)(struct vm_fault *vmf);
/* called by access_process_vm when get_user_pages() fails, typically
* for use by special VMAs that can switch between memory and hardware
@@ -2413,6 +2414,44 @@ int vm_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr,
pfn_t pfn);
int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len);
+static inline vm_fault_t vmf_insert_page(struct vm_area_struct *vma,
+ unsigned long addr, struct page *page)
+{
+ int err = vm_insert_page(vma, addr, page);
+
+ if (err == -ENOMEM)
+ return VM_FAULT_OOM;
+ if (err < 0 && err != -EBUSY)
+ return VM_FAULT_SIGBUS;
+
+ return VM_FAULT_NOPAGE;
+}
+
+static inline vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma,
+ unsigned long addr, pfn_t pfn)
+{
+ int err = vm_insert_mixed(vma, addr, pfn);
+
+ if (err == -ENOMEM)
+ return VM_FAULT_OOM;
+ if (err < 0 && err != -EBUSY)
+ return VM_FAULT_SIGBUS;
+
+ return VM_FAULT_NOPAGE;
+}
+
+static inline vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma,
+ unsigned long addr, unsigned long pfn)
+{
+ int err = vm_insert_pfn(vma, addr, pfn);
+
+ if (err == -ENOMEM)
+ return VM_FAULT_OOM;
+ if (err < 0 && err != -EBUSY)
+ return VM_FAULT_SIGBUS;
+
+ return VM_FAULT_NOPAGE;
+}
struct page *follow_page_mask(struct vm_area_struct *vma,
unsigned long address, unsigned int foll_flags,
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index fd1af6b..2161234 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -22,6 +22,8 @@
#endif
#define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
+typedef int vm_fault_t;
+
struct address_space;
struct mem_cgroup;
struct hmm;
--
1.9.1
next reply other threads:[~2018-03-08 13:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-08 13:05 Souptick Joarder [this message]
2018-03-08 22:22 ` [PATCH] mm: Change return type to vm_fault_t Matthew Wilcox
2018-03-08 23:22 ` Andrew Morton
2018-03-08 23:48 ` Matthew Wilcox
2018-03-09 6:28 ` Souptick Joarder
2018-03-08 22:26 ` Andrew Morton
2018-03-08 22:55 ` Matthew Wilcox
-- strict thread matches above, loose matches on Subject: below --
2018-04-14 21:33 Souptick Joarder
2018-05-29 14:31 Souptick Joarder
2018-05-29 14:50 ` Matthew Wilcox
2018-05-29 15:55 ` Souptick Joarder
2018-05-29 17:34 ` Matthew Wilcox
2018-05-30 3:40 ` Souptick Joarder
2018-05-30 11:16 ` Matthew Wilcox
2018-06-02 14:44 ` Souptick Joarder
2018-06-02 14:44 ` Souptick Joarder
2018-06-02 14:55 ` Souptick Joarder
2018-06-02 14:59 ` Luc Van Oostenryck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180308130523.GA30642@jordon-HP-15-Notebook-PC \
--to=jrdr.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).