All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric B Munson <emunson@akamai.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>,
	Michal Hocko <mhocko@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	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 11:09:12 -0400	[thread overview]
Message-ID: <20150824150912.GA17005@akamai.com> (raw)
In-Reply-To: <55DB29EB.1000308@suse.cz>

[-- Attachment #1: Type: text/plain, Size: 3250 bytes --]

On Mon, 24 Aug 2015, Vlastimil Babka wrote:

> On 08/24/2015 03:50 PM, Konstantin Khlebnikov wrote:
> >On Mon, Aug 24, 2015 at 4:30 PM, Vlastimil Babka <vbabka@suse.cz> wrote:
> >>On 08/24/2015 12:17 PM, Konstantin Khlebnikov wrote:
> >>>>
> >>>>
> >>>>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.
> >>
> >>
> >>Does (and should) mremap really prefault non-present pages? Shouldn't it
> >>just prepare the page tables and that's it?
> >
> >As I see mremap prefaults pages when it extends mlocked area.
> >
> >Also quote from manpage
> >: If  the memory segment specified by old_address and old_size is locked
> >: (using mlock(2) or similar), then this lock is maintained when the segment is
> >: resized and/or relocated.  As a  consequence, the amount of memory locked
> >: by the process may change.
> 
> Oh, right... Well that looks like a convincing argument for having a
> sticky VM_LOCKONFAULT after all. Having mremap guess by scanning
> existing pte's would slow it down, and be unreliable (was the area
> completely populated because MLOCK_ONFAULT was not used or because
> the process aulted it already? Was it not populated because
> MLOCK_ONFAULT was used, or because mmap(MAP_LOCKED) failed to
> populate it all?).

Given this, I am going to stop working in v8 and leave the vma flag in
place.

> 
> The only sane alternative is to populate always for mremap() of
> VM_LOCKED areas, and document this loss of MLOCK_ONFAULT information
> as a limitation of mlock2(MLOCK_ONFAULT). Which might or might not
> be enough for Eric's usecase, but it's somewhat ugly.
> 

I don't think that this is the right solution, I would be really
surprised as a user if an area I locked with MLOCK_ONFAULT was then
fully locked and prepopulated after mremap().

> >>
> >>>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.
> >>
> >>
> >>I don't think we should strive to have mremap try to fix the inherent
> >>unreliability of mmap (MAP_POPULATE)?
> >
> >I don't think so. MAP_POPULATE works only when mmap happens.
> >Flag MREMAP_POPULATE might be a good idea. Just for symmetry.
> 
> Maybe, but please do it as a separate series.
> 
> --
> 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>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-08-24 15:09 UTC|newest]

Thread overview: 87+ 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 ` Eric B Munson
2015-08-09  5:22 ` 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-09  5:22   ` Eric B Munson
2015-08-12  9:42   ` Michal Hocko
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-09  5:22 ` Eric B Munson
2015-08-09  5:22   ` Eric B Munson
2015-08-09  5:22   ` Eric B Munson
2015-08-09  5:22   ` Eric B Munson
2015-08-09  5:22   ` Eric B Munson
2015-08-12  9:45   ` Michal Hocko
2015-08-12  9:45   ` Michal Hocko
2015-08-12  9:45     ` Michal Hocko
2015-08-12  9:45     ` Michal Hocko
2015-08-12  9:45     ` Michal Hocko
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-09  5:22   ` Eric B Munson
2015-08-12 11:59   ` Michal Hocko
2015-08-12 11:59     ` Michal Hocko
2015-08-19 21:33     ` Eric B Munson
     [not found]       ` <20150819213345.GB4536-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
2015-08-20  7:53         ` Vlastimil Babka
2015-08-20  7:53           ` Vlastimil Babka
2015-08-20  7:53           ` Vlastimil Babka
2015-08-20  7:56         ` Michal Hocko
2015-08-20  7:56           ` Michal Hocko
2015-08-20  7:56           ` Michal Hocko
2015-08-20 17:03           ` Eric B Munson
     [not found]             ` <20150820170309.GA11557-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
2015-08-21  7:25               ` Michal Hocko
2015-08-21  7:25                 ` Michal Hocko
2015-08-21  7:25                 ` Michal Hocko
     [not found]                 ` <20150821072552.GF23723-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-08-21 18:31                   ` Eric B Munson
2015-08-21 18:31                     ` Eric B Munson
     [not found]                     ` <20150821183132.GA12835-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
2015-08-24 10:17                       ` Konstantin Khlebnikov
2015-08-24 10:17                         ` Konstantin Khlebnikov
2015-08-24 10:17                         ` Konstantin Khlebnikov
2015-08-24 13:30                         ` Vlastimil Babka
2015-08-24 13:30                           ` Vlastimil Babka
     [not found]                           ` <55DB1C77.8070705-AlSwsSmVLrQ@public.gmane.org>
2015-08-24 13:50                             ` Konstantin Khlebnikov
2015-08-24 13:50                               ` Konstantin Khlebnikov
2015-08-24 13:50                               ` Konstantin Khlebnikov
     [not found]                               ` <CALYGNiNuZgQFzZ+_dQsPOvSJAX7QfZ38zbabn4wRc=oC5Lb9wA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-08-24 14:27                                 ` Vlastimil Babka
2015-08-24 14:27                                   ` Vlastimil Babka
2015-08-24 14:27                                   ` Vlastimil Babka
2015-08-24 15:09                                   ` Eric B Munson [this message]
2015-08-24 15:46                                     ` Konstantin Khlebnikov
2015-08-24 15:46                                       ` Konstantin Khlebnikov
2015-08-24 15:55                                       ` Eric B Munson
     [not found]                                         ` <20150824155503.GB17005-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
2015-08-24 16:22                                           ` Konstantin Khlebnikov
2015-08-24 16:22                                             ` Konstantin Khlebnikov
2015-08-24 16:22                                             ` Konstantin Khlebnikov
2015-08-24 17:00                                             ` Eric B Munson
     [not found]                                               ` <20150824170028.GC17005-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
2015-08-24 18:53                                                 ` Konstantin Khlebnikov
2015-08-24 18:53                                                   ` Konstantin Khlebnikov
2015-08-24 18:53                                                   ` Konstantin Khlebnikov
     [not found]                                                   ` <CALYGNiO3r9Yx7xeS-rZ_nVCR+BRP4d0-Fnd0omkBDdh1ftnExg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-08-24 20:26                                                     ` Eric B Munson
2015-08-24 20:26                                                       ` Eric B Munson
2015-08-25 13:41                       ` Michal Hocko
2015-08-25 13:41                         ` Michal Hocko
2015-08-25 13:41                         ` Michal Hocko
2015-08-25 13:55                         ` Vlastimil Babka
2015-08-25 13:55                           ` Vlastimil Babka
2015-08-25 14:29                           ` Michal Hocko
2015-08-25 14:29                             ` Michal Hocko
     [not found]                         ` <20150825134154.GB6285-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-08-25 13:58                           ` Konstantin Khlebnikov
2015-08-25 13:58                             ` Konstantin Khlebnikov
2015-08-25 13:58                             ` Konstantin Khlebnikov
2015-08-25 14:29                         ` Eric B Munson
     [not found]                           ` <20150825142902.GF17005-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
2015-08-25 18:58                             ` Michal Hocko
2015-08-25 18:58                               ` Michal Hocko
2015-08-25 18:58                               ` Michal Hocko
2015-08-25 19:03                               ` Eric B Munson
     [not found]                                 ` <20150825190300.GG17005-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
2015-08-26  7:20                                   ` Michal Hocko
2015-08-26  7:20                                     ` Michal Hocko
2015-08-26  7:20                                     ` Michal Hocko
2015-08-26 15:35                                     ` Vlastimil Babka
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   ` Eric B Munson
2015-08-09  5:22   ` 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   ` Eric B Munson
2015-08-09  5:22 ` [PATCH v7 6/6] mips: Add entry for new mlock2 syscall Eric B Munson
2015-08-09  5:22   ` 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=20150824150912.GA17005@akamai.com \
    --to=emunson@akamai.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kirill@shutemov.name \
    --cc=koct9i@gmail.com \
    --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 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.