linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Khlebnikov <koct9i@gmail.com>
To: Eric B Munson <emunson@akamai.com>
Cc: Michal Hocko <mhocko@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	Jonathan Corbet <corbet@lwn.net>,
	"Kirill A. Shutemov" <kirill@shutemov.name>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Linux API <linux-api@vger.kernel.org>
Subject: Re: [PATCH v7 3/6] mm: Introduce VM_LOCKONFAULT
Date: Mon, 24 Aug 2015 13:17:49 +0300	[thread overview]
Message-ID: <CALYGNiPcruTM+2KKNZr7ebCVCPsqytSrW8rSzSmj+1Qp4OqXEw@mail.gmail.com> (raw)
In-Reply-To: <20150821183132.GA12835@akamai.com>

On Fri, Aug 21, 2015 at 9:31 PM, Eric B Munson <emunson@akamai.com> wrote:
> On Fri, 21 Aug 2015, Michal Hocko wrote:
>
>> On Thu 20-08-15 13:03:09, Eric B Munson wrote:
>> > On Thu, 20 Aug 2015, Michal Hocko wrote:
>> >
>> > > On Wed 19-08-15 17:33:45, Eric B Munson wrote:
>> > > [...]
>> > > > The group which asked for this feature here
>> > > > wants the ability to distinguish between LOCKED and LOCKONFAULT regions
>> > > > and without the VMA flag there isn't a way to do that.
>> > >
>> > > Could you be more specific on why this is needed?
>> >
>> > They want to keep metrics on the amount of memory used in a LOCKONFAULT
>> > region versus the address space of the region.
>>
>> /proc/<pid>/smaps already exports that information AFAICS. It exports
>> VMA flags including VM_LOCKED and if rss < size then this is clearly
>> LOCKONFAULT because the standard mlock semantic is to populate. Would
>> that be sufficient?
>>
>> Now, it is true that LOCKONFAULT wouldn't be distinguishable from
>> MAP_LOCKED which failed to populate but does that really matter? It is
>> LOCKONFAULT in a way as well.
>
> Does that matter to my users?  No, they do not use MAP_LOCKED at all so
> any VMA with VM_LOCKED set and rss < size is lock on fault.  Will it
> matter to others?  I suspect so, but these are likely to be the same
> group of users which will be suprised to learn that MAP_LOCKED does not
> guarantee that the entire range is faulted in on return from mmap.
>
>>
>> > > > Do we know that these last two open flags are needed right now or is
>> > > > this speculation that they will be and that none of the other VMA flags
>> > > > can be reclaimed?
>> > >
>> > > I do not think they are needed by anybody right now but that is not a
>> > > reason why it should be used without a really strong justification.
>> > > If the discoverability is really needed then fair enough but I haven't
>> > > seen any justification for that yet.
>> >
>> > To be completely clear you believe that if the metrics collection is
>> > not a strong enough justification, it is better to expand the mm_struct
>> > by another unsigned long than to use one of these bits right?
>>
>> A simple bool is sufficient for that. And yes I think we should go with
>> per mm_struct flag rather than the additional vma flag if it has only
>> the global (whole address space) scope - which would be the case if the
>> LOCKONFAULT is always an mlock modifier and the persistance is needed
>> only for MCL_FUTURE. Which is imho a sane semantic.
>
> I am in the middle of implementing lock on fault this way, but I cannot
> see how we will hanlde mremap of a lock on fault region.  Say we have
> the following:
>
>     addr = mmap(len, MAP_ANONYMOUS, ...);
>     mlock(addr, len, MLOCK_ONFAULT);
>     ...
>     mremap(addr, len, 2 * len, ...)
>
> There is no way for mremap to know that the area being remapped was lock
> on fault so it will be locked and prefaulted by remap.  How can we avoid
> this without tracking per vma if it was locked with lock or lock on
> fault?

remap can count filled ptes and prefault only completely populated areas.

There might be a problem after failed populate: remap will handle them
as lock on fault. In this case we can fill ptes with swap-like non-present
entries to remember that fact and count them as should-be-locked pages.

--
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>

  reply	other threads:[~2015-08-24 10:17 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-09  5:22 [PATCH v7 0/6] Allow user to request memory to be locked on page fault Eric B Munson
2015-08-09  5:22 ` [PATCH v7 1/6] mm: mlock: Refactor mlock, munlock, and munlockall code Eric B Munson
2015-08-12  9:42   ` Michal Hocko
2015-08-09  5:22 ` [PATCH v7 2/6] mm: mlock: Add new mlock system call Eric B Munson
2015-08-12  9:45   ` Michal Hocko
2015-08-09  5:22 ` [PATCH v7 3/6] mm: Introduce VM_LOCKONFAULT Eric B Munson
2015-08-12 11:59   ` Michal Hocko
2015-08-19 21:33     ` Eric B Munson
2015-08-20  7:53       ` Vlastimil Babka
2015-08-20  7:56       ` Michal Hocko
2015-08-20 17:03         ` Eric B Munson
2015-08-21  7:25           ` Michal Hocko
2015-08-21 18:31             ` Eric B Munson
2015-08-24 10:17               ` Konstantin Khlebnikov [this message]
2015-08-24 13:30                 ` Vlastimil Babka
2015-08-24 13:50                   ` Konstantin Khlebnikov
2015-08-24 14:27                     ` Vlastimil Babka
2015-08-24 15:09                       ` Eric B Munson
2015-08-24 15:46                         ` Konstantin Khlebnikov
2015-08-24 15:55                           ` Eric B Munson
2015-08-24 16:22                             ` Konstantin Khlebnikov
2015-08-24 17:00                               ` Eric B Munson
2015-08-24 18:53                                 ` Konstantin Khlebnikov
2015-08-24 20:26                                   ` Eric B Munson
2015-08-25 13:41               ` Michal Hocko
2015-08-25 13:55                 ` Vlastimil Babka
2015-08-25 14:29                   ` Michal Hocko
2015-08-25 13:58                 ` Konstantin Khlebnikov
2015-08-25 14:29                 ` Eric B Munson
2015-08-25 18:58                   ` Michal Hocko
2015-08-25 19:03                     ` Eric B Munson
2015-08-26  7:20                       ` Michal Hocko
2015-08-26 15:35                         ` Vlastimil Babka
2015-08-09  5:22 ` [PATCH v7 4/6] mm: mlock: Add mlock flags to enable VM_LOCKONFAULT usage Eric B Munson
2015-08-09  5:22 ` [PATCH v7 5/6] selftests: vm: Add tests for lock on fault Eric B Munson
2015-08-09  5:22 ` [PATCH v7 6/6] mips: Add entry for new mlock2 syscall 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=CALYGNiPcruTM+2KKNZr7ebCVCPsqytSrW8rSzSmj+1Qp4OqXEw@mail.gmail.com \
    --to=koct9i@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emunson@akamai.com \
    --cc=kirill@shutemov.name \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=vbabka@suse.cz \
    /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