From: Eric B Munson <emunson@akamai.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuahkh@osg.samsung.com>,
linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mips@linux-mips.org, linux-parisc@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org,
linux-xtensa@linux-xtensa.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-api@vger.kernel.org
Subject: Re: [PATCH 0/3] Allow user to request memory to be locked on page fault
Date: Wed, 13 May 2015 10:14:42 -0400 [thread overview]
Message-ID: <20150513141442.GC1227@akamai.com> (raw)
In-Reply-To: <20150513135805.GA17708@dhcp22.suse.cz>
[-- Attachment #1: Type: text/plain, Size: 2818 bytes --]
On Wed, 13 May 2015, Michal Hocko wrote:
> On Fri 08-05-15 16:06:10, Eric B Munson wrote:
> > On Fri, 08 May 2015, Andrew Morton wrote:
> >
> > > On Fri, 8 May 2015 15:33:43 -0400 Eric B Munson <emunson@akamai.com> wrote:
> > >
> > > > mlock() allows a user to control page out of program memory, but this
> > > > comes at the cost of faulting in the entire mapping when it is
> > > > allocated. For large mappings where the entire area is not necessary
> > > > this is not ideal.
> > > >
> > > > This series introduces new flags for mmap() and mlockall() that allow a
> > > > user to specify that the covered are should not be paged out, but only
> > > > after the memory has been used the first time.
> > >
> > > Please tell us much much more about the value of these changes: the use
> > > cases, the behavioural improvements and performance results which the
> > > patchset brings to those use cases, etc.
> > >
> >
> > The primary use case is for mmaping large files read only. The process
> > knows that some of the data is necessary, but it is unlikely that the
> > entire file will be needed. The developer only wants to pay the cost to
> > read the data in once. Unfortunately developer must choose between
> > allowing the kernel to page in the memory as needed and guaranteeing
> > that the data will only be read from disk once. The first option runs
> > the risk of having the memory reclaimed if the system is under memory
> > pressure, the second forces the memory usage and startup delay when
> > faulting in the entire file.
>
> Is there any reason you cannot do this from the userspace? Start by
> mmap(PROT_NONE) and do mmap(MAP_FIXED|MAP_LOCKED|MAP_READ|other_flags_you_need)
> from the SIGSEGV handler?
> You can generate a lot of vmas that way but you can mitigate that to a
> certain level by mapping larger than PAGE_SIZE chunks in the fault
> handler. Would that work in your usecase?
This might work for the use cases I have laid out (I am not sure about
the anonymous mmap one, but I will try it). I am concerned about how
much memory management policy these suggestions push into userspace.
I am also concerned about the number of system calls required to do the
same thing. This will require a new call to mmap() for every new page
accessed in the file (or for every file_size/map_size in the multiple
page chunk). The simple case of calling mlock() on the every time the
file was accessed was significantly slower than the LOCKONFAULT flag.
Your suggestion will be better in that it avoids the extra mlock call
for pages already locked, but there still significantly more system
calls. I will add this to the program I have been using to measure
executuion times and see how it compares to the other options.
Eric
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-05-13 14:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 19:33 [PATCH 0/3] Allow user to request memory to be locked on page fault Eric B Munson
2015-05-08 19:33 ` [PATCH 1/3] Add flag to request pages are locked after " Eric B Munson
2015-05-08 19:33 ` [PATCH 2/3] Add mlockall flag for locking pages on fault Eric B Munson
[not found] ` <1431113626-19153-1-git-send-email-emunson-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
2015-05-08 19:33 ` [PATCH 3/3] Add tests for lock " Eric B Munson
2015-05-08 19:42 ` [PATCH 0/3] Allow user to request memory to be locked on page fault Andrew Morton
[not found] ` <20150508124203.6679b1d35ad9555425003929-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2015-05-08 20:06 ` Eric B Munson
2015-05-08 20:15 ` Andrew Morton
2015-05-11 14:36 ` Eric B Munson
2015-05-11 19:12 ` Andrew Morton
2015-05-11 21:05 ` Eric B Munson
2015-05-13 13:58 ` Michal Hocko
2015-05-13 14:14 ` Eric B Munson [this message]
2015-05-11 18:06 ` Eric B Munson
2015-05-13 15:00 ` Eric B Munson
[not found] ` <20150513150036.GG1227-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
2015-05-14 8:08 ` Michal Hocko
[not found] ` <20150514080812.GC6433-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-05-14 13:58 ` Eric B Munson
2015-05-15 15:35 ` Eric B Munson
2015-05-19 20:30 ` Eric B Munson
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=20150513141442.GC1227@akamai.com \
--to=emunson@akamai.com \
--cc=akpm@linux-foundation.org \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-mm@kvack.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-xtensa@linux-xtensa.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mhocko@suse.cz \
--cc=shuahkh@osg.samsung.com \
--cc=sparclinux@vger.kernel.org \
/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).