Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1384637

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

From Toshi Kani <toshi.kani@hpe.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings
Date 2016-04-22 01:40 +0200
Message-ID <rqwmt-Fk-3@gated-at.bofh.it> (permalink)
References (1 earlier) <roqEx-6Md-1@gated-at.bofh.it> <rpnXY-3a0-7@gated-at.bofh.it> <rpIzo-2JB-9@gated-at.bofh.it> <rqdjQ-27E-15@gated-at.bofh.it> <rqgUq-59Y-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 4/21/2016 3:06 AM, Matthew Wilcox wrote:
> On Wed, Apr 20, 2016 at 11:10:25PM -0400, Toshi Kani wrote:
>> How about moving the function (as is) to mm/huge_memory.c, rename it to
>> get_hugepage_unmapped_area(), which is defined to NULL in huge_mm.h
>> when TRANSPARENT_HUGEPAGE is unset?
> Great idea.  Perhaps it should look something like this?

Yes, it looks good! I will use it. :-)

>
> unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr,
>                  unsigned long len, unsigned long pgoff, unsigned long flags)
> {
>          loff_t off, off_end, off_pmd;
>          unsigned long len_pmd, addr_pmd;
>
>          if (addr)
>                  goto out;
>          if (IS_DAX(filp->f_mapping->host) && !IS_ENABLED(CONFIG_FS_DAX_PMD))
>                  goto out;
>          /* Kirill, please fill in the right condition here for THP pagecache */
>
>          off = (loff_t)pgoff << PAGE_SHIFT;
>          off_end = off + len;
>          off_pmd = round_up(off, PMD_SIZE);      /* pmd-aligned start offset */
>
>          if ((off_end <= off_pmd) || ((off_end - off_pmd) < PMD_SIZE))
>                  goto out;
>
>          len_pmd = len + PMD_SIZE;
>          if ((off + len_pmd) < off)
>                  goto out;
>
>          addr_pmd = current->mm->get_unmapped_area(filp, NULL, len_pmd,
>                                                  pgoff, flags);
>          if (!IS_ERR_VALUE(addr_pmd)) {
>                  addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
>                  return addr_pmd;
>          }
>   out:
>          return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
> }
>
>   - I deleted the check for filp == NULL.  It can't be NULL ... this is a
>     file_operation ;-)

Right.

>   - Why is len_pmd len + PMD_SIZE instead of round_up(len, PMD_SIZE)?

The length is padded with an extra-PMD size so that any assigned address 
'addr_pmd'
can be aligned by PMD.  IOW, it does not make an assumption that 
addr_pmd is aligned
by the length.

>   - I'm still in two minds about passing 'addr' to the first call to
>     get_unmapped_area() instead of NULL.

When 'addr' is specified, we need to use 'len' since user may be 
managing free VMA
range by itself.  So, I think falling back with the original args is 
correct.

Thanks,
-Toshi

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Andrew Morton <akpm@linux-foundation.org> - 2016-04-16 07:10 +0200
  Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Jan Kara <jack@suse.cz> - 2016-04-18 22:30 +0200
    Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Matthew Wilcox <willy@linux.intel.com> - 2016-04-19 20:30 +0200
      Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Toshi Kani <toshi.kani@hpe.com> - 2016-04-21 05:20 +0200
        Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Matthew Wilcox <willy@linux.intel.com> - 2016-04-21 09:10 +0200
          Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Mike Kravetz <mike.kravetz@oracle.com> - 2016-04-21 22:30 +0200
            Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Toshi Kani <toshi.kani@hpe.com> - 2016-04-22 01:50 +0200
              Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Matthew Wilcox <willy@linux.intel.com> - 2016-04-22 02:30 +0200
                Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Toshi Kani <toshi.kani@hpe.com> - 2016-04-22 03:00 +0200
          Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings Toshi Kani <toshi.kani@hpe.com> - 2016-04-22 01:40 +0200

csiph-web