Re: [PATCH v4 RESEND 0/2] Align mmap address for DAX pmd mappings

From: Kani, Toshimitsu
Date: Thu Sep 08 2016 - 19:38:01 EST


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.

===
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;
ÂÂÂÂÂÂÂÂ}
===

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