linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Piotr Kwapulinski <kwapulinski.piotr@gmail.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>,
	akpm@linux-foundation.org, mtk.manpages@gmail.com,
	cmetcalf@mellanox.com, arnd@arndb.de, viro@zeniv.linux.org.uk,
	mszeredi@suse.cz, dave@stgolabs.net,
	kirill.shutemov@linux.intel.com, mingo@kernel.org,
	dan.j.williams@intel.com, dave.hansen@linux.intel.com,
	koct9i@gmail.com, hannes@cmpxchg.org, jack@suse.cz,
	xiexiuqi@huawei.com, iamjoonsoo.kim@lge.com, oleg@redhat.com,
	gang.chen.5i5j@gmail.com, aarcange@redhat.com,
	aryabinin@virtuozzo.com, rientjes@google.com, denc716@gmail.com,
	toshi.kani@hpe.com, ldufour@linux.vnet.ibm.com,
	kuleshovmail@gmail.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH 0/3] mm/mmap.c: don't unmap the overlapping VMA(s)
Date: Fri, 8 Apr 2016 17:32:29 +0200	[thread overview]
Message-ID: <20160408153228.GA1397@home.local> (raw)
In-Reply-To: <20160407163108.GF32755@dhcp22.suse.cz>

On Thu, Apr 07, 2016 at 06:31:09PM +0200, Michal Hocko wrote:
> On Thu 07-04-16 18:11:29, Piotr Kwapulinski wrote:
> > On Mon, Apr 04, 2016 at 05:26:43PM +0200, Vlastimil Babka wrote:
> > > On 04/04/2016 09:31 AM, Michal Hocko wrote:
> > > >On Sat 02-04-16 21:17:31, Piotr Kwapulinski wrote:
> > > >>Currently the mmap(MAP_FIXED) discards the overlapping part of the
> > > >>existing VMA(s).
> > > >>Introduce the new MAP_DONTUNMAP flag which forces the mmap to fail
> > > >>with ENOMEM whenever the overlapping occurs and MAP_FIXED is set.
> > > >>No existing mapping(s) is discarded.
> > > >
> > > >You forgot to tell us what is the use case for this new flag.
> > > 
> > > Exactly. Also, returning ENOMEM is strange, EINVAL might be a better match,
> > > otherwise how would you distinguish a "geunine" ENOMEM from passing a wrong
> > > address?
> > > 
> > > 
> > 
> > Thanks to all for suggestions. I'll fix them.
> > 
> > The example use case:
> > #include <stdio.h>
> > #include <string.h>
> > #include <sys/mman.h>
> > 
> > void main(void)
> > {
> >   void* addr = (void*)0x1000000;
> >   size_t size = 0x600000;
> >   void* start = 0;
> >   start = mmap(addr,
> >                size,
> >                PROT_WRITE,
> >                MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
> >                -1, 0);
> > 
> >   strcpy(start, "PPPP");
> >   printf("%s\n", start);        // == PPPP
> > 
> >   addr = (void*)0x1000000;
> >   size = 0x9000;
> >   start = mmap(addr,
> >                size,
> >                PROT_READ | PROT_WRITE,
> >                MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
> >                -1, 0);
> >   
> >   printf("%s\n", start);        // != PPPP
> > }
> > 
> > Another use case, this time with huge pages in action.
> > The limit configured in proc's nr_hugepages is exceeded.
> > mmap unmaps the area and fails. No new mapping is created.
> > The program segfaults.
> 
> Yes and this is the standard behavior for ages. So _why_ somebody wants
> non-default behavior. When I've asked for the use case I meant a real
> life code (not just an example snippet) which cannot cope with the
> standard semantic. In other words why this cannot be handled in the
> userspace and we have to add a new API which we have to maintain for
> ever?

Ok, I got it. Thanks for feedback.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Piotr Kwapulinski <kwapulinski.piotr@gmail.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>,
	akpm@linux-foundation.org, mtk.manpages@gmail.com,
	cmetcalf@mellanox.com, arnd@arndb.de, viro@zeniv.linux.org.uk,
	mszeredi@suse.cz, dave@stgolabs.net,
	kirill.shutemov@linux.intel.com, mingo@kernel.org,
	dan.j.williams@intel.com, dave.hansen@linux.intel.com,
	koct9i@gmail.com, hannes@cmpxchg.org, jack@suse.cz,
	xiexiuqi@huawei.com, iamjoonsoo.kim@lge.com, oleg@redhat.com,
	gang.chen.5i5j@gmail.com, aarcange@redhat.com,
	aryabinin@virtuozzo.com, rientjes@google.com, denc716@gmail.com,
	toshi.kani@hpe.com, ldufour@linux.vnet.ibm.com,
	kuleshovmail@gmail.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH 0/3] mm/mmap.c: don't unmap the overlapping VMA(s)
Date: Fri, 8 Apr 2016 17:32:29 +0200	[thread overview]
Message-ID: <20160408153228.GA1397@home.local> (raw)
Message-ID: <20160408153229.aUqo4ta2cU5t5zfEd9wro-iim7chWJPl-jfjY3f8-b8@z> (raw)
In-Reply-To: <20160407163108.GF32755@dhcp22.suse.cz>

On Thu, Apr 07, 2016 at 06:31:09PM +0200, Michal Hocko wrote:
> On Thu 07-04-16 18:11:29, Piotr Kwapulinski wrote:
> > On Mon, Apr 04, 2016 at 05:26:43PM +0200, Vlastimil Babka wrote:
> > > On 04/04/2016 09:31 AM, Michal Hocko wrote:
> > > >On Sat 02-04-16 21:17:31, Piotr Kwapulinski wrote:
> > > >>Currently the mmap(MAP_FIXED) discards the overlapping part of the
> > > >>existing VMA(s).
> > > >>Introduce the new MAP_DONTUNMAP flag which forces the mmap to fail
> > > >>with ENOMEM whenever the overlapping occurs and MAP_FIXED is set.
> > > >>No existing mapping(s) is discarded.
> > > >
> > > >You forgot to tell us what is the use case for this new flag.
> > > 
> > > Exactly. Also, returning ENOMEM is strange, EINVAL might be a better match,
> > > otherwise how would you distinguish a "geunine" ENOMEM from passing a wrong
> > > address?
> > > 
> > > 
> > 
> > Thanks to all for suggestions. I'll fix them.
> > 
> > The example use case:
> > #include <stdio.h>
> > #include <string.h>
> > #include <sys/mman.h>
> > 
> > void main(void)
> > {
> >   void* addr = (void*)0x1000000;
> >   size_t size = 0x600000;
> >   void* start = 0;
> >   start = mmap(addr,
> >                size,
> >                PROT_WRITE,
> >                MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
> >                -1, 0);
> > 
> >   strcpy(start, "PPPP");
> >   printf("%s\n", start);        // == PPPP
> > 
> >   addr = (void*)0x1000000;
> >   size = 0x9000;
> >   start = mmap(addr,
> >                size,
> >                PROT_READ | PROT_WRITE,
> >                MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
> >                -1, 0);
> >   
> >   printf("%s\n", start);        // != PPPP
> > }
> > 
> > Another use case, this time with huge pages in action.
> > The limit configured in proc's nr_hugepages is exceeded.
> > mmap unmaps the area and fails. No new mapping is created.
> > The program segfaults.
> 
> Yes and this is the standard behavior for ages. So _why_ somebody wants
> non-default behavior. When I've asked for the use case I meant a real
> life code (not just an example snippet) which cannot cope with the
> standard semantic. In other words why this cannot be handled in the
> userspace and we have to add a new API which we have to maintain for
> ever?

Ok, I got it. Thanks for feedback.


  parent reply	other threads:[~2016-04-08 15:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-02 19:17 [PATCH 0/3] mm/mmap.c: don't unmap the overlapping VMA(s) Piotr Kwapulinski
2016-04-02 19:17 ` [PATCH 1/3] man/mmap.2: " Piotr Kwapulinski
2016-04-02 19:17   ` Piotr Kwapulinski
2016-04-02 19:17 ` [PATCH 2/3] mm/mremap.c: " Piotr Kwapulinski
2016-04-02 19:17   ` Piotr Kwapulinski
2016-04-02 19:17 ` [PATCH 3/3] man/mremap.2: " Piotr Kwapulinski
2016-04-02 19:17   ` Piotr Kwapulinski
2016-04-02 21:54 ` [PATCH 0/3] mm/mmap.c: " Kirill A. Shutemov
2016-04-03  5:52 ` Konstantin Khlebnikov
2016-04-03  5:52   ` Konstantin Khlebnikov
2016-04-04  7:31 ` Michal Hocko
2016-04-04  7:31   ` Michal Hocko
2016-04-04 15:26   ` Vlastimil Babka
2016-04-07 16:11     ` Piotr Kwapulinski
2016-04-07 16:11       ` Piotr Kwapulinski
2016-04-07 16:31       ` Michal Hocko
2016-04-07 16:31         ` Michal Hocko
2016-04-08 15:32         ` Piotr Kwapulinski [this message]
2016-04-08 15:32           ` Piotr Kwapulinski
2016-04-07 16:20     ` Piotr Kwapulinski

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=20160408153228.GA1397@home.local \
    --to=kwapulinski.piotr@gmail.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=aryabinin@virtuozzo.com \
    --cc=cmetcalf@mellanox.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dave@stgolabs.net \
    --cc=denc716@gmail.com \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jack@suse.cz \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=koct9i@gmail.com \
    --cc=kuleshovmail@gmail.com \
    --cc=ldufour@linux.vnet.ibm.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mingo@kernel.org \
    --cc=mszeredi@suse.cz \
    --cc=mtk.manpages@gmail.com \
    --cc=oleg@redhat.com \
    --cc=rientjes@google.com \
    --cc=toshi.kani@hpe.com \
    --cc=vbabka@suse.cz \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xiexiuqi@huawei.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).