Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-05 Thread Souptick Joarder
On Tue, Nov 6, 2018 at 11:51 AM Mike Rapoport  wrote:
>
> On Mon, Nov 05, 2018 at 07:23:55PM +0530, Souptick Joarder wrote:
> > On Mon, Nov 5, 2018 at 2:43 PM Mike Rapoport  wrote:
> > >
> > > On Mon, Nov 05, 2018 at 11:14:17AM +0530, Souptick Joarder wrote:
> > > > Hi Matthew,
> > > >
> > > > On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
> > > > >
> > > > > On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > > > > > On Sat, Nov 03, 2018 at 10:35:04AM +0530, Souptick Joarder wrote:
>
> > > > > > > +typedef __bitwise unsigned int vm_fault_t;
> > > > > > > +
> > > > > > > +/**
> > > > > > > + * enum - VM_FAULT code
> > > > > >
> > > > > > Can you document an anonymous enum?  I've never tried.  Did you run 
> > > > > > this
> > > > > > through 'make htmldocs'?
> > > > >
> > > > > You cannot document an anonymous enum.
> > > >
> > > > I assume, you are pointing to Document folder and I don't know if this
> > > > enum need to be documented or not.
> > >
> > > The enum should be documented, even if it's documentation is (yet) not
> > > linked anywhere in the Documentation/
> > >
> > > > I didn't run 'make htmldocs' as there is no document related changes.
> > >
> > > You can verify that kernel-doc can parse your documentation by running
> > >
> > > scripts/kernel-doc -none -v 
> >
> > I run "scripts/kernel-doc -none -v include/linux/mm_types.h" and it is 
> > showing
> > below error and warning which is linked to enum in discussion.
> >
> > include/linux/mm_types.h:612: info: Scanning doc for typedef vm_fault_t
> > include/linux/mm_types.h:623: info: Scanning doc for enum
> > include/linux/mm_types.h:628: warning: contents before sections
> > include/linux/mm_types.h:660: error: Cannot parse enum!
> > 1 errors
> > 1 warnings
> >
> > Shall I keep the documentation for enum or remove it from this patch ?
>
> The documentation should be there, you just need to add a name for the
> enum. Then kernel-doc will be able to parse it.
>
> > > > >
> > > > > > > + * This enum is used to track the VM_FAULT code return by page
> > > > > > > + * fault handlers.
> > > > > >
>
> I think that the enum description should also include the text from the
> comment that described VM_FAULT_* defines:
>
> /*
>  * 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.
>  */
>

Ok, will add  both in v2. Thanks.


Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-05 Thread Souptick Joarder
On Tue, Nov 6, 2018 at 11:51 AM Mike Rapoport  wrote:
>
> On Mon, Nov 05, 2018 at 07:23:55PM +0530, Souptick Joarder wrote:
> > On Mon, Nov 5, 2018 at 2:43 PM Mike Rapoport  wrote:
> > >
> > > On Mon, Nov 05, 2018 at 11:14:17AM +0530, Souptick Joarder wrote:
> > > > Hi Matthew,
> > > >
> > > > On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
> > > > >
> > > > > On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > > > > > On Sat, Nov 03, 2018 at 10:35:04AM +0530, Souptick Joarder wrote:
>
> > > > > > > +typedef __bitwise unsigned int vm_fault_t;
> > > > > > > +
> > > > > > > +/**
> > > > > > > + * enum - VM_FAULT code
> > > > > >
> > > > > > Can you document an anonymous enum?  I've never tried.  Did you run 
> > > > > > this
> > > > > > through 'make htmldocs'?
> > > > >
> > > > > You cannot document an anonymous enum.
> > > >
> > > > I assume, you are pointing to Document folder and I don't know if this
> > > > enum need to be documented or not.
> > >
> > > The enum should be documented, even if it's documentation is (yet) not
> > > linked anywhere in the Documentation/
> > >
> > > > I didn't run 'make htmldocs' as there is no document related changes.
> > >
> > > You can verify that kernel-doc can parse your documentation by running
> > >
> > > scripts/kernel-doc -none -v 
> >
> > I run "scripts/kernel-doc -none -v include/linux/mm_types.h" and it is 
> > showing
> > below error and warning which is linked to enum in discussion.
> >
> > include/linux/mm_types.h:612: info: Scanning doc for typedef vm_fault_t
> > include/linux/mm_types.h:623: info: Scanning doc for enum
> > include/linux/mm_types.h:628: warning: contents before sections
> > include/linux/mm_types.h:660: error: Cannot parse enum!
> > 1 errors
> > 1 warnings
> >
> > Shall I keep the documentation for enum or remove it from this patch ?
>
> The documentation should be there, you just need to add a name for the
> enum. Then kernel-doc will be able to parse it.
>
> > > > >
> > > > > > > + * This enum is used to track the VM_FAULT code return by page
> > > > > > > + * fault handlers.
> > > > > >
>
> I think that the enum description should also include the text from the
> comment that described VM_FAULT_* defines:
>
> /*
>  * 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.
>  */
>

Ok, will add  both in v2. Thanks.


Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-05 Thread Mike Rapoport
On Mon, Nov 05, 2018 at 07:23:55PM +0530, Souptick Joarder wrote:
> On Mon, Nov 5, 2018 at 2:43 PM Mike Rapoport  wrote:
> >
> > On Mon, Nov 05, 2018 at 11:14:17AM +0530, Souptick Joarder wrote:
> > > Hi Matthew,
> > >
> > > On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
> > > >
> > > > On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > > > > On Sat, Nov 03, 2018 at 10:35:04AM +0530, Souptick Joarder wrote:

> > > > > > +typedef __bitwise unsigned int vm_fault_t;
> > > > > > +
> > > > > > +/**
> > > > > > + * enum - VM_FAULT code
> > > > >
> > > > > Can you document an anonymous enum?  I've never tried.  Did you run 
> > > > > this
> > > > > through 'make htmldocs'?
> > > >
> > > > You cannot document an anonymous enum.
> > >
> > > I assume, you are pointing to Document folder and I don't know if this
> > > enum need to be documented or not.
> >
> > The enum should be documented, even if it's documentation is (yet) not
> > linked anywhere in the Documentation/
> >
> > > I didn't run 'make htmldocs' as there is no document related changes.
> >
> > You can verify that kernel-doc can parse your documentation by running
> >
> > scripts/kernel-doc -none -v 
> 
> I run "scripts/kernel-doc -none -v include/linux/mm_types.h" and it is showing
> below error and warning which is linked to enum in discussion.
> 
> include/linux/mm_types.h:612: info: Scanning doc for typedef vm_fault_t
> include/linux/mm_types.h:623: info: Scanning doc for enum
> include/linux/mm_types.h:628: warning: contents before sections
> include/linux/mm_types.h:660: error: Cannot parse enum!
> 1 errors
> 1 warnings
> 
> Shall I keep the documentation for enum or remove it from this patch ?

The documentation should be there, you just need to add a name for the
enum. Then kernel-doc will be able to parse it.
 
> > > >
> > > > > > + * This enum is used to track the VM_FAULT code return by page
> > > > > > + * fault handlers.
> > > > >

I think that the enum description should also include the text from the
comment that described VM_FAULT_* defines:

/*
 * 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.
 */



-- 
Sincerely yours,
Mike.



Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-05 Thread Mike Rapoport
On Mon, Nov 05, 2018 at 07:23:55PM +0530, Souptick Joarder wrote:
> On Mon, Nov 5, 2018 at 2:43 PM Mike Rapoport  wrote:
> >
> > On Mon, Nov 05, 2018 at 11:14:17AM +0530, Souptick Joarder wrote:
> > > Hi Matthew,
> > >
> > > On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
> > > >
> > > > On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > > > > On Sat, Nov 03, 2018 at 10:35:04AM +0530, Souptick Joarder wrote:

> > > > > > +typedef __bitwise unsigned int vm_fault_t;
> > > > > > +
> > > > > > +/**
> > > > > > + * enum - VM_FAULT code
> > > > >
> > > > > Can you document an anonymous enum?  I've never tried.  Did you run 
> > > > > this
> > > > > through 'make htmldocs'?
> > > >
> > > > You cannot document an anonymous enum.
> > >
> > > I assume, you are pointing to Document folder and I don't know if this
> > > enum need to be documented or not.
> >
> > The enum should be documented, even if it's documentation is (yet) not
> > linked anywhere in the Documentation/
> >
> > > I didn't run 'make htmldocs' as there is no document related changes.
> >
> > You can verify that kernel-doc can parse your documentation by running
> >
> > scripts/kernel-doc -none -v 
> 
> I run "scripts/kernel-doc -none -v include/linux/mm_types.h" and it is showing
> below error and warning which is linked to enum in discussion.
> 
> include/linux/mm_types.h:612: info: Scanning doc for typedef vm_fault_t
> include/linux/mm_types.h:623: info: Scanning doc for enum
> include/linux/mm_types.h:628: warning: contents before sections
> include/linux/mm_types.h:660: error: Cannot parse enum!
> 1 errors
> 1 warnings
> 
> Shall I keep the documentation for enum or remove it from this patch ?

The documentation should be there, you just need to add a name for the
enum. Then kernel-doc will be able to parse it.
 
> > > >
> > > > > > + * This enum is used to track the VM_FAULT code return by page
> > > > > > + * fault handlers.
> > > > >

I think that the enum description should also include the text from the
comment that described VM_FAULT_* defines:

/*
 * 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.
 */



-- 
Sincerely yours,
Mike.



Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-05 Thread Souptick Joarder
On Mon, Nov 5, 2018 at 2:43 PM Mike Rapoport  wrote:
>
> On Mon, Nov 05, 2018 at 11:14:17AM +0530, Souptick Joarder wrote:
> > Hi Matthew,
> >
> > On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
> > >
> > > On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > > > On Sat, Nov 03, 2018 at 10:35:04AM +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.
> > > >
> > > >
> > > > > -/* 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)
> > > > ...
> > > > > +/* 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)
> > > >
> > > > I think it's important to mention in the changelog that these values
> > > > have been changed to avoid conflicts with other VM_FAULT codes.
> > > >
> > > > > +/**
> > > > > + * typedef vm_fault_t -  __bitwise unsigned int
> > > > > + *
> > > > > + * vm_fault_t is the new unsigned int type to return VM_FAULT
> > > > > + * code by page fault handlers of drivers/file systems. Now if
> > > > > + * any page fault handlers returns non VM_FAULT code instead
> > > > > + * of VM_FAULT code, it will be a mismatch with function
> > > > > + * prototype and sparse will detect it.
> > > > > + */
> > > >
> > > > The first line should be what the typedef *means*, not repeat the
> > > > compiler's definition.  The rest of the description should be 
> > > > information
> > > > for someone coming to the type for the first time; what you've written
> > > > here is changelog material.
> > > >
> > > > /**
> > > >  * 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 code
> > > >
> > > > Can you document an anonymous enum?  I've never tried.  Did you run this
> > > > through 'make htmldocs'?
> > >
> > > You cannot document an anonymous enum.
> >
> >
> > I assume, you are pointing to Document folder and I don't know if this
> > enum need to be documented or not.
>
> The enum should be documented, even if it's documentation is (yet) not
> linked anywhere in the Documentation/
>
> > I didn't run 'make htmldocs' as there is no document related changes.
>
> You can verify that kernel-doc can parse your documentation by running
>
> scripts/kernel-doc -none -v 

I run "scripts/kernel-doc -none -v include/linux/mm_types.h" and it is showing
below error and warning which is linked to enum in discussion.

include/linux/mm_types.h:612: info: Scanning doc for typedef vm_fault_t
include/linux/mm_types.h:623: info: Scanning doc for enum
include/linux/mm_types.h:628: warning: contents before sections
include/linux/mm_types.h:660: error: Cannot parse enum!
1 errors
1 warnings

Shall I keep the documentation for enum or remove it from this patch ?

>
> > >
> > > > > + * This enum is used to track the VM_FAULT code return by page
> > > > > + * fault handlers.
> > > >
> > > >  * Page fault handlers return a bitmask of these values to tell the
> > > >  * core VM what happened when handling the fault.
> > > >
> > >
> > > --
> > > Sincerely yours,
> > > Mike.
> > >
> >
>
> --
> Sincerely yours,
> Mike.
>


Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-05 Thread Souptick Joarder
On Mon, Nov 5, 2018 at 2:43 PM Mike Rapoport  wrote:
>
> On Mon, Nov 05, 2018 at 11:14:17AM +0530, Souptick Joarder wrote:
> > Hi Matthew,
> >
> > On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
> > >
> > > On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > > > On Sat, Nov 03, 2018 at 10:35:04AM +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.
> > > >
> > > >
> > > > > -/* 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)
> > > > ...
> > > > > +/* 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)
> > > >
> > > > I think it's important to mention in the changelog that these values
> > > > have been changed to avoid conflicts with other VM_FAULT codes.
> > > >
> > > > > +/**
> > > > > + * typedef vm_fault_t -  __bitwise unsigned int
> > > > > + *
> > > > > + * vm_fault_t is the new unsigned int type to return VM_FAULT
> > > > > + * code by page fault handlers of drivers/file systems. Now if
> > > > > + * any page fault handlers returns non VM_FAULT code instead
> > > > > + * of VM_FAULT code, it will be a mismatch with function
> > > > > + * prototype and sparse will detect it.
> > > > > + */
> > > >
> > > > The first line should be what the typedef *means*, not repeat the
> > > > compiler's definition.  The rest of the description should be 
> > > > information
> > > > for someone coming to the type for the first time; what you've written
> > > > here is changelog material.
> > > >
> > > > /**
> > > >  * 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 code
> > > >
> > > > Can you document an anonymous enum?  I've never tried.  Did you run this
> > > > through 'make htmldocs'?
> > >
> > > You cannot document an anonymous enum.
> >
> >
> > I assume, you are pointing to Document folder and I don't know if this
> > enum need to be documented or not.
>
> The enum should be documented, even if it's documentation is (yet) not
> linked anywhere in the Documentation/
>
> > I didn't run 'make htmldocs' as there is no document related changes.
>
> You can verify that kernel-doc can parse your documentation by running
>
> scripts/kernel-doc -none -v 

I run "scripts/kernel-doc -none -v include/linux/mm_types.h" and it is showing
below error and warning which is linked to enum in discussion.

include/linux/mm_types.h:612: info: Scanning doc for typedef vm_fault_t
include/linux/mm_types.h:623: info: Scanning doc for enum
include/linux/mm_types.h:628: warning: contents before sections
include/linux/mm_types.h:660: error: Cannot parse enum!
1 errors
1 warnings

Shall I keep the documentation for enum or remove it from this patch ?

>
> > >
> > > > > + * This enum is used to track the VM_FAULT code return by page
> > > > > + * fault handlers.
> > > >
> > > >  * Page fault handlers return a bitmask of these values to tell the
> > > >  * core VM what happened when handling the fault.
> > > >
> > >
> > > --
> > > Sincerely yours,
> > > Mike.
> > >
> >
>
> --
> Sincerely yours,
> Mike.
>


Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-05 Thread Mike Rapoport
On Mon, Nov 05, 2018 at 11:14:17AM +0530, Souptick Joarder wrote:
> Hi Matthew,
> 
> On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
> >
> > On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > > On Sat, Nov 03, 2018 at 10:35:04AM +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.
> > >
> > >
> > > > -/* 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)
> > > ...
> > > > +/* 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)
> > >
> > > I think it's important to mention in the changelog that these values
> > > have been changed to avoid conflicts with other VM_FAULT codes.
> > >
> > > > +/**
> > > > + * typedef vm_fault_t -  __bitwise unsigned int
> > > > + *
> > > > + * vm_fault_t is the new unsigned int type to return VM_FAULT
> > > > + * code by page fault handlers of drivers/file systems. Now if
> > > > + * any page fault handlers returns non VM_FAULT code instead
> > > > + * of VM_FAULT code, it will be a mismatch with function
> > > > + * prototype and sparse will detect it.
> > > > + */
> > >
> > > The first line should be what the typedef *means*, not repeat the
> > > compiler's definition.  The rest of the description should be information
> > > for someone coming to the type for the first time; what you've written
> > > here is changelog material.
> > >
> > > /**
> > >  * 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 code
> > >
> > > Can you document an anonymous enum?  I've never tried.  Did you run this
> > > through 'make htmldocs'?
> >
> > You cannot document an anonymous enum.
> 
> 
> I assume, you are pointing to Document folder and I don't know if this
> enum need to be documented or not.

The enum should be documented, even if it's documentation is (yet) not
linked anywhere in the Documentation/
 
> I didn't run 'make htmldocs' as there is no document related changes.

You can verify that kernel-doc can parse your documentation by running

scripts/kernel-doc -none -v 

> >
> > > > + * This enum is used to track the VM_FAULT code return by page
> > > > + * fault handlers.
> > >
> > >  * Page fault handlers return a bitmask of these values to tell the
> > >  * core VM what happened when handling the fault.
> > >
> >
> > --
> > Sincerely yours,
> > Mike.
> >
> 

-- 
Sincerely yours,
Mike.



Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-05 Thread Mike Rapoport
On Mon, Nov 05, 2018 at 11:14:17AM +0530, Souptick Joarder wrote:
> Hi Matthew,
> 
> On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
> >
> > On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > > On Sat, Nov 03, 2018 at 10:35:04AM +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.
> > >
> > >
> > > > -/* 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)
> > > ...
> > > > +/* 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)
> > >
> > > I think it's important to mention in the changelog that these values
> > > have been changed to avoid conflicts with other VM_FAULT codes.
> > >
> > > > +/**
> > > > + * typedef vm_fault_t -  __bitwise unsigned int
> > > > + *
> > > > + * vm_fault_t is the new unsigned int type to return VM_FAULT
> > > > + * code by page fault handlers of drivers/file systems. Now if
> > > > + * any page fault handlers returns non VM_FAULT code instead
> > > > + * of VM_FAULT code, it will be a mismatch with function
> > > > + * prototype and sparse will detect it.
> > > > + */
> > >
> > > The first line should be what the typedef *means*, not repeat the
> > > compiler's definition.  The rest of the description should be information
> > > for someone coming to the type for the first time; what you've written
> > > here is changelog material.
> > >
> > > /**
> > >  * 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 code
> > >
> > > Can you document an anonymous enum?  I've never tried.  Did you run this
> > > through 'make htmldocs'?
> >
> > You cannot document an anonymous enum.
> 
> 
> I assume, you are pointing to Document folder and I don't know if this
> enum need to be documented or not.

The enum should be documented, even if it's documentation is (yet) not
linked anywhere in the Documentation/
 
> I didn't run 'make htmldocs' as there is no document related changes.

You can verify that kernel-doc can parse your documentation by running

scripts/kernel-doc -none -v 

> >
> > > > + * This enum is used to track the VM_FAULT code return by page
> > > > + * fault handlers.
> > >
> > >  * Page fault handlers return a bitmask of these values to tell the
> > >  * core VM what happened when handling the fault.
> > >
> >
> > --
> > Sincerely yours,
> > Mike.
> >
> 

-- 
Sincerely yours,
Mike.



Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-04 Thread Souptick Joarder
Hi Matthew,

On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
>
> On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > On Sat, Nov 03, 2018 at 10:35:04AM +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.
> >
> >
> > > -/* 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)
> > ...
> > > +/* 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)
> >
> > I think it's important to mention in the changelog that these values
> > have been changed to avoid conflicts with other VM_FAULT codes.
> >
> > > +/**
> > > + * typedef vm_fault_t -  __bitwise unsigned int
> > > + *
> > > + * vm_fault_t is the new unsigned int type to return VM_FAULT
> > > + * code by page fault handlers of drivers/file systems. Now if
> > > + * any page fault handlers returns non VM_FAULT code instead
> > > + * of VM_FAULT code, it will be a mismatch with function
> > > + * prototype and sparse will detect it.
> > > + */
> >
> > The first line should be what the typedef *means*, not repeat the
> > compiler's definition.  The rest of the description should be information
> > for someone coming to the type for the first time; what you've written
> > here is changelog material.
> >
> > /**
> >  * 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 code
> >
> > Can you document an anonymous enum?  I've never tried.  Did you run this
> > through 'make htmldocs'?
>
> You cannot document an anonymous enum.


I assume, you are pointing to Document folder and I don't know if this
enum need to be documented or not.

I didn't run 'make htmldocs' as there is no document related changes.

>
> > > + * This enum is used to track the VM_FAULT code return by page
> > > + * fault handlers.
> >
> >  * Page fault handlers return a bitmask of these values to tell the
> >  * core VM what happened when handling the fault.
> >
>
> --
> Sincerely yours,
> Mike.
>


Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-04 Thread Souptick Joarder
Hi Matthew,

On Sun, Nov 4, 2018 at 2:06 PM Mike Rapoport  wrote:
>
> On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> > On Sat, Nov 03, 2018 at 10:35:04AM +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.
> >
> >
> > > -/* 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)
> > ...
> > > +/* 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)
> >
> > I think it's important to mention in the changelog that these values
> > have been changed to avoid conflicts with other VM_FAULT codes.
> >
> > > +/**
> > > + * typedef vm_fault_t -  __bitwise unsigned int
> > > + *
> > > + * vm_fault_t is the new unsigned int type to return VM_FAULT
> > > + * code by page fault handlers of drivers/file systems. Now if
> > > + * any page fault handlers returns non VM_FAULT code instead
> > > + * of VM_FAULT code, it will be a mismatch with function
> > > + * prototype and sparse will detect it.
> > > + */
> >
> > The first line should be what the typedef *means*, not repeat the
> > compiler's definition.  The rest of the description should be information
> > for someone coming to the type for the first time; what you've written
> > here is changelog material.
> >
> > /**
> >  * 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 code
> >
> > Can you document an anonymous enum?  I've never tried.  Did you run this
> > through 'make htmldocs'?
>
> You cannot document an anonymous enum.


I assume, you are pointing to Document folder and I don't know if this
enum need to be documented or not.

I didn't run 'make htmldocs' as there is no document related changes.

>
> > > + * This enum is used to track the VM_FAULT code return by page
> > > + * fault handlers.
> >
> >  * Page fault handlers return a bitmask of these values to tell the
> >  * core VM what happened when handling the fault.
> >
>
> --
> Sincerely yours,
> Mike.
>


Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-04 Thread Mike Rapoport
On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> On Sat, Nov 03, 2018 at 10:35:04AM +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.
> 
> 
> > -/* 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)
> ...
> > +/* 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)
> 
> I think it's important to mention in the changelog that these values
> have been changed to avoid conflicts with other VM_FAULT codes.
> 
> > +/**
> > + * typedef vm_fault_t -  __bitwise unsigned int
> > + *
> > + * vm_fault_t is the new unsigned int type to return VM_FAULT
> > + * code by page fault handlers of drivers/file systems. Now if
> > + * any page fault handlers returns non VM_FAULT code instead
> > + * of VM_FAULT code, it will be a mismatch with function
> > + * prototype and sparse will detect it.
> > + */
> 
> The first line should be what the typedef *means*, not repeat the
> compiler's definition.  The rest of the description should be information
> for someone coming to the type for the first time; what you've written
> here is changelog material.
> 
> /**
>  * 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 code
> 
> Can you document an anonymous enum?  I've never tried.  Did you run this
> through 'make htmldocs'?

You cannot document an anonymous enum.
 
> > + * This enum is used to track the VM_FAULT code return by page
> > + * fault handlers.
> 
>  * Page fault handlers return a bitmask of these values to tell the
>  * core VM what happened when handling the fault.
> 

-- 
Sincerely yours,
Mike.



Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-04 Thread Mike Rapoport
On Sat, Nov 03, 2018 at 05:02:36AM -0700, Matthew Wilcox wrote:
> On Sat, Nov 03, 2018 at 10:35:04AM +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.
> 
> 
> > -/* 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)
> ...
> > +/* 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)
> 
> I think it's important to mention in the changelog that these values
> have been changed to avoid conflicts with other VM_FAULT codes.
> 
> > +/**
> > + * typedef vm_fault_t -  __bitwise unsigned int
> > + *
> > + * vm_fault_t is the new unsigned int type to return VM_FAULT
> > + * code by page fault handlers of drivers/file systems. Now if
> > + * any page fault handlers returns non VM_FAULT code instead
> > + * of VM_FAULT code, it will be a mismatch with function
> > + * prototype and sparse will detect it.
> > + */
> 
> The first line should be what the typedef *means*, not repeat the
> compiler's definition.  The rest of the description should be information
> for someone coming to the type for the first time; what you've written
> here is changelog material.
> 
> /**
>  * 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 code
> 
> Can you document an anonymous enum?  I've never tried.  Did you run this
> through 'make htmldocs'?

You cannot document an anonymous enum.
 
> > + * This enum is used to track the VM_FAULT code return by page
> > + * fault handlers.
> 
>  * Page fault handlers return a bitmask of these values to tell the
>  * core VM what happened when handling the fault.
> 

-- 
Sincerely yours,
Mike.



Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-03 Thread Matthew Wilcox
On Sat, Nov 03, 2018 at 10:35:04AM +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.


> -/* 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)
...
> +/* 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)

I think it's important to mention in the changelog that these values
have been changed to avoid conflicts with other VM_FAULT codes.

> +/**
> + * typedef vm_fault_t -  __bitwise unsigned int
> + *
> + * vm_fault_t is the new unsigned int type to return VM_FAULT
> + * code by page fault handlers of drivers/file systems. Now if
> + * any page fault handlers returns non VM_FAULT code instead
> + * of VM_FAULT code, it will be a mismatch with function
> + * prototype and sparse will detect it.
> + */

The first line should be what the typedef *means*, not repeat the
compiler's definition.  The rest of the description should be information
for someone coming to the type for the first time; what you've written
here is changelog material.

/**
 * 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 code

Can you document an anonymous enum?  I've never tried.  Did you run this
through 'make htmldocs'?

> + * This enum is used to track the VM_FAULT code return by page
> + * fault handlers.

 * Page fault handlers return a bitmask of these values to tell the
 * core VM what happened when handling the fault.



Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-03 Thread Matthew Wilcox
On Sat, Nov 03, 2018 at 10:35:04AM +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.


> -/* 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)
...
> +/* 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)

I think it's important to mention in the changelog that these values
have been changed to avoid conflicts with other VM_FAULT codes.

> +/**
> + * typedef vm_fault_t -  __bitwise unsigned int
> + *
> + * vm_fault_t is the new unsigned int type to return VM_FAULT
> + * code by page fault handlers of drivers/file systems. Now if
> + * any page fault handlers returns non VM_FAULT code instead
> + * of VM_FAULT code, it will be a mismatch with function
> + * prototype and sparse will detect it.
> + */

The first line should be what the typedef *means*, not repeat the
compiler's definition.  The rest of the description should be information
for someone coming to the type for the first time; what you've written
here is changelog material.

/**
 * 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 code

Can you document an anonymous enum?  I've never tried.  Did you run this
through 'make htmldocs'?

> + * This enum is used to track the VM_FAULT code return by page
> + * fault handlers.

 * Page fault handlers return a bitmask of these values to tell the
 * core VM what happened when handling the fault.



Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-02 Thread Souptick Joarder
On Sat, Nov 3, 2018 at 10:31 AM 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.
>
> Signed-off-by: Souptick Joarder 
> ---
>  include/linux/mm.h   | 46 -
>  include/linux/mm_types.h | 75 
> +++-
>  2 files changed, 74 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_SIGBUS0x0002
> -#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_NOPAGE0x0100  /* ->fault installed the pte, not 
> return page */
> -#define VM_FAULT_LOCKED0x0200  /* ->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..48c2108 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,80 @@ static inline bool mm_tlb_flush_nested(struct mm_struct 
> *mm)
>
>  struct vm_fault;
>
> +/**
> + * typedef vm_fault_t -  __bitwise unsigned int
> + *
> + * vm_fault_t is the new unsigned int type to return VM_FAULT
> + * code by page fault handlers of drivers/file systems. Now if
> + * any page fault handlers returns non VM_FAULT code instead
> + * of VM_FAULT code, it will be a mismatch with function
> + * prototype and sparse will detect it.
> + */
> +typedef __bitwise unsigned int vm_fault_t;
> +
> +/**
> + * enum - VM_FAULT code
> + *
> + * This enum is used to track the VM_FAULT code return by page
> + * fault handlers.
> + *
> + * @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: 

Re: [PATCH] mm: Create the new vm_fault_t type

2018-11-02 Thread Souptick Joarder
On Sat, Nov 3, 2018 at 10:31 AM 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.
>
> Signed-off-by: Souptick Joarder 
> ---
>  include/linux/mm.h   | 46 -
>  include/linux/mm_types.h | 75 
> +++-
>  2 files changed, 74 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_SIGBUS0x0002
> -#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_NOPAGE0x0100  /* ->fault installed the pte, not 
> return page */
> -#define VM_FAULT_LOCKED0x0200  /* ->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..48c2108 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,80 @@ static inline bool mm_tlb_flush_nested(struct mm_struct 
> *mm)
>
>  struct vm_fault;
>
> +/**
> + * typedef vm_fault_t -  __bitwise unsigned int
> + *
> + * vm_fault_t is the new unsigned int type to return VM_FAULT
> + * code by page fault handlers of drivers/file systems. Now if
> + * any page fault handlers returns non VM_FAULT code instead
> + * of VM_FAULT code, it will be a mismatch with function
> + * prototype and sparse will detect it.
> + */
> +typedef __bitwise unsigned int vm_fault_t;
> +
> +/**
> + * enum - VM_FAULT code
> + *
> + * This enum is used to track the VM_FAULT code return by page
> + * fault handlers.
> + *
> + * @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: