linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: John Hubbard <jhubbard@nvidia.com>,
	Li Xinhai <lixinhai.lxh@gmail.com>,
	linux-mm@kvack.org, Linux API <linux-api@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] mm: introduce MAP_FIXED_HUGETLB_LEN to mmap()
Date: Fri, 27 Mar 2020 18:31:22 -0700	[thread overview]
Message-ID: <0de74135-200f-ce91-3f27-5ab759220c9d@oracle.com> (raw)
In-Reply-To: <a3444ac1-90d3-83fa-fd7b-85ea77c6e0ff@nvidia.com>

On 3/27/20 12:12 PM, John Hubbard wrote:
> On 3/27/20 5:59 AM, Li Xinhai wrote:
>> The purpose of MAP_FIXED_HUGETLB_LEN is to check whether the parameter
>> length is valid or not according to the target file's huge page size.
>> When it is used, if length is not aligned to underlying huge page size,
>> mmap() is failed with errno set to EINVAL. When it is not used, the
>> current semantic is maintained, i.e., length is round up to underlying
>> huge page size.
>>
>> In current code, the vma related call, except mmap, are all consider
>> not correctly aligned length as invalid parameter, including mprotect,
>> munmap, mlock, etc., by checking through hugetlb_vm_op_split. So, user
>> will see failure, after successfully call mmap, although using same
>> length parameter to other mapping syscall.
>>
>> With MAP_FIXED_HUGETLB_LEN, user can choose to check if length is
>> correctly aligned at first place when call mmap, instead of failure after
>> mapping has been created.
> 
> Hi Li,
> 
> This is not worth creating a new MAP_ flag. If you look at the existing flags
> you will see that they are both limited and carefully chosen, so as to cover
> a reasonable chunk of functionality per flag. We don't just drop in a flag
> for tiny corner cases like this one.
> 
> btw, remember that user API changes require man pages updates as well. And
> that the API has to be supported forever. And that if we use up valuable
> flag slots on trivia then we'll run out of flags quite soon, and won't be
> able to do broader, more important upgrades.
> 
> Also, we need to include a user space API mailing list for things that
> affect that. Adding them now: Linux API <linux-api@vger.kernel.org>
> The man pages mailing list will also be needed if we go there.
> 
> Let's take a closer look at your problem and see what it takes to solve it.
> If we need some sort of flag to mmap() or other routines, fine. But so far,
> I can see at least two solutions that are much easier:

I too question the motivation for this patch.  Is it simply to eliminate some
of the hugetlb special behavior and make it behave more like the rest of mm?

> Solution idea #2: just do the length check unconditionally here (without looking
> at a new flag), and return an error if it is not aligned. And same thing for the
> MAP_HUGETLB case below. And delete the "len = ALIGN(len, huge_page_size(hs));" in
> both cases.
> 
> That would still require a man page update, and consensus that it won't Break
> The World, but it's possible (I really don't know) that this is a more common
> and desirable behavior.
> 
> Let's see if anyone else weighs in about this.

That certainly would be the easiest thing to do.  However, I'm guessing
the current behavior was added when hugetlb mmap support was added.  There
is no telling how many applications might break if we change the behavior.
I'm guessing this is the reason Li chose to only change the behavior if
a new flag was specified.
-- 
Mike Kravetz


  reply	other threads:[~2020-03-28  1:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27 12:59 [PATCH] mm: introduce MAP_FIXED_HUGETLB_LEN to mmap() Li Xinhai
2020-03-27 19:12 ` John Hubbard
2020-03-28  1:31   ` Mike Kravetz [this message]
2020-03-28  2:19     ` Li Xinhai
2020-03-29  3:20       ` Li Xinhai
2020-03-28  2:14   ` Li Xinhai

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=0de74135-200f-ce91-3f27-5ab759220c9d@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=jhubbard@nvidia.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lixinhai.lxh@gmail.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).