From: Gleb Natapov <gleb@redhat.com>
To: WANG Cong <xiyou.wangcong@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-api@vger.kernel.org
Subject: Re: [PATCH v3][RFC] add MAP_UNLOCKED mmap flag
Date: Thu, 8 Oct 2009 11:16:12 +0200 [thread overview]
Message-ID: <20091008091611.GD16702@redhat.com> (raw)
In-Reply-To: <874oqap7xw.fsf@gmail.com>
On Thu, Oct 08, 2009 at 05:10:35PM +0800, WANG Cong wrote:
> Gleb Natapov <gleb@redhat.com> writes:
>
> > If application does mlockall(MCL_FUTURE) it is no longer possible to
> > mmap file bigger than main memory or allocate big area of anonymous
> > memory. Sometimes it is desirable to lock everything related to program
> > execution into memory, but still be able to mmap big file or allocate
> > huge amount of memory and allow OS to swap them on demand. MAP_UNLOCKED
> > allows to do that.
> >
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
>
> <snip>
>
> > diff --git a/mm/mmap.c b/mm/mmap.c
> > index 73f5e4b..ecc4471 100644
> > --- a/mm/mmap.c
> > +++ b/mm/mmap.c
> > @@ -985,6 +985,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
> > if (!can_do_mlock())
> > return -EPERM;
> >
> > + if (flags & MAP_UNLOCKED)
> > + vm_flags &= ~VM_LOCKED;
> > +
> > /* mlock MCL_FUTURE? */
> > if (vm_flags & VM_LOCKED) {
> > unsigned long locked, lock_limit;
>
> So, if I read it correctly, it is perfectly legal to set
> both MAP_LOCKED and MAP_UNLOCKED at the same time? While
> the behavior is still same as only setting MAP_UNLOCKED.
>
> Is this what we expect?
>
This is what code does currently. Should we return EINVAL in this case?
--
Gleb.
--
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: Gleb Natapov <gleb@redhat.com>
To: WANG Cong <xiyou.wangcong@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-api@vger.kernel.org
Subject: Re: [PATCH v3][RFC] add MAP_UNLOCKED mmap flag
Date: Thu, 8 Oct 2009 11:16:12 +0200 [thread overview]
Message-ID: <20091008091611.GD16702@redhat.com> (raw)
In-Reply-To: <874oqap7xw.fsf@gmail.com>
On Thu, Oct 08, 2009 at 05:10:35PM +0800, WANG Cong wrote:
> Gleb Natapov <gleb@redhat.com> writes:
>
> > If application does mlockall(MCL_FUTURE) it is no longer possible to
> > mmap file bigger than main memory or allocate big area of anonymous
> > memory. Sometimes it is desirable to lock everything related to program
> > execution into memory, but still be able to mmap big file or allocate
> > huge amount of memory and allow OS to swap them on demand. MAP_UNLOCKED
> > allows to do that.
> >
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
>
> <snip>
>
> > diff --git a/mm/mmap.c b/mm/mmap.c
> > index 73f5e4b..ecc4471 100644
> > --- a/mm/mmap.c
> > +++ b/mm/mmap.c
> > @@ -985,6 +985,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
> > if (!can_do_mlock())
> > return -EPERM;
> >
> > + if (flags & MAP_UNLOCKED)
> > + vm_flags &= ~VM_LOCKED;
> > +
> > /* mlock MCL_FUTURE? */
> > if (vm_flags & VM_LOCKED) {
> > unsigned long locked, lock_limit;
>
> So, if I read it correctly, it is perfectly legal to set
> both MAP_LOCKED and MAP_UNLOCKED at the same time? While
> the behavior is still same as only setting MAP_UNLOCKED.
>
> Is this what we expect?
>
This is what code does currently. Should we return EINVAL in this case?
--
Gleb.
next prev parent reply other threads:[~2009-10-08 9:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-06 19:03 [PATCH v3][RFC] add MAP_UNLOCKED mmap flag Gleb Natapov
2009-10-06 19:03 ` Gleb Natapov
2009-10-08 9:10 ` WANG Cong
2009-10-08 9:10 ` WANG Cong
2009-10-08 9:16 ` Gleb Natapov [this message]
2009-10-08 9:16 ` Gleb Natapov
2009-10-08 9:37 ` WANG Cong
2009-10-08 9:37 ` WANG Cong
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=20091008091611.GD16702@redhat.com \
--to=gleb@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=xiyou.wangcong@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.