* [PATCH v3] mm: Create the new vm_fault_t type
@ 2018-11-06 12:06 Souptick Joarder
2018-11-06 12:10 ` Michal Hocko
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Souptick Joarder @ 2018-11-06 12:06 UTC (permalink / raw)
To: willy, akpm, mhocko, kirill.shutemov, dan.j.williams, vbabka,
riel, rppt
Cc: linux-mm, linux-kernel
Page fault handlers are supposed to return VM_FAULT codes,
but some drivers/file systems mistakenly return error
numbers. Now that all drivers/file systems have been converted
to use the vm_fault_t return type, change the type definition
to no longer be compatible with 'int'. By making it an unsigned
int, the function prototype becomes incompatible with a function
which returns int. Sparse will detect any attempts to return a
value which is not a VM_FAULT code.
VM_FAULT_SET_HINDEX and VM_FAULT_GET_HINDEX values are changed
to avoid conflict with other VM_FAULT codes.
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
v2: Updated the change log and corrected the document part.
name added to the enum that kernel-doc able to parse it.
v3: Corrected the documentation.
include/linux/mm.h | 46 ------------------------------
include/linux/mm_types.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 72 insertions(+), 47 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fcf9cc9..511a3ce 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1267,52 +1267,6 @@ static inline void clear_page_pfmemalloc(struct page *page)
}
/*
- * Different kinds of faults, as returned by handle_mm_fault().
- * Used to decide whether a process gets delivered SIGBUS or
- * just gets major/minor fault counters bumped up.
- */
-
-#define VM_FAULT_OOM 0x0001
-#define VM_FAULT_SIGBUS 0x0002
-#define VM_FAULT_MAJOR 0x0004
-#define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */
-#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */
-#define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */
-#define VM_FAULT_SIGSEGV 0x0040
-
-#define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */
-#define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */
-#define VM_FAULT_RETRY 0x0400 /* ->fault blocked, must retry */
-#define VM_FAULT_FALLBACK 0x0800 /* huge page fault failed, fall back to small */
-#define VM_FAULT_DONE_COW 0x1000 /* ->fault has fully handled COW */
-#define VM_FAULT_NEEDDSYNC 0x2000 /* ->fault did not modify page tables
- * and needs fsync() to complete (for
- * synchronous page faults in DAX) */
-
-#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \
- VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \
- VM_FAULT_FALLBACK)
-
-#define VM_FAULT_RESULT_TRACE \
- { VM_FAULT_OOM, "OOM" }, \
- { VM_FAULT_SIGBUS, "SIGBUS" }, \
- { VM_FAULT_MAJOR, "MAJOR" }, \
- { VM_FAULT_WRITE, "WRITE" }, \
- { VM_FAULT_HWPOISON, "HWPOISON" }, \
- { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \
- { VM_FAULT_SIGSEGV, "SIGSEGV" }, \
- { VM_FAULT_NOPAGE, "NOPAGE" }, \
- { VM_FAULT_LOCKED, "LOCKED" }, \
- { VM_FAULT_RETRY, "RETRY" }, \
- { VM_FAULT_FALLBACK, "FALLBACK" }, \
- { VM_FAULT_DONE_COW, "DONE_COW" }, \
- { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" }
-
-/* Encode hstate index for a hwpoisoned large page */
-#define VM_FAULT_SET_HINDEX(x) ((x) << 12)
-#define VM_FAULT_GET_HINDEX(x) (((x) >> 12) & 0xf)
-
-/*
* Can be called by the pagefault handler when it gets a VM_FAULT_OOM.
*/
extern void pagefault_out_of_memory(void);
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 5ed8f62..cb25016 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -22,7 +22,6 @@
#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;
@@ -609,6 +608,78 @@ static inline bool mm_tlb_flush_nested(struct mm_struct *mm)
struct vm_fault;
+/**
+ * typedef vm_fault_t - Return type for page fault handlers.
+ *
+ * Page fault handlers return a bitmask of %VM_FAULT values.
+ */
+typedef __bitwise unsigned int vm_fault_t;
+
+/**
+ * enum vm_fault_reason - Page fault handlers return a bitmask of
+ * these values to tell the core VM what happened when handling the
+ * fault. Used to decide whether a process gets delivered SIGBUS or
+ * just gets major/minor fault counters bumped up.
+ *
+ * @VM_FAULT_OOM: Out Of Memory
+ * @VM_FAULT_SIGBUS: Bad access
+ * @VM_FAULT_MAJOR: Page read from storage
+ * @VM_FAULT_WRITE: Special case for get_user_pages
+ * @VM_FAULT_HWPOISON: Hit poisoned small page
+ * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded
+ * in upper bits
+ * @VM_FAULT_SIGSEGV: segmentation fault
+ * @VM_FAULT_NOPAGE: ->fault installed the pte, not return page
+ * @VM_FAULT_LOCKED: ->fault locked the returned page
+ * @VM_FAULT_RETRY: ->fault blocked, must retry
+ * @VM_FAULT_FALLBACK: huge page fault failed, fall back to small
+ * @VM_FAULT_DONE_COW: ->fault has fully handled COW
+ * @VM_FAULT_NEEDDSYNC: ->fault did not modify page tables and needs
+ * fsync() to complete (for synchronous page faults
+ * in DAX)
+ * @VM_FAULT_HINDEX_MASK: mask HINDEX value
+ *
+ */
+enum vm_fault_reason {
+ VM_FAULT_OOM = (__force vm_fault_t)0x000001,
+ VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002,
+ VM_FAULT_MAJOR = (__force vm_fault_t)0x000004,
+ VM_FAULT_WRITE = (__force vm_fault_t)0x000008,
+ VM_FAULT_HWPOISON = (__force vm_fault_t)0x000010,
+ VM_FAULT_HWPOISON_LARGE = (__force vm_fault_t)0x000020,
+ VM_FAULT_SIGSEGV = (__force vm_fault_t)0x000040,
+ VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100,
+ VM_FAULT_LOCKED = (__force vm_fault_t)0x000200,
+ VM_FAULT_RETRY = (__force vm_fault_t)0x000400,
+ VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800,
+ VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000,
+ VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000,
+ VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000,
+};
+
+/* Encode hstate index for a hwpoisoned large page */
+#define VM_FAULT_SET_HINDEX(x) ((__force vm_fault_t)((x) << 16))
+#define VM_FAULT_GET_HINDEX(x) (((x) >> 16) & 0xf)
+
+#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | \
+ VM_FAULT_SIGSEGV | VM_FAULT_HWPOISON | \
+ VM_FAULT_HWPOISON_LARGE | VM_FAULT_FALLBACK)
+
+#define VM_FAULT_RESULT_TRACE \
+ { VM_FAULT_OOM, "OOM" }, \
+ { VM_FAULT_SIGBUS, "SIGBUS" }, \
+ { VM_FAULT_MAJOR, "MAJOR" }, \
+ { VM_FAULT_WRITE, "WRITE" }, \
+ { VM_FAULT_HWPOISON, "HWPOISON" }, \
+ { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \
+ { VM_FAULT_SIGSEGV, "SIGSEGV" }, \
+ { VM_FAULT_NOPAGE, "NOPAGE" }, \
+ { VM_FAULT_LOCKED, "LOCKED" }, \
+ { VM_FAULT_RETRY, "RETRY" }, \
+ { VM_FAULT_FALLBACK, "FALLBACK" }, \
+ { VM_FAULT_DONE_COW, "DONE_COW" }, \
+ { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" }
+
struct vm_special_mapping {
const char *name; /* The name, e.g. "[vdso]". */
--
1.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH v3] mm: Create the new vm_fault_t type 2018-11-06 12:06 [PATCH v3] mm: Create the new vm_fault_t type Souptick Joarder @ 2018-11-06 12:10 ` Michal Hocko 2018-11-14 5:13 ` Souptick Joarder 2018-11-15 1:47 ` Mike Rapoport 2 siblings, 0 replies; 12+ messages in thread From: Michal Hocko @ 2018-11-06 12:10 UTC (permalink / raw) To: Souptick Joarder Cc: willy, akpm, kirill.shutemov, dan.j.williams, vbabka, riel, rppt, linux-mm, linux-kernel [off-list] Please do not submit a new version of the patch just after a minor feedback to the documentation. Wait for some more feedback. Sending 3 versions in about 2 days is just way too much. Thanks! -- Michal Hocko SUSE Labs ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2018-11-06 12:06 [PATCH v3] mm: Create the new vm_fault_t type Souptick Joarder 2018-11-06 12:10 ` Michal Hocko @ 2018-11-14 5:13 ` Souptick Joarder 2018-11-14 9:59 ` William Kucharski 2018-11-15 1:47 ` Mike Rapoport 2 siblings, 1 reply; 12+ messages in thread From: Souptick Joarder @ 2018-11-14 5:13 UTC (permalink / raw) To: Matthew Wilcox, Andrew Morton, Michal Hocko, Kirill A. Shutemov, Dan Williams, vbabka, riel, rppt Cc: Linux-MM, linux-kernel On Tue, Nov 6, 2018 at 5:33 PM Souptick Joarder <jrdr.linux@gmail.com> wrote: > > Page fault handlers are supposed to return VM_FAULT codes, > but some drivers/file systems mistakenly return error > numbers. Now that all drivers/file systems have been converted > to use the vm_fault_t return type, change the type definition > to no longer be compatible with 'int'. By making it an unsigned > int, the function prototype becomes incompatible with a function > which returns int. Sparse will detect any attempts to return a > value which is not a VM_FAULT code. > > VM_FAULT_SET_HINDEX and VM_FAULT_GET_HINDEX values are changed > to avoid conflict with other VM_FAULT codes. > > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> Any further comment on this patch ? > --- > v2: Updated the change log and corrected the document part. > name added to the enum that kernel-doc able to parse it. > > v3: Corrected the documentation. > > include/linux/mm.h | 46 ------------------------------ > include/linux/mm_types.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 72 insertions(+), 47 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index fcf9cc9..511a3ce 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1267,52 +1267,6 @@ static inline void clear_page_pfmemalloc(struct page *page) > } > > /* > - * Different kinds of faults, as returned by handle_mm_fault(). > - * Used to decide whether a process gets delivered SIGBUS or > - * just gets major/minor fault counters bumped up. > - */ > - > -#define VM_FAULT_OOM 0x0001 > -#define VM_FAULT_SIGBUS 0x0002 > -#define VM_FAULT_MAJOR 0x0004 > -#define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ > -#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */ > -#define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */ > -#define VM_FAULT_SIGSEGV 0x0040 > - > -#define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ > -#define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ > -#define VM_FAULT_RETRY 0x0400 /* ->fault blocked, must retry */ > -#define VM_FAULT_FALLBACK 0x0800 /* huge page fault failed, fall back to small */ > -#define VM_FAULT_DONE_COW 0x1000 /* ->fault has fully handled COW */ > -#define VM_FAULT_NEEDDSYNC 0x2000 /* ->fault did not modify page tables > - * and needs fsync() to complete (for > - * synchronous page faults in DAX) */ > - > -#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \ > - VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \ > - VM_FAULT_FALLBACK) > - > -#define VM_FAULT_RESULT_TRACE \ > - { VM_FAULT_OOM, "OOM" }, \ > - { VM_FAULT_SIGBUS, "SIGBUS" }, \ > - { VM_FAULT_MAJOR, "MAJOR" }, \ > - { VM_FAULT_WRITE, "WRITE" }, \ > - { VM_FAULT_HWPOISON, "HWPOISON" }, \ > - { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > - { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > - { VM_FAULT_NOPAGE, "NOPAGE" }, \ > - { VM_FAULT_LOCKED, "LOCKED" }, \ > - { VM_FAULT_RETRY, "RETRY" }, \ > - { VM_FAULT_FALLBACK, "FALLBACK" }, \ > - { VM_FAULT_DONE_COW, "DONE_COW" }, \ > - { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > - > -/* Encode hstate index for a hwpoisoned large page */ > -#define VM_FAULT_SET_HINDEX(x) ((x) << 12) > -#define VM_FAULT_GET_HINDEX(x) (((x) >> 12) & 0xf) > - > -/* > * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. > */ > extern void pagefault_out_of_memory(void); > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 5ed8f62..cb25016 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -22,7 +22,6 @@ > #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; > @@ -609,6 +608,78 @@ static inline bool mm_tlb_flush_nested(struct mm_struct *mm) > > struct vm_fault; > > +/** > + * typedef vm_fault_t - Return type for page fault handlers. > + * > + * Page fault handlers return a bitmask of %VM_FAULT values. > + */ > +typedef __bitwise unsigned int vm_fault_t; > + > +/** > + * enum vm_fault_reason - Page fault handlers return a bitmask of > + * these values to tell the core VM what happened when handling the > + * fault. Used to decide whether a process gets delivered SIGBUS or > + * just gets major/minor fault counters bumped up. > + * > + * @VM_FAULT_OOM: Out Of Memory > + * @VM_FAULT_SIGBUS: Bad access > + * @VM_FAULT_MAJOR: Page read from storage > + * @VM_FAULT_WRITE: Special case for get_user_pages > + * @VM_FAULT_HWPOISON: Hit poisoned small page > + * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded > + * in upper bits > + * @VM_FAULT_SIGSEGV: segmentation fault > + * @VM_FAULT_NOPAGE: ->fault installed the pte, not return page > + * @VM_FAULT_LOCKED: ->fault locked the returned page > + * @VM_FAULT_RETRY: ->fault blocked, must retry > + * @VM_FAULT_FALLBACK: huge page fault failed, fall back to small > + * @VM_FAULT_DONE_COW: ->fault has fully handled COW > + * @VM_FAULT_NEEDDSYNC: ->fault did not modify page tables and needs > + * fsync() to complete (for synchronous page faults > + * in DAX) > + * @VM_FAULT_HINDEX_MASK: mask HINDEX value > + * > + */ > +enum vm_fault_reason { > + VM_FAULT_OOM = (__force vm_fault_t)0x000001, > + VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002, > + VM_FAULT_MAJOR = (__force vm_fault_t)0x000004, > + VM_FAULT_WRITE = (__force vm_fault_t)0x000008, > + VM_FAULT_HWPOISON = (__force vm_fault_t)0x000010, > + VM_FAULT_HWPOISON_LARGE = (__force vm_fault_t)0x000020, > + VM_FAULT_SIGSEGV = (__force vm_fault_t)0x000040, > + VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100, > + VM_FAULT_LOCKED = (__force vm_fault_t)0x000200, > + VM_FAULT_RETRY = (__force vm_fault_t)0x000400, > + VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800, > + VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000, > + VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000, > + VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000, > +}; > + > +/* Encode hstate index for a hwpoisoned large page */ > +#define VM_FAULT_SET_HINDEX(x) ((__force vm_fault_t)((x) << 16)) > +#define VM_FAULT_GET_HINDEX(x) (((x) >> 16) & 0xf) > + > +#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | \ > + VM_FAULT_SIGSEGV | VM_FAULT_HWPOISON | \ > + VM_FAULT_HWPOISON_LARGE | VM_FAULT_FALLBACK) > + > +#define VM_FAULT_RESULT_TRACE \ > + { VM_FAULT_OOM, "OOM" }, \ > + { VM_FAULT_SIGBUS, "SIGBUS" }, \ > + { VM_FAULT_MAJOR, "MAJOR" }, \ > + { VM_FAULT_WRITE, "WRITE" }, \ > + { VM_FAULT_HWPOISON, "HWPOISON" }, \ > + { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > + { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > + { VM_FAULT_NOPAGE, "NOPAGE" }, \ > + { VM_FAULT_LOCKED, "LOCKED" }, \ > + { VM_FAULT_RETRY, "RETRY" }, \ > + { VM_FAULT_FALLBACK, "FALLBACK" }, \ > + { VM_FAULT_DONE_COW, "DONE_COW" }, \ > + { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > + > struct vm_special_mapping { > const char *name; /* The name, e.g. "[vdso]". */ > > -- > 1.9.1 > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2018-11-14 5:13 ` Souptick Joarder @ 2018-11-14 9:59 ` William Kucharski 0 siblings, 0 replies; 12+ messages in thread From: William Kucharski @ 2018-11-14 9:59 UTC (permalink / raw) To: Souptick Joarder Cc: Matthew Wilcox, Andrew Morton, Michal Hocko, Kirill A. Shutemov, Dan Williams, vbabka, riel, rppt, Linux-MM, linux-kernel > On Nov 13, 2018, at 10:13 PM, Souptick Joarder <jrdr.linux@gmail.com> wrote: > > On Tue, Nov 6, 2018 at 5:33 PM Souptick Joarder <jrdr.linux@gmail.com> wrote: >> >> Page fault handlers are supposed to return VM_FAULT codes, >> but some drivers/file systems mistakenly return error >> numbers. Now that all drivers/file systems have been converted >> to use the vm_fault_t return type, change the type definition >> to no longer be compatible with 'int'. By making it an unsigned >> int, the function prototype becomes incompatible with a function >> which returns int. Sparse will detect any attempts to return a >> value which is not a VM_FAULT code. >> >> VM_FAULT_SET_HINDEX and VM_FAULT_GET_HINDEX values are changed >> to avoid conflict with other VM_FAULT codes. >> >> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> > > Any further comment on this patch ? Reviewed-by: William Kucharski <william.kucharski@oracle.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2018-11-06 12:06 [PATCH v3] mm: Create the new vm_fault_t type Souptick Joarder 2018-11-06 12:10 ` Michal Hocko 2018-11-14 5:13 ` Souptick Joarder @ 2018-11-15 1:47 ` Mike Rapoport 2018-11-24 4:46 ` Souptick Joarder 2 siblings, 1 reply; 12+ messages in thread From: Mike Rapoport @ 2018-11-15 1:47 UTC (permalink / raw) To: Souptick Joarder Cc: willy, akpm, mhocko, kirill.shutemov, dan.j.williams, vbabka, riel, linux-mm, linux-kernel On Tue, Nov 06, 2018 at 05:36:42PM +0530, Souptick Joarder wrote: > Page fault handlers are supposed to return VM_FAULT codes, > but some drivers/file systems mistakenly return error > numbers. Now that all drivers/file systems have been converted > to use the vm_fault_t return type, change the type definition > to no longer be compatible with 'int'. By making it an unsigned > int, the function prototype becomes incompatible with a function > which returns int. Sparse will detect any attempts to return a > value which is not a VM_FAULT code. > > VM_FAULT_SET_HINDEX and VM_FAULT_GET_HINDEX values are changed > to avoid conflict with other VM_FAULT codes. > > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> For the docs part Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> > --- > v2: Updated the change log and corrected the document part. > name added to the enum that kernel-doc able to parse it. > > v3: Corrected the documentation. > > include/linux/mm.h | 46 ------------------------------ > include/linux/mm_types.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 72 insertions(+), 47 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index fcf9cc9..511a3ce 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1267,52 +1267,6 @@ static inline void clear_page_pfmemalloc(struct page *page) > } > > /* > - * Different kinds of faults, as returned by handle_mm_fault(). > - * Used to decide whether a process gets delivered SIGBUS or > - * just gets major/minor fault counters bumped up. > - */ > - > -#define VM_FAULT_OOM 0x0001 > -#define VM_FAULT_SIGBUS 0x0002 > -#define VM_FAULT_MAJOR 0x0004 > -#define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ > -#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */ > -#define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */ > -#define VM_FAULT_SIGSEGV 0x0040 > - > -#define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ > -#define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ > -#define VM_FAULT_RETRY 0x0400 /* ->fault blocked, must retry */ > -#define VM_FAULT_FALLBACK 0x0800 /* huge page fault failed, fall back to small */ > -#define VM_FAULT_DONE_COW 0x1000 /* ->fault has fully handled COW */ > -#define VM_FAULT_NEEDDSYNC 0x2000 /* ->fault did not modify page tables > - * and needs fsync() to complete (for > - * synchronous page faults in DAX) */ > - > -#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \ > - VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \ > - VM_FAULT_FALLBACK) > - > -#define VM_FAULT_RESULT_TRACE \ > - { VM_FAULT_OOM, "OOM" }, \ > - { VM_FAULT_SIGBUS, "SIGBUS" }, \ > - { VM_FAULT_MAJOR, "MAJOR" }, \ > - { VM_FAULT_WRITE, "WRITE" }, \ > - { VM_FAULT_HWPOISON, "HWPOISON" }, \ > - { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > - { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > - { VM_FAULT_NOPAGE, "NOPAGE" }, \ > - { VM_FAULT_LOCKED, "LOCKED" }, \ > - { VM_FAULT_RETRY, "RETRY" }, \ > - { VM_FAULT_FALLBACK, "FALLBACK" }, \ > - { VM_FAULT_DONE_COW, "DONE_COW" }, \ > - { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > - > -/* Encode hstate index for a hwpoisoned large page */ > -#define VM_FAULT_SET_HINDEX(x) ((x) << 12) > -#define VM_FAULT_GET_HINDEX(x) (((x) >> 12) & 0xf) > - > -/* > * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. > */ > extern void pagefault_out_of_memory(void); > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 5ed8f62..cb25016 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -22,7 +22,6 @@ > #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; > @@ -609,6 +608,78 @@ static inline bool mm_tlb_flush_nested(struct mm_struct *mm) > > struct vm_fault; > > +/** > + * typedef vm_fault_t - Return type for page fault handlers. > + * > + * Page fault handlers return a bitmask of %VM_FAULT values. > + */ > +typedef __bitwise unsigned int vm_fault_t; > + > +/** > + * enum vm_fault_reason - Page fault handlers return a bitmask of > + * these values to tell the core VM what happened when handling the > + * fault. Used to decide whether a process gets delivered SIGBUS or > + * just gets major/minor fault counters bumped up. > + * > + * @VM_FAULT_OOM: Out Of Memory > + * @VM_FAULT_SIGBUS: Bad access > + * @VM_FAULT_MAJOR: Page read from storage > + * @VM_FAULT_WRITE: Special case for get_user_pages > + * @VM_FAULT_HWPOISON: Hit poisoned small page > + * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded > + * in upper bits > + * @VM_FAULT_SIGSEGV: segmentation fault > + * @VM_FAULT_NOPAGE: ->fault installed the pte, not return page > + * @VM_FAULT_LOCKED: ->fault locked the returned page > + * @VM_FAULT_RETRY: ->fault blocked, must retry > + * @VM_FAULT_FALLBACK: huge page fault failed, fall back to small > + * @VM_FAULT_DONE_COW: ->fault has fully handled COW > + * @VM_FAULT_NEEDDSYNC: ->fault did not modify page tables and needs > + * fsync() to complete (for synchronous page faults > + * in DAX) > + * @VM_FAULT_HINDEX_MASK: mask HINDEX value > + * > + */ > +enum vm_fault_reason { > + VM_FAULT_OOM = (__force vm_fault_t)0x000001, > + VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002, > + VM_FAULT_MAJOR = (__force vm_fault_t)0x000004, > + VM_FAULT_WRITE = (__force vm_fault_t)0x000008, > + VM_FAULT_HWPOISON = (__force vm_fault_t)0x000010, > + VM_FAULT_HWPOISON_LARGE = (__force vm_fault_t)0x000020, > + VM_FAULT_SIGSEGV = (__force vm_fault_t)0x000040, > + VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100, > + VM_FAULT_LOCKED = (__force vm_fault_t)0x000200, > + VM_FAULT_RETRY = (__force vm_fault_t)0x000400, > + VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800, > + VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000, > + VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000, > + VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000, > +}; > + > +/* Encode hstate index for a hwpoisoned large page */ > +#define VM_FAULT_SET_HINDEX(x) ((__force vm_fault_t)((x) << 16)) > +#define VM_FAULT_GET_HINDEX(x) (((x) >> 16) & 0xf) > + > +#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | \ > + VM_FAULT_SIGSEGV | VM_FAULT_HWPOISON | \ > + VM_FAULT_HWPOISON_LARGE | VM_FAULT_FALLBACK) > + > +#define VM_FAULT_RESULT_TRACE \ > + { VM_FAULT_OOM, "OOM" }, \ > + { VM_FAULT_SIGBUS, "SIGBUS" }, \ > + { VM_FAULT_MAJOR, "MAJOR" }, \ > + { VM_FAULT_WRITE, "WRITE" }, \ > + { VM_FAULT_HWPOISON, "HWPOISON" }, \ > + { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > + { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > + { VM_FAULT_NOPAGE, "NOPAGE" }, \ > + { VM_FAULT_LOCKED, "LOCKED" }, \ > + { VM_FAULT_RETRY, "RETRY" }, \ > + { VM_FAULT_FALLBACK, "FALLBACK" }, \ > + { VM_FAULT_DONE_COW, "DONE_COW" }, \ > + { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > + > struct vm_special_mapping { > const char *name; /* The name, e.g. "[vdso]". */ > > -- > 1.9.1 > -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2018-11-15 1:47 ` Mike Rapoport @ 2018-11-24 4:46 ` Souptick Joarder 2018-12-14 5:05 ` Souptick Joarder 0 siblings, 1 reply; 12+ messages in thread From: Souptick Joarder @ 2018-11-24 4:46 UTC (permalink / raw) To: rppt Cc: Matthew Wilcox, Andrew Morton, Michal Hocko, Kirill A. Shutemov, Dan Williams, vbabka, riel, Linux-MM, linux-kernel On Thu, Nov 15, 2018 at 7:17 AM Mike Rapoport <rppt@linux.ibm.com> wrote: > > On Tue, Nov 06, 2018 at 05:36:42PM +0530, Souptick Joarder wrote: > > Page fault handlers are supposed to return VM_FAULT codes, > > but some drivers/file systems mistakenly return error > > numbers. Now that all drivers/file systems have been converted > > to use the vm_fault_t return type, change the type definition > > to no longer be compatible with 'int'. By making it an unsigned > > int, the function prototype becomes incompatible with a function > > which returns int. Sparse will detect any attempts to return a > > value which is not a VM_FAULT code. > > > > VM_FAULT_SET_HINDEX and VM_FAULT_GET_HINDEX values are changed > > to avoid conflict with other VM_FAULT codes. > > > > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> > > For the docs part > Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> > > > --- > > v2: Updated the change log and corrected the document part. > > name added to the enum that kernel-doc able to parse it. > > > > v3: Corrected the documentation. If no further comment, can we get this patch in queue for 4.21 ? > > > > include/linux/mm.h | 46 ------------------------------ > > include/linux/mm_types.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++- > > 2 files changed, 72 insertions(+), 47 deletions(-) > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index fcf9cc9..511a3ce 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -1267,52 +1267,6 @@ static inline void clear_page_pfmemalloc(struct page *page) > > } > > > > /* > > - * Different kinds of faults, as returned by handle_mm_fault(). > > - * Used to decide whether a process gets delivered SIGBUS or > > - * just gets major/minor fault counters bumped up. > > - */ > > - > > -#define VM_FAULT_OOM 0x0001 > > -#define VM_FAULT_SIGBUS 0x0002 > > -#define VM_FAULT_MAJOR 0x0004 > > -#define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ > > -#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */ > > -#define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */ > > -#define VM_FAULT_SIGSEGV 0x0040 > > - > > -#define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ > > -#define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ > > -#define VM_FAULT_RETRY 0x0400 /* ->fault blocked, must retry */ > > -#define VM_FAULT_FALLBACK 0x0800 /* huge page fault failed, fall back to small */ > > -#define VM_FAULT_DONE_COW 0x1000 /* ->fault has fully handled COW */ > > -#define VM_FAULT_NEEDDSYNC 0x2000 /* ->fault did not modify page tables > > - * and needs fsync() to complete (for > > - * synchronous page faults in DAX) */ > > - > > -#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \ > > - VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \ > > - VM_FAULT_FALLBACK) > > - > > -#define VM_FAULT_RESULT_TRACE \ > > - { VM_FAULT_OOM, "OOM" }, \ > > - { VM_FAULT_SIGBUS, "SIGBUS" }, \ > > - { VM_FAULT_MAJOR, "MAJOR" }, \ > > - { VM_FAULT_WRITE, "WRITE" }, \ > > - { VM_FAULT_HWPOISON, "HWPOISON" }, \ > > - { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > > - { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > > - { VM_FAULT_NOPAGE, "NOPAGE" }, \ > > - { VM_FAULT_LOCKED, "LOCKED" }, \ > > - { VM_FAULT_RETRY, "RETRY" }, \ > > - { VM_FAULT_FALLBACK, "FALLBACK" }, \ > > - { VM_FAULT_DONE_COW, "DONE_COW" }, \ > > - { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > > - > > -/* Encode hstate index for a hwpoisoned large page */ > > -#define VM_FAULT_SET_HINDEX(x) ((x) << 12) > > -#define VM_FAULT_GET_HINDEX(x) (((x) >> 12) & 0xf) > > - > > -/* > > * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. > > */ > > extern void pagefault_out_of_memory(void); > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > index 5ed8f62..cb25016 100644 > > --- a/include/linux/mm_types.h > > +++ b/include/linux/mm_types.h > > @@ -22,7 +22,6 @@ > > #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; > > @@ -609,6 +608,78 @@ static inline bool mm_tlb_flush_nested(struct mm_struct *mm) > > > > struct vm_fault; > > > > +/** > > + * typedef vm_fault_t - Return type for page fault handlers. > > + * > > + * Page fault handlers return a bitmask of %VM_FAULT values. > > + */ > > +typedef __bitwise unsigned int vm_fault_t; > > + > > +/** > > + * enum vm_fault_reason - Page fault handlers return a bitmask of > > + * these values to tell the core VM what happened when handling the > > + * fault. Used to decide whether a process gets delivered SIGBUS or > > + * just gets major/minor fault counters bumped up. > > + * > > + * @VM_FAULT_OOM: Out Of Memory > > + * @VM_FAULT_SIGBUS: Bad access > > + * @VM_FAULT_MAJOR: Page read from storage > > + * @VM_FAULT_WRITE: Special case for get_user_pages > > + * @VM_FAULT_HWPOISON: Hit poisoned small page > > + * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded > > + * in upper bits > > + * @VM_FAULT_SIGSEGV: segmentation fault > > + * @VM_FAULT_NOPAGE: ->fault installed the pte, not return page > > + * @VM_FAULT_LOCKED: ->fault locked the returned page > > + * @VM_FAULT_RETRY: ->fault blocked, must retry > > + * @VM_FAULT_FALLBACK: huge page fault failed, fall back to small > > + * @VM_FAULT_DONE_COW: ->fault has fully handled COW > > + * @VM_FAULT_NEEDDSYNC: ->fault did not modify page tables and needs > > + * fsync() to complete (for synchronous page faults > > + * in DAX) > > + * @VM_FAULT_HINDEX_MASK: mask HINDEX value > > + * > > + */ > > +enum vm_fault_reason { > > + VM_FAULT_OOM = (__force vm_fault_t)0x000001, > > + VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002, > > + VM_FAULT_MAJOR = (__force vm_fault_t)0x000004, > > + VM_FAULT_WRITE = (__force vm_fault_t)0x000008, > > + VM_FAULT_HWPOISON = (__force vm_fault_t)0x000010, > > + VM_FAULT_HWPOISON_LARGE = (__force vm_fault_t)0x000020, > > + VM_FAULT_SIGSEGV = (__force vm_fault_t)0x000040, > > + VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100, > > + VM_FAULT_LOCKED = (__force vm_fault_t)0x000200, > > + VM_FAULT_RETRY = (__force vm_fault_t)0x000400, > > + VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800, > > + VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000, > > + VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000, > > + VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000, > > +}; > > + > > +/* Encode hstate index for a hwpoisoned large page */ > > +#define VM_FAULT_SET_HINDEX(x) ((__force vm_fault_t)((x) << 16)) > > +#define VM_FAULT_GET_HINDEX(x) (((x) >> 16) & 0xf) > > + > > +#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | \ > > + VM_FAULT_SIGSEGV | VM_FAULT_HWPOISON | \ > > + VM_FAULT_HWPOISON_LARGE | VM_FAULT_FALLBACK) > > + > > +#define VM_FAULT_RESULT_TRACE \ > > + { VM_FAULT_OOM, "OOM" }, \ > > + { VM_FAULT_SIGBUS, "SIGBUS" }, \ > > + { VM_FAULT_MAJOR, "MAJOR" }, \ > > + { VM_FAULT_WRITE, "WRITE" }, \ > > + { VM_FAULT_HWPOISON, "HWPOISON" }, \ > > + { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > > + { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > > + { VM_FAULT_NOPAGE, "NOPAGE" }, \ > > + { VM_FAULT_LOCKED, "LOCKED" }, \ > > + { VM_FAULT_RETRY, "RETRY" }, \ > > + { VM_FAULT_FALLBACK, "FALLBACK" }, \ > > + { VM_FAULT_DONE_COW, "DONE_COW" }, \ > > + { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > > + > > struct vm_special_mapping { > > const char *name; /* The name, e.g. "[vdso]". */ > > > > -- > > 1.9.1 > > > > -- > Sincerely yours, > Mike. > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2018-11-24 4:46 ` Souptick Joarder @ 2018-12-14 5:05 ` Souptick Joarder 2019-01-07 6:17 ` Souptick Joarder 0 siblings, 1 reply; 12+ messages in thread From: Souptick Joarder @ 2018-12-14 5:05 UTC (permalink / raw) To: rppt Cc: Matthew Wilcox, Andrew Morton, Michal Hocko, Kirill A. Shutemov, Dan Williams, vbabka, riel, Linux-MM, linux-kernel Hi Andrew, On Sat, Nov 24, 2018 at 10:16 AM Souptick Joarder <jrdr.linux@gmail.com> wrote: > > On Thu, Nov 15, 2018 at 7:17 AM Mike Rapoport <rppt@linux.ibm.com> wrote: > > > > On Tue, Nov 06, 2018 at 05:36:42PM +0530, Souptick Joarder wrote: > > > Page fault handlers are supposed to return VM_FAULT codes, > > > but some drivers/file systems mistakenly return error > > > numbers. Now that all drivers/file systems have been converted > > > to use the vm_fault_t return type, change the type definition > > > to no longer be compatible with 'int'. By making it an unsigned > > > int, the function prototype becomes incompatible with a function > > > which returns int. Sparse will detect any attempts to return a > > > value which is not a VM_FAULT code. > > > > > > VM_FAULT_SET_HINDEX and VM_FAULT_GET_HINDEX values are changed > > > to avoid conflict with other VM_FAULT codes. > > > > > > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> > > > > For the docs part > > Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> > > > > > --- > > > v2: Updated the change log and corrected the document part. > > > name added to the enum that kernel-doc able to parse it. > > > > > > v3: Corrected the documentation. > > If no further comment, can we get this patch in queue for 4.21 ? Do I need to make any further improvement for this patch ? > > > > > > > include/linux/mm.h | 46 ------------------------------ > > > include/linux/mm_types.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++- > > > 2 files changed, 72 insertions(+), 47 deletions(-) > > > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > > index fcf9cc9..511a3ce 100644 > > > --- a/include/linux/mm.h > > > +++ b/include/linux/mm.h > > > @@ -1267,52 +1267,6 @@ static inline void clear_page_pfmemalloc(struct page *page) > > > } > > > > > > /* > > > - * Different kinds of faults, as returned by handle_mm_fault(). > > > - * Used to decide whether a process gets delivered SIGBUS or > > > - * just gets major/minor fault counters bumped up. > > > - */ > > > - > > > -#define VM_FAULT_OOM 0x0001 > > > -#define VM_FAULT_SIGBUS 0x0002 > > > -#define VM_FAULT_MAJOR 0x0004 > > > -#define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ > > > -#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */ > > > -#define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */ > > > -#define VM_FAULT_SIGSEGV 0x0040 > > > - > > > -#define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ > > > -#define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ > > > -#define VM_FAULT_RETRY 0x0400 /* ->fault blocked, must retry */ > > > -#define VM_FAULT_FALLBACK 0x0800 /* huge page fault failed, fall back to small */ > > > -#define VM_FAULT_DONE_COW 0x1000 /* ->fault has fully handled COW */ > > > -#define VM_FAULT_NEEDDSYNC 0x2000 /* ->fault did not modify page tables > > > - * and needs fsync() to complete (for > > > - * synchronous page faults in DAX) */ > > > - > > > -#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \ > > > - VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \ > > > - VM_FAULT_FALLBACK) > > > - > > > -#define VM_FAULT_RESULT_TRACE \ > > > - { VM_FAULT_OOM, "OOM" }, \ > > > - { VM_FAULT_SIGBUS, "SIGBUS" }, \ > > > - { VM_FAULT_MAJOR, "MAJOR" }, \ > > > - { VM_FAULT_WRITE, "WRITE" }, \ > > > - { VM_FAULT_HWPOISON, "HWPOISON" }, \ > > > - { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > > > - { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > > > - { VM_FAULT_NOPAGE, "NOPAGE" }, \ > > > - { VM_FAULT_LOCKED, "LOCKED" }, \ > > > - { VM_FAULT_RETRY, "RETRY" }, \ > > > - { VM_FAULT_FALLBACK, "FALLBACK" }, \ > > > - { VM_FAULT_DONE_COW, "DONE_COW" }, \ > > > - { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > > > - > > > -/* Encode hstate index for a hwpoisoned large page */ > > > -#define VM_FAULT_SET_HINDEX(x) ((x) << 12) > > > -#define VM_FAULT_GET_HINDEX(x) (((x) >> 12) & 0xf) > > > - > > > -/* > > > * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. > > > */ > > > extern void pagefault_out_of_memory(void); > > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > > index 5ed8f62..cb25016 100644 > > > --- a/include/linux/mm_types.h > > > +++ b/include/linux/mm_types.h > > > @@ -22,7 +22,6 @@ > > > #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; > > > @@ -609,6 +608,78 @@ static inline bool mm_tlb_flush_nested(struct mm_struct *mm) > > > > > > struct vm_fault; > > > > > > +/** > > > + * typedef vm_fault_t - Return type for page fault handlers. > > > + * > > > + * Page fault handlers return a bitmask of %VM_FAULT values. > > > + */ > > > +typedef __bitwise unsigned int vm_fault_t; > > > + > > > +/** > > > + * enum vm_fault_reason - Page fault handlers return a bitmask of > > > + * these values to tell the core VM what happened when handling the > > > + * fault. Used to decide whether a process gets delivered SIGBUS or > > > + * just gets major/minor fault counters bumped up. > > > + * > > > + * @VM_FAULT_OOM: Out Of Memory > > > + * @VM_FAULT_SIGBUS: Bad access > > > + * @VM_FAULT_MAJOR: Page read from storage > > > + * @VM_FAULT_WRITE: Special case for get_user_pages > > > + * @VM_FAULT_HWPOISON: Hit poisoned small page > > > + * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded > > > + * in upper bits > > > + * @VM_FAULT_SIGSEGV: segmentation fault > > > + * @VM_FAULT_NOPAGE: ->fault installed the pte, not return page > > > + * @VM_FAULT_LOCKED: ->fault locked the returned page > > > + * @VM_FAULT_RETRY: ->fault blocked, must retry > > > + * @VM_FAULT_FALLBACK: huge page fault failed, fall back to small > > > + * @VM_FAULT_DONE_COW: ->fault has fully handled COW > > > + * @VM_FAULT_NEEDDSYNC: ->fault did not modify page tables and needs > > > + * fsync() to complete (for synchronous page faults > > > + * in DAX) > > > + * @VM_FAULT_HINDEX_MASK: mask HINDEX value > > > + * > > > + */ > > > +enum vm_fault_reason { > > > + VM_FAULT_OOM = (__force vm_fault_t)0x000001, > > > + VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002, > > > + VM_FAULT_MAJOR = (__force vm_fault_t)0x000004, > > > + VM_FAULT_WRITE = (__force vm_fault_t)0x000008, > > > + VM_FAULT_HWPOISON = (__force vm_fault_t)0x000010, > > > + VM_FAULT_HWPOISON_LARGE = (__force vm_fault_t)0x000020, > > > + VM_FAULT_SIGSEGV = (__force vm_fault_t)0x000040, > > > + VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100, > > > + VM_FAULT_LOCKED = (__force vm_fault_t)0x000200, > > > + VM_FAULT_RETRY = (__force vm_fault_t)0x000400, > > > + VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800, > > > + VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000, > > > + VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000, > > > + VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000, > > > +}; > > > + > > > +/* Encode hstate index for a hwpoisoned large page */ > > > +#define VM_FAULT_SET_HINDEX(x) ((__force vm_fault_t)((x) << 16)) > > > +#define VM_FAULT_GET_HINDEX(x) (((x) >> 16) & 0xf) > > > + > > > +#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | \ > > > + VM_FAULT_SIGSEGV | VM_FAULT_HWPOISON | \ > > > + VM_FAULT_HWPOISON_LARGE | VM_FAULT_FALLBACK) > > > + > > > +#define VM_FAULT_RESULT_TRACE \ > > > + { VM_FAULT_OOM, "OOM" }, \ > > > + { VM_FAULT_SIGBUS, "SIGBUS" }, \ > > > + { VM_FAULT_MAJOR, "MAJOR" }, \ > > > + { VM_FAULT_WRITE, "WRITE" }, \ > > > + { VM_FAULT_HWPOISON, "HWPOISON" }, \ > > > + { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > > > + { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > > > + { VM_FAULT_NOPAGE, "NOPAGE" }, \ > > > + { VM_FAULT_LOCKED, "LOCKED" }, \ > > > + { VM_FAULT_RETRY, "RETRY" }, \ > > > + { VM_FAULT_FALLBACK, "FALLBACK" }, \ > > > + { VM_FAULT_DONE_COW, "DONE_COW" }, \ > > > + { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > > > + > > > struct vm_special_mapping { > > > const char *name; /* The name, e.g. "[vdso]". */ > > > > > > -- > > > 1.9.1 > > > > > > > -- > > Sincerely yours, > > Mike. > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2018-12-14 5:05 ` Souptick Joarder @ 2019-01-07 6:17 ` Souptick Joarder 2019-01-07 6:17 ` Souptick Joarder 2019-01-07 22:44 ` Andrew Morton 0 siblings, 2 replies; 12+ messages in thread From: Souptick Joarder @ 2019-01-07 6:17 UTC (permalink / raw) To: rppt, Andrew Morton, Michal Hocko, Dan Williams, Matthew Wilcox Cc: Kirill A. Shutemov, vbabka, riel, Linux-MM, linux-kernel On Fri, Dec 14, 2018 at 10:35 AM Souptick Joarder <jrdr.linux@gmail.com> wrote: > > Hi Andrew, > > On Sat, Nov 24, 2018 at 10:16 AM Souptick Joarder <jrdr.linux@gmail.com> wrote: > > > > On Thu, Nov 15, 2018 at 7:17 AM Mike Rapoport <rppt@linux.ibm.com> wrote: > > > > > > On Tue, Nov 06, 2018 at 05:36:42PM +0530, Souptick Joarder wrote: > > > > Page fault handlers are supposed to return VM_FAULT codes, > > > > but some drivers/file systems mistakenly return error > > > > numbers. Now that all drivers/file systems have been converted > > > > to use the vm_fault_t return type, change the type definition > > > > to no longer be compatible with 'int'. By making it an unsigned > > > > int, the function prototype becomes incompatible with a function > > > > which returns int. Sparse will detect any attempts to return a > > > > value which is not a VM_FAULT code. > > > > > > > > VM_FAULT_SET_HINDEX and VM_FAULT_GET_HINDEX values are changed > > > > to avoid conflict with other VM_FAULT codes. > > > > > > > > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> > > > > > > For the docs part > > > Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> > > > > > > > --- > > > > v2: Updated the change log and corrected the document part. > > > > name added to the enum that kernel-doc able to parse it. > > > > > > > > v3: Corrected the documentation. > > > > If no further comment, can we get this patch in queue for 4.21 ? > > Do I need to make any further improvement for this patch ? If no further comment, can we get this patch in queue for 5.0-rcX ? > > > > > > > > > > include/linux/mm.h | 46 ------------------------------ > > > > include/linux/mm_types.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++- > > > > 2 files changed, 72 insertions(+), 47 deletions(-) > > > > > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > > > index fcf9cc9..511a3ce 100644 > > > > --- a/include/linux/mm.h > > > > +++ b/include/linux/mm.h > > > > @@ -1267,52 +1267,6 @@ static inline void clear_page_pfmemalloc(struct page *page) > > > > } > > > > > > > > /* > > > > - * Different kinds of faults, as returned by handle_mm_fault(). > > > > - * Used to decide whether a process gets delivered SIGBUS or > > > > - * just gets major/minor fault counters bumped up. > > > > - */ > > > > - > > > > -#define VM_FAULT_OOM 0x0001 > > > > -#define VM_FAULT_SIGBUS 0x0002 > > > > -#define VM_FAULT_MAJOR 0x0004 > > > > -#define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ > > > > -#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */ > > > > -#define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */ > > > > -#define VM_FAULT_SIGSEGV 0x0040 > > > > - > > > > -#define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ > > > > -#define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ > > > > -#define VM_FAULT_RETRY 0x0400 /* ->fault blocked, must retry */ > > > > -#define VM_FAULT_FALLBACK 0x0800 /* huge page fault failed, fall back to small */ > > > > -#define VM_FAULT_DONE_COW 0x1000 /* ->fault has fully handled COW */ > > > > -#define VM_FAULT_NEEDDSYNC 0x2000 /* ->fault did not modify page tables > > > > - * and needs fsync() to complete (for > > > > - * synchronous page faults in DAX) */ > > > > - > > > > -#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \ > > > > - VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \ > > > > - VM_FAULT_FALLBACK) > > > > - > > > > -#define VM_FAULT_RESULT_TRACE \ > > > > - { VM_FAULT_OOM, "OOM" }, \ > > > > - { VM_FAULT_SIGBUS, "SIGBUS" }, \ > > > > - { VM_FAULT_MAJOR, "MAJOR" }, \ > > > > - { VM_FAULT_WRITE, "WRITE" }, \ > > > > - { VM_FAULT_HWPOISON, "HWPOISON" }, \ > > > > - { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > > > > - { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > > > > - { VM_FAULT_NOPAGE, "NOPAGE" }, \ > > > > - { VM_FAULT_LOCKED, "LOCKED" }, \ > > > > - { VM_FAULT_RETRY, "RETRY" }, \ > > > > - { VM_FAULT_FALLBACK, "FALLBACK" }, \ > > > > - { VM_FAULT_DONE_COW, "DONE_COW" }, \ > > > > - { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > > > > - > > > > -/* Encode hstate index for a hwpoisoned large page */ > > > > -#define VM_FAULT_SET_HINDEX(x) ((x) << 12) > > > > -#define VM_FAULT_GET_HINDEX(x) (((x) >> 12) & 0xf) > > > > - > > > > -/* > > > > * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. > > > > */ > > > > extern void pagefault_out_of_memory(void); > > > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > > > index 5ed8f62..cb25016 100644 > > > > --- a/include/linux/mm_types.h > > > > +++ b/include/linux/mm_types.h > > > > @@ -22,7 +22,6 @@ > > > > #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; > > > > @@ -609,6 +608,78 @@ static inline bool mm_tlb_flush_nested(struct mm_struct *mm) > > > > > > > > struct vm_fault; > > > > > > > > +/** > > > > + * typedef vm_fault_t - Return type for page fault handlers. > > > > + * > > > > + * Page fault handlers return a bitmask of %VM_FAULT values. > > > > + */ > > > > +typedef __bitwise unsigned int vm_fault_t; > > > > + > > > > +/** > > > > + * enum vm_fault_reason - Page fault handlers return a bitmask of > > > > + * these values to tell the core VM what happened when handling the > > > > + * fault. Used to decide whether a process gets delivered SIGBUS or > > > > + * just gets major/minor fault counters bumped up. > > > > + * > > > > + * @VM_FAULT_OOM: Out Of Memory > > > > + * @VM_FAULT_SIGBUS: Bad access > > > > + * @VM_FAULT_MAJOR: Page read from storage > > > > + * @VM_FAULT_WRITE: Special case for get_user_pages > > > > + * @VM_FAULT_HWPOISON: Hit poisoned small page > > > > + * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded > > > > + * in upper bits > > > > + * @VM_FAULT_SIGSEGV: segmentation fault > > > > + * @VM_FAULT_NOPAGE: ->fault installed the pte, not return page > > > > + * @VM_FAULT_LOCKED: ->fault locked the returned page > > > > + * @VM_FAULT_RETRY: ->fault blocked, must retry > > > > + * @VM_FAULT_FALLBACK: huge page fault failed, fall back to small > > > > + * @VM_FAULT_DONE_COW: ->fault has fully handled COW > > > > + * @VM_FAULT_NEEDDSYNC: ->fault did not modify page tables and needs > > > > + * fsync() to complete (for synchronous page faults > > > > + * in DAX) > > > > + * @VM_FAULT_HINDEX_MASK: mask HINDEX value > > > > + * > > > > + */ > > > > +enum vm_fault_reason { > > > > + VM_FAULT_OOM = (__force vm_fault_t)0x000001, > > > > + VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002, > > > > + VM_FAULT_MAJOR = (__force vm_fault_t)0x000004, > > > > + VM_FAULT_WRITE = (__force vm_fault_t)0x000008, > > > > + VM_FAULT_HWPOISON = (__force vm_fault_t)0x000010, > > > > + VM_FAULT_HWPOISON_LARGE = (__force vm_fault_t)0x000020, > > > > + VM_FAULT_SIGSEGV = (__force vm_fault_t)0x000040, > > > > + VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100, > > > > + VM_FAULT_LOCKED = (__force vm_fault_t)0x000200, > > > > + VM_FAULT_RETRY = (__force vm_fault_t)0x000400, > > > > + VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800, > > > > + VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000, > > > > + VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000, > > > > + VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000, > > > > +}; > > > > + > > > > +/* Encode hstate index for a hwpoisoned large page */ > > > > +#define VM_FAULT_SET_HINDEX(x) ((__force vm_fault_t)((x) << 16)) > > > > +#define VM_FAULT_GET_HINDEX(x) (((x) >> 16) & 0xf) > > > > + > > > > +#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | \ > > > > + VM_FAULT_SIGSEGV | VM_FAULT_HWPOISON | \ > > > > + VM_FAULT_HWPOISON_LARGE | VM_FAULT_FALLBACK) > > > > + > > > > +#define VM_FAULT_RESULT_TRACE \ > > > > + { VM_FAULT_OOM, "OOM" }, \ > > > > + { VM_FAULT_SIGBUS, "SIGBUS" }, \ > > > > + { VM_FAULT_MAJOR, "MAJOR" }, \ > > > > + { VM_FAULT_WRITE, "WRITE" }, \ > > > > + { VM_FAULT_HWPOISON, "HWPOISON" }, \ > > > > + { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > > > > + { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > > > > + { VM_FAULT_NOPAGE, "NOPAGE" }, \ > > > > + { VM_FAULT_LOCKED, "LOCKED" }, \ > > > > + { VM_FAULT_RETRY, "RETRY" }, \ > > > > + { VM_FAULT_FALLBACK, "FALLBACK" }, \ > > > > + { VM_FAULT_DONE_COW, "DONE_COW" }, \ > > > > + { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > > > > + > > > > struct vm_special_mapping { > > > > const char *name; /* The name, e.g. "[vdso]". */ > > > > > > > > -- > > > > 1.9.1 > > > > > > > > > > -- > > > Sincerely yours, > > > Mike. > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2019-01-07 6:17 ` Souptick Joarder @ 2019-01-07 6:17 ` Souptick Joarder 2019-01-07 22:44 ` Andrew Morton 1 sibling, 0 replies; 12+ messages in thread From: Souptick Joarder @ 2019-01-07 6:17 UTC (permalink / raw) To: rppt, Andrew Morton, Michal Hocko, Dan Williams, Matthew Wilcox Cc: Kirill A. Shutemov, vbabka, riel, Linux-MM, linux-kernel On Fri, Dec 14, 2018 at 10:35 AM Souptick Joarder <jrdr.linux@gmail.com> wrote: > > Hi Andrew, > > On Sat, Nov 24, 2018 at 10:16 AM Souptick Joarder <jrdr.linux@gmail.com> wrote: > > > > On Thu, Nov 15, 2018 at 7:17 AM Mike Rapoport <rppt@linux.ibm.com> wrote: > > > > > > On Tue, Nov 06, 2018 at 05:36:42PM +0530, Souptick Joarder wrote: > > > > Page fault handlers are supposed to return VM_FAULT codes, > > > > but some drivers/file systems mistakenly return error > > > > numbers. Now that all drivers/file systems have been converted > > > > to use the vm_fault_t return type, change the type definition > > > > to no longer be compatible with 'int'. By making it an unsigned > > > > int, the function prototype becomes incompatible with a function > > > > which returns int. Sparse will detect any attempts to return a > > > > value which is not a VM_FAULT code. > > > > > > > > VM_FAULT_SET_HINDEX and VM_FAULT_GET_HINDEX values are changed > > > > to avoid conflict with other VM_FAULT codes. > > > > > > > > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> > > > > > > For the docs part > > > Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> > > > > > > > --- > > > > v2: Updated the change log and corrected the document part. > > > > name added to the enum that kernel-doc able to parse it. > > > > > > > > v3: Corrected the documentation. > > > > If no further comment, can we get this patch in queue for 4.21 ? > > Do I need to make any further improvement for this patch ? If no further comment, can we get this patch in queue for 5.0-rcX ? > > > > > > > > > > include/linux/mm.h | 46 ------------------------------ > > > > include/linux/mm_types.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++- > > > > 2 files changed, 72 insertions(+), 47 deletions(-) > > > > > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > > > index fcf9cc9..511a3ce 100644 > > > > --- a/include/linux/mm.h > > > > +++ b/include/linux/mm.h > > > > @@ -1267,52 +1267,6 @@ static inline void clear_page_pfmemalloc(struct page *page) > > > > } > > > > > > > > /* > > > > - * Different kinds of faults, as returned by handle_mm_fault(). > > > > - * Used to decide whether a process gets delivered SIGBUS or > > > > - * just gets major/minor fault counters bumped up. > > > > - */ > > > > - > > > > -#define VM_FAULT_OOM 0x0001 > > > > -#define VM_FAULT_SIGBUS 0x0002 > > > > -#define VM_FAULT_MAJOR 0x0004 > > > > -#define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ > > > > -#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */ > > > > -#define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */ > > > > -#define VM_FAULT_SIGSEGV 0x0040 > > > > - > > > > -#define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ > > > > -#define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ > > > > -#define VM_FAULT_RETRY 0x0400 /* ->fault blocked, must retry */ > > > > -#define VM_FAULT_FALLBACK 0x0800 /* huge page fault failed, fall back to small */ > > > > -#define VM_FAULT_DONE_COW 0x1000 /* ->fault has fully handled COW */ > > > > -#define VM_FAULT_NEEDDSYNC 0x2000 /* ->fault did not modify page tables > > > > - * and needs fsync() to complete (for > > > > - * synchronous page faults in DAX) */ > > > > - > > > > -#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \ > > > > - VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \ > > > > - VM_FAULT_FALLBACK) > > > > - > > > > -#define VM_FAULT_RESULT_TRACE \ > > > > - { VM_FAULT_OOM, "OOM" }, \ > > > > - { VM_FAULT_SIGBUS, "SIGBUS" }, \ > > > > - { VM_FAULT_MAJOR, "MAJOR" }, \ > > > > - { VM_FAULT_WRITE, "WRITE" }, \ > > > > - { VM_FAULT_HWPOISON, "HWPOISON" }, \ > > > > - { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > > > > - { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > > > > - { VM_FAULT_NOPAGE, "NOPAGE" }, \ > > > > - { VM_FAULT_LOCKED, "LOCKED" }, \ > > > > - { VM_FAULT_RETRY, "RETRY" }, \ > > > > - { VM_FAULT_FALLBACK, "FALLBACK" }, \ > > > > - { VM_FAULT_DONE_COW, "DONE_COW" }, \ > > > > - { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > > > > - > > > > -/* Encode hstate index for a hwpoisoned large page */ > > > > -#define VM_FAULT_SET_HINDEX(x) ((x) << 12) > > > > -#define VM_FAULT_GET_HINDEX(x) (((x) >> 12) & 0xf) > > > > - > > > > -/* > > > > * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. > > > > */ > > > > extern void pagefault_out_of_memory(void); > > > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > > > index 5ed8f62..cb25016 100644 > > > > --- a/include/linux/mm_types.h > > > > +++ b/include/linux/mm_types.h > > > > @@ -22,7 +22,6 @@ > > > > #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; > > > > @@ -609,6 +608,78 @@ static inline bool mm_tlb_flush_nested(struct mm_struct *mm) > > > > > > > > struct vm_fault; > > > > > > > > +/** > > > > + * typedef vm_fault_t - Return type for page fault handlers. > > > > + * > > > > + * Page fault handlers return a bitmask of %VM_FAULT values. > > > > + */ > > > > +typedef __bitwise unsigned int vm_fault_t; > > > > + > > > > +/** > > > > + * enum vm_fault_reason - Page fault handlers return a bitmask of > > > > + * these values to tell the core VM what happened when handling the > > > > + * fault. Used to decide whether a process gets delivered SIGBUS or > > > > + * just gets major/minor fault counters bumped up. > > > > + * > > > > + * @VM_FAULT_OOM: Out Of Memory > > > > + * @VM_FAULT_SIGBUS: Bad access > > > > + * @VM_FAULT_MAJOR: Page read from storage > > > > + * @VM_FAULT_WRITE: Special case for get_user_pages > > > > + * @VM_FAULT_HWPOISON: Hit poisoned small page > > > > + * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded > > > > + * in upper bits > > > > + * @VM_FAULT_SIGSEGV: segmentation fault > > > > + * @VM_FAULT_NOPAGE: ->fault installed the pte, not return page > > > > + * @VM_FAULT_LOCKED: ->fault locked the returned page > > > > + * @VM_FAULT_RETRY: ->fault blocked, must retry > > > > + * @VM_FAULT_FALLBACK: huge page fault failed, fall back to small > > > > + * @VM_FAULT_DONE_COW: ->fault has fully handled COW > > > > + * @VM_FAULT_NEEDDSYNC: ->fault did not modify page tables and needs > > > > + * fsync() to complete (for synchronous page faults > > > > + * in DAX) > > > > + * @VM_FAULT_HINDEX_MASK: mask HINDEX value > > > > + * > > > > + */ > > > > +enum vm_fault_reason { > > > > + VM_FAULT_OOM = (__force vm_fault_t)0x000001, > > > > + VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002, > > > > + VM_FAULT_MAJOR = (__force vm_fault_t)0x000004, > > > > + VM_FAULT_WRITE = (__force vm_fault_t)0x000008, > > > > + VM_FAULT_HWPOISON = (__force vm_fault_t)0x000010, > > > > + VM_FAULT_HWPOISON_LARGE = (__force vm_fault_t)0x000020, > > > > + VM_FAULT_SIGSEGV = (__force vm_fault_t)0x000040, > > > > + VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100, > > > > + VM_FAULT_LOCKED = (__force vm_fault_t)0x000200, > > > > + VM_FAULT_RETRY = (__force vm_fault_t)0x000400, > > > > + VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800, > > > > + VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000, > > > > + VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000, > > > > + VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000, > > > > +}; > > > > + > > > > +/* Encode hstate index for a hwpoisoned large page */ > > > > +#define VM_FAULT_SET_HINDEX(x) ((__force vm_fault_t)((x) << 16)) > > > > +#define VM_FAULT_GET_HINDEX(x) (((x) >> 16) & 0xf) > > > > + > > > > +#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | \ > > > > + VM_FAULT_SIGSEGV | VM_FAULT_HWPOISON | \ > > > > + VM_FAULT_HWPOISON_LARGE | VM_FAULT_FALLBACK) > > > > + > > > > +#define VM_FAULT_RESULT_TRACE \ > > > > + { VM_FAULT_OOM, "OOM" }, \ > > > > + { VM_FAULT_SIGBUS, "SIGBUS" }, \ > > > > + { VM_FAULT_MAJOR, "MAJOR" }, \ > > > > + { VM_FAULT_WRITE, "WRITE" }, \ > > > > + { VM_FAULT_HWPOISON, "HWPOISON" }, \ > > > > + { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ > > > > + { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ > > > > + { VM_FAULT_NOPAGE, "NOPAGE" }, \ > > > > + { VM_FAULT_LOCKED, "LOCKED" }, \ > > > > + { VM_FAULT_RETRY, "RETRY" }, \ > > > > + { VM_FAULT_FALLBACK, "FALLBACK" }, \ > > > > + { VM_FAULT_DONE_COW, "DONE_COW" }, \ > > > > + { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" } > > > > + > > > > struct vm_special_mapping { > > > > const char *name; /* The name, e.g. "[vdso]". */ > > > > > > > > -- > > > > 1.9.1 > > > > > > > > > > -- > > > Sincerely yours, > > > Mike. > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2019-01-07 6:17 ` Souptick Joarder 2019-01-07 6:17 ` Souptick Joarder @ 2019-01-07 22:44 ` Andrew Morton 2019-01-08 11:53 ` Souptick Joarder 1 sibling, 1 reply; 12+ messages in thread From: Andrew Morton @ 2019-01-07 22:44 UTC (permalink / raw) To: Souptick Joarder Cc: rppt, Michal Hocko, Dan Williams, Matthew Wilcox, Kirill A. Shutemov, vbabka, riel, Linux-MM, linux-kernel On Mon, 7 Jan 2019 11:47:12 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote: > > Do I need to make any further improvement for this patch ? > > If no further comment, can we get this patch in queue for 5.0-rcX ? I stopped paying attention a while ago, sorry. Please resend everything which you believe is ready to go. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2019-01-07 22:44 ` Andrew Morton @ 2019-01-08 11:53 ` Souptick Joarder 2019-01-08 11:53 ` Souptick Joarder 0 siblings, 1 reply; 12+ messages in thread From: Souptick Joarder @ 2019-01-08 11:53 UTC (permalink / raw) To: Andrew Morton Cc: rppt, Michal Hocko, Dan Williams, Matthew Wilcox, Kirill A. Shutemov, vbabka, riel, Linux-MM, linux-kernel On Tue, Jan 8, 2019 at 4:14 AM Andrew Morton <akpm@linux-foundation.org> wrote: > > On Mon, 7 Jan 2019 11:47:12 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote: > > > > Do I need to make any further improvement for this patch ? > > > > If no further comment, can we get this patch in queue for 5.0-rcX ? > > I stopped paying attention a while ago, sorry. > > Please resend everything which you believe is ready to go. Sure, I will resend. no prob :) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] mm: Create the new vm_fault_t type 2019-01-08 11:53 ` Souptick Joarder @ 2019-01-08 11:53 ` Souptick Joarder 0 siblings, 0 replies; 12+ messages in thread From: Souptick Joarder @ 2019-01-08 11:53 UTC (permalink / raw) To: Andrew Morton Cc: rppt, Michal Hocko, Dan Williams, Matthew Wilcox, Kirill A. Shutemov, vbabka, riel, Linux-MM, linux-kernel On Tue, Jan 8, 2019 at 4:14 AM Andrew Morton <akpm@linux-foundation.org> wrote: > > On Mon, 7 Jan 2019 11:47:12 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote: > > > > Do I need to make any further improvement for this patch ? > > > > If no further comment, can we get this patch in queue for 5.0-rcX ? > > I stopped paying attention a while ago, sorry. > > Please resend everything which you believe is ready to go. Sure, I will resend. no prob :) ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-01-08 11:53 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-11-06 12:06 [PATCH v3] mm: Create the new vm_fault_t type Souptick Joarder 2018-11-06 12:10 ` Michal Hocko 2018-11-14 5:13 ` Souptick Joarder 2018-11-14 9:59 ` William Kucharski 2018-11-15 1:47 ` Mike Rapoport 2018-11-24 4:46 ` Souptick Joarder 2018-12-14 5:05 ` Souptick Joarder 2019-01-07 6:17 ` Souptick Joarder 2019-01-07 6:17 ` Souptick Joarder 2019-01-07 22:44 ` Andrew Morton 2019-01-08 11:53 ` Souptick Joarder 2019-01-08 11:53 ` Souptick Joarder
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).