diff mbox

[v4,RESEND,0/2] Align mmap address for DAX pmd mappings

Message ID 1473376846.2092.69.camel@hpe.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kani, Toshi Sept. 8, 2016, 11:21 p.m. UTC
On Thu, 2016-09-08 at 07:48 -0600, Kani, Toshimitsu wrote:
> On Thu, 2016-09-08 at 13:57 +0300, Kirill A. Shutemov wrote:
> > 
> > On Mon, Aug 29, 2016 at 10:00:43PM +0000, Kani, Toshimitsu wrote:
 :
> > > 
> > > Looking further, these shmem_huge handlings only check pre-
> > > conditions.  So, we should be able to make shmem_get_unmapped_are
> > > a() as a wrapper, which checks such shmem-specific conitions, and
> > > then call __thp_get_unmapped_area() for the actual work.  All
> > > DAX-specific checks are performed in thp_get_unmapped_area() as
> > > well.  We can make  __thp_get_unmapped_area() as a common
> > > function.
> > > 
> > > I'd prefer to make such change as a separate item,
> > 
> > Do you have plan to submit such change?
> 
> Yes, I will submit the change once I finish testing.

I found a bug in the current code, and need some clarification.  The
if-statement below is reverted.

===

Because of this bug, mounting tmpfs with "huge=never" enables huge page
mappings, and "huge=always" or others disables it...

The above simple change will change the default behavior, though.  When
"huge=" option is not specified, SHMEM_SB(sb)->huge is set to zero,
which is SHMEM_HUGE_NEVER.  Therefore, huge page mappings are enabled
by default because of this bug.

What's the intended default behavior of this feature?

Thanks,
-Toshi

Comments

kirill.shutemov@linux.intel.com Sept. 9, 2016, 12:36 p.m. UTC | #1
On Thu, Sep 08, 2016 at 11:21:46PM +0000, Kani, Toshimitsu wrote:
> On Thu, 2016-09-08 at 07:48 -0600, Kani, Toshimitsu wrote:
> > On Thu, 2016-09-08 at 13:57 +0300, Kirill A. Shutemov wrote:
> > > 
> > > On Mon, Aug 29, 2016 at 10:00:43PM +0000, Kani, Toshimitsu wrote:
>  :
> > > > 
> > > > Looking further, these shmem_huge handlings only check pre-
> > > > conditions.  So, we should be able to make shmem_get_unmapped_are
> > > > a() as a wrapper, which checks such shmem-specific conitions, and
> > > > then call __thp_get_unmapped_area() for the actual work.  All
> > > > DAX-specific checks are performed in thp_get_unmapped_area() as
> > > > well.  We can make  __thp_get_unmapped_area() as a common
> > > > function.
> > > > 
> > > > I'd prefer to make such change as a separate item,
> > > 
> > > Do you have plan to submit such change?
> > 
> > Yes, I will submit the change once I finish testing.
> 
> I found a bug in the current code, and need some clarification.  The
> if-statement below is reverted.

<two-hands-facepalm>

Yeah. It was repored by Hillf[1]. The fixup got lost. :(

Could you post a proper patch with the fix?

I would be nice to credit Hillf there too.

[1] http://lkml.kernel.org/r/054f01d1c86f$2994d5c0$7cbe8140$@alibaba-inc.com
Kani, Toshi Sept. 9, 2016, 5:21 p.m. UTC | #2
On Fri, 2016-09-09 at 15:36 +0300, Kirill A. Shutemov wrote:
> On Thu, Sep 08, 2016 at 11:21:46PM +0000, Kani, Toshimitsu wrote:

> > 

> > On Thu, 2016-09-08 at 07:48 -0600, Kani, Toshimitsu wrote:

> > > 

> > > On Thu, 2016-09-08 at 13:57 +0300, Kirill A. Shutemov wrote:

> > > > 

> > > > On Mon, Aug 29, 2016 at 10:00:43PM +0000, Kani, Toshimitsu

> > > > wrote:

> >  :

> > > > > Looking further, these shmem_huge handlings only check pre-

> > > > > conditions.  So, we should be able to make shmem_get_unmapped

> > > > > _are a() as a wrapper, which checks such shmem-specific

> > > > > conitions, and then call __thp_get_unmapped_area() for the

> > > > > actual work.  All DAX-specific checks are performed in

> > > > > thp_get_unmapped_area() as well.  We can make

> > > > >  __thp_get_unmapped_area() as a common

> > > > > function.

> > > > > 

> > > > > I'd prefer to make such change as a separate item,

> > > > 

> > > > Do you have plan to submit such change?

> > > 

> > > Yes, I will submit the change once I finish testing.

> > 

> > I found a bug in the current code, and need some clarification.

> >  The if-statement below is reverted.

> 

> <two-hands-facepalm>

> 

> Yeah. It was repored by Hillf[1]. The fixup got lost. :(

> 

> Could you post a proper patch with the fix?

>

> I would be nice to credit Hillf there too.

> 

> [1] http://lkml.kernel.org/r/054f01d1c86f$2994d5c0$7cbe8140$@alibaba-

> inc.com


Yes, I will submit the fix as well.

I will not change the default value of sbinfo->huge in this fix.  So,
user will have to specify "huge=" option to enable huge page mappings.
 If this is not desireable, we will need a separate patch.

Thanks,
-Toshi
Kirill A . Shutemov Sept. 9, 2016, 6:37 p.m. UTC | #3
On Fri, Sep 09, 2016 at 05:21:40PM +0000, Kani, Toshimitsu wrote:
> On Fri, 2016-09-09 at 15:36 +0300, Kirill A. Shutemov wrote:
> > On Thu, Sep 08, 2016 at 11:21:46PM +0000, Kani, Toshimitsu wrote:
> > > 
> > > On Thu, 2016-09-08 at 07:48 -0600, Kani, Toshimitsu wrote:
> > > > 
> > > > On Thu, 2016-09-08 at 13:57 +0300, Kirill A. Shutemov wrote:
> > > > > 
> > > > > On Mon, Aug 29, 2016 at 10:00:43PM +0000, Kani, Toshimitsu
> > > > > wrote:
> > >  :
> > > > > > Looking further, these shmem_huge handlings only check pre-
> > > > > > conditions.  So, we should be able to make shmem_get_unmapped
> > > > > > _are a() as a wrapper, which checks such shmem-specific
> > > > > > conitions, and then call __thp_get_unmapped_area() for the
> > > > > > actual work.  All DAX-specific checks are performed in
> > > > > > thp_get_unmapped_area() as well.  We can make
> > > > > >  __thp_get_unmapped_area() as a common
> > > > > > function.
> > > > > > 
> > > > > > I'd prefer to make such change as a separate item,
> > > > > 
> > > > > Do you have plan to submit such change?
> > > > 
> > > > Yes, I will submit the change once I finish testing.
> > > 
> > > I found a bug in the current code, and need some clarification.
> > >  The if-statement below is reverted.
> > 
> > <two-hands-facepalm>
> > 
> > Yeah. It was repored by Hillf[1]. The fixup got lost. :(
> > 
> > Could you post a proper patch with the fix?
> >
> > I would be nice to credit Hillf there too.
> > 
> > [1] http://lkml.kernel.org/r/054f01d1c86f$2994d5c0$7cbe8140$@alibaba-
> > inc.com
> 
> Yes, I will submit the fix as well.
> 
> I will not change the default value of sbinfo->huge in this fix.  So,
> user will have to specify "huge=" option to enable huge page mappings.
>  If this is not desireable, we will need a separate patch.

That's okay. I only screwed up part wich make vma aligned. Allocation of
huge page happens under right condition.
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;
        }