]> Git Repo - linux.git/commit
mm: thp: pass correct vm_flags to hugepage_vma_check()
authorSong Liu <[email protected]>
Fri, 17 Aug 2018 22:47:00 +0000 (15:47 -0700)
committerLinus Torvalds <[email protected]>
Fri, 17 Aug 2018 23:20:30 +0000 (16:20 -0700)
commit50f8b92f21d23789bd4ada593e8ddc56cc4f79fe
treeac23602fa31f41df2466e584f6e024364f10f888
parenta718e28f538441a3b6612da9ff226973376cdf0f
mm: thp: pass correct vm_flags to hugepage_vma_check()

khugepaged_enter_vma_merge() passes a stale vma->vm_flags to
hugepage_vma_check().  The argument vm_flags contains the latest value.
Therefore, it is necessary to pass this vm_flags into
hugepage_vma_check().

With this bug, madvise(MADV_HUGEPAGE) for mmap files in shmem fails to
put memory in huge pages.  Here is an example of failed madvise():

   /* mount /dev/shm with huge=advise:
    *     mount -o remount,huge=advise /dev/shm */
   /* create file /dev/shm/huge */
   #define HUGE_FILE "/dev/shm/huge"

   fd = open(HUGE_FILE, O_RDONLY);
   ptr = mmap(NULL, FILE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0);
   ret = madvise(ptr, FILE_SIZE, MADV_HUGEPAGE);

madvise() will return 0, but this memory region is never put in huge
page (check from /proc/meminfo: ShmemHugePages).

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 02b75dc8160d ("mm: thp: register mm for khugepaged when merging vma for shmem")
Signed-off-by: Song Liu <[email protected]>
Reviewed-by: Rik van Riel <[email protected]>
Reviewed-by: Yang Shi <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/khugepaged.c
This page took 0.049152 seconds and 4 git commands to generate.