From: Toshi Kani <toshi.kani@hpe.com>
To: Matthew Wilcox <willy@linux.intel.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>, Jan Kara <jack@suse.cz>,
"linux-nvdimm@ml01.01.org" <linux-nvdimm@ml01.01.org>,
"david@fromorbit.com" <david@fromorbit.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"adilger.kernel@dilger.ca" <adilger.kernel@dilger.ca>,
"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"tytso@mit.edu" <tytso@mit.edu>,
Andrew Morton <akpm@linux-foundation.org>,
"kirill.shutemov@linux.intel.com"
<kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH v3 0/2] Align mmap address for DAX pmd mappings
Date: Thu, 21 Apr 2016 20:59:38 -0400 [thread overview]
Message-ID: <5719777A.4050400@hpe.com> (raw)
In-Reply-To: <20160422002236.GE29068@linux.intel.com>
On 4/21/2016 8:22 PM, Matthew Wilcox wrote:
> On Thu, Apr 21, 2016 at 07:43:39PM -0400, Toshi Kani wrote:
>> On 4/21/2016 4:21 PM, Mike Kravetz wrote:
>>> Might want to keep the future possibility of PUD_SIZE THP in mind?
>> Yes, this is why the func name does not say 'pmd'. It can be extended to
>> support
>> PUD_SIZE in future.
> Sure ... but what does that look like? I think it should look a little
> like this:
Yes, I had something similar in mind, too. Do you want me to use this
version without the call with PUD_SIZE?
>
> unsigned long __thp_get_unmapped_area(struct file *filp, unsigned long len,
> loff_t off, unsigned long flags, unsigned long size);
> {
> unsigned long addr;
> loff_t off_end = off + len;
> loff_t off_align = round_up(off, size);
> unsigned long len_size;
>
> if ((off_end <= off_align) || ((off_end - off_align) < size))
> return NULL;
>
> len_size = len + size;
> if ((len_size < len) || (off + len_size) < off)
> return NULL;
>
> addr = current->mm->get_unmapped_area(filp, NULL, len_size,
> off >> PAGE_SHIFT, flags);
> if (IS_ERR_VALUE(addr))
> return NULL;
>
> addr += (off - addr) & (size - 1);
> return addr;
> }
>
> unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr,
> unsigned long len, unsigned long pgoff, unsigned long flags)
> {
> loff_t off = (loff_t)pgoff << PAGE_SHIFT;
>
> 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 */
>
> addr = __thp_get_unmapped_area(filp, len, off, flags, PUD_SIZE);
> if (addr)
> return addr;
> addr = __thp_get_unmapped_area(filp, len, off, flags, PMD_SIZE);
> if (addr)
> return addr;
>
> out:
> return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
> }
>
> By the way, I added an extra check here, when we add len and size
> (PMD_SIZE in the original), we need to make sure that doesn't wrap.
> NB: I'm not even compiling these suggestions, just throwing them out
> here as ideas to be criticised.
Yes, I agree with the extra check. Thanks for pointing this out.
>
> Also, len_size is a stupid name, but I can't think of a better one.
How about len_pad?
Thanks,
-Toshi
next prev parent reply other threads:[~2016-04-22 0:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 16:48 [PATCH v3 0/2] Align mmap address for DAX pmd mappings Toshi Kani
2016-04-14 16:48 ` [PATCH v3 1/2] dax: add dax_get_unmapped_area for " Toshi Kani
2016-04-18 20:47 ` Jan Kara
2016-04-19 2:36 ` Toshi Kani
2016-04-14 16:48 ` [PATCH v3 2/2] ext2/4, xfs, blk: call dax_get_unmapped_area() for DAX " Toshi Kani
2016-04-16 5:05 ` [PATCH v3 0/2] Align mmap address " Andrew Morton
2016-04-18 20:26 ` Jan Kara
2016-04-19 18:23 ` Matthew Wilcox
2016-04-21 3:10 ` Toshi Kani
2016-04-21 7:06 ` Matthew Wilcox
2016-04-21 20:21 ` Mike Kravetz
2016-04-21 23:43 ` Toshi Kani
2016-04-22 0:22 ` Matthew Wilcox
2016-04-22 0:59 ` Toshi Kani [this message]
2016-04-21 23:35 ` Toshi Kani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5719777A.4050400@hpe.com \
--to=toshi.kani@hpe.com \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=jack@suse.cz \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvdimm@ml01.01.org \
--cc=mike.kravetz@oracle.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).