Re: [PATCH 1/1] mm/gup_benchmark: fix MAP_HUGETLB case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 21, 2019 at 02:24:35PM -0700, John Hubbard wrote:
> The MAP_HUGETLB ("-H" option) of gup_benchmark fails:
> 
> $ sudo ./gup_benchmark -H
> mmap: Invalid argument
> 
> This is because gup_benchmark.c is passing in a file descriptor to
> mmap(), but the fd came from opening up the /dev/zero file. This
> confuses the mmap syscall implementation, which thinks that, if the
> caller did not specify MAP_ANONYMOUS, then the file must be a huge
> page file. So it attempts to verify that the file really is a huge
> page file, as you can see here:
> 
> ksys_mmap_pgoff()
> {
>     if (!(flags & MAP_ANONYMOUS)) {
>         retval = -EINVAL;
>         if (unlikely(flags & MAP_HUGETLB && !is_file_hugepages(file)))
>             goto out_fput; /* THIS IS WHERE WE END UP */
> 
>     else if (flags & MAP_HUGETLB) {
>         ...proceed normally, /dev/zero is ok here...
> 
> ...and of course is_file_hugepages() returns "false" for the /dev/zero
> file.
> 
> The problem is that the user space program, gup_benchmark.c, really just
> wants anonymous memory here. The simplest way to get that is to pass
> MAP_ANONYMOUS whenever MAP_HUGETLB is specified, so that's what this
> patch does.

This looks wrong, MAP_HUGETLB should only be use to create vma
for hugetlbfs. If you want anonymous private vma do not set the
MAP_HUGETLB. If you want huge page inside your anonymous vma
there is nothing to do at the mmap time, this is the job of the
transparent huge page code (THP).

NAK as misleading

Cheers,
Jérôme





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux