diff mbox

[1/2] shmem: fix tmpfs to handle the huge= option properly

Message ID 1473459863-11287-2-git-send-email-toshi.kani@hpe.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kani, Toshi Sept. 9, 2016, 10:24 p.m. UTC
shmem_get_unmapped_area() checks SHMEM_SB(sb)->huge incorrectly,
which leads to a reversed effect of "huge=" mount option.

Fix the check in shmem_get_unmapped_area().

Note, the default value of SHMEM_SB(sb)->huge remains as
SHMEM_HUGE_NEVER.  User will need to specify "huge=" option to
enable huge page mappings.

Reported-by: Hillf Danton <hillf.zj@alibaba-inc.com>
Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Hugh Dickins <hughd@google.com>
---
 mm/shmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kirill A . Shutemov Sept. 12, 2016, 9:59 a.m. UTC | #1
On Fri, Sep 09, 2016 at 04:24:22PM -0600, Toshi Kani wrote:
> shmem_get_unmapped_area() checks SHMEM_SB(sb)->huge incorrectly,
> which leads to a reversed effect of "huge=" mount option.
> 
> Fix the check in shmem_get_unmapped_area().
> 
> Note, the default value of SHMEM_SB(sb)->huge remains as
> SHMEM_HUGE_NEVER.  User will need to specify "huge=" option to
> enable huge page mappings.
> 
> Reported-by: Hillf Danton <hillf.zj@alibaba-inc.com>
> Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Hugh Dickins <hughd@google.com>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Aneesh Kumar K.V Sept. 22, 2016, 10:58 a.m. UTC | #2
Toshi Kani <toshi.kani@hpe.com> writes:

> shmem_get_unmapped_area() checks SHMEM_SB(sb)->huge incorrectly,
> which leads to a reversed effect of "huge=" mount option.
>
> Fix the check in shmem_get_unmapped_area().
>
> Note, the default value of SHMEM_SB(sb)->huge remains as
> SHMEM_HUGE_NEVER.  User will need to specify "huge=" option to
> enable huge page mappings.
>

Any update on getting this merged ?

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

> Reported-by: Hillf Danton <hillf.zj@alibaba-inc.com>
> Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Hugh Dickins <hughd@google.com>
> ---
>  mm/shmem.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index fd8b2b5..aec5b49 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1980,7 +1980,7 @@ unsigned long shmem_get_unmapped_area(struct file *file,
>  				return addr;
>  			sb = shm_mnt->mnt_sb;
>  		}
> -		if (SHMEM_SB(sb)->huge != SHMEM_HUGE_NEVER)
> +		if (SHMEM_SB(sb)->huge == SHMEM_HUGE_NEVER)
>  			return addr;
>  	}
>  
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Hugh Dickins Sept. 23, 2016, 2:33 a.m. UTC | #3
On Thu, 22 Sep 2016, Aneesh Kumar K.V wrote:
> Toshi Kani <toshi.kani@hpe.com> writes:
> 
> > shmem_get_unmapped_area() checks SHMEM_SB(sb)->huge incorrectly,
> > which leads to a reversed effect of "huge=" mount option.
> >
> > Fix the check in shmem_get_unmapped_area().
> >
> > Note, the default value of SHMEM_SB(sb)->huge remains as
> > SHMEM_HUGE_NEVER.  User will need to specify "huge=" option to
> > enable huge page mappings.
> >
> 
> Any update on getting this merged ?
> 
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Yikes, how did we ever not notice this?  Very embarrassing.

Huge thank you to Hillf for spotting it (only now do I rediscover
your June mail: I'm sorry, my attention has been fully elsewhere).

Big thank you to Toshi for sending the patch,
and to Aneesh for now sounding the alarm.

The only reassurance is that at least all the rest of it has
been under test for the last few months, via the SHMEM_HUGE_FORCE
override.  So it's not as if none of the code has been tested,
but I am still mystified why it hasn't been obvious without.

To the patch,
Acked-by: Hugh Dickins <hughd@google.com>
but I wish I could dream up a more emphatic tag.

Andrew, please please grab this and send it in!

Thank you,
Hugh

> 
> > Reported-by: Hillf Danton <hillf.zj@alibaba-inc.com>
> > Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > Cc: Hugh Dickins <hughd@google.com>
> > ---
> >  mm/shmem.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index fd8b2b5..aec5b49 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -1980,7 +1980,7 @@ unsigned long shmem_get_unmapped_area(struct file *file,
> >  				return addr;
> >  			sb = shm_mnt->mnt_sb;
> >  		}
> > -		if (SHMEM_SB(sb)->huge != SHMEM_HUGE_NEVER)
> > +		if (SHMEM_SB(sb)->huge == SHMEM_HUGE_NEVER)
> >  			return addr;
> >  	}
> >  
> >
> > --
diff mbox

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index fd8b2b5..aec5b49 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1980,7 +1980,7 @@  unsigned long shmem_get_unmapped_area(struct file *file,
 				return addr;
 			sb = shm_mnt->mnt_sb;
 		}
-		if (SHMEM_SB(sb)->huge != SHMEM_HUGE_NEVER)
+		if (SHMEM_SB(sb)->huge == SHMEM_HUGE_NEVER)
 			return addr;
 	}