Re: [PATCH 00/13] mm/munlock: rework of mlock+munlock page handling

Michal Hocko
2022-02-09T21:01:33Z

On Wed 09-02-22 08:21:17, Hugh Dickins wrote:
> On Wed, 9 Feb 2022, Michal Hocko wrote:
[...]
> > The only thing that is not entirely clear to me at the moment is why you
> > have chosen to ignore already mapped LOCKONFAULT pages. They will
> > eventually get sorted out during the reclaim/migration but this can
> > backfire if too many pages have been pre-faulted before LOCKONFAULT
> > call. Maybe not an interesting case in the first place but I am still
> > wondering why you have chosen that way.
>
> I'm puzzled: what makes you think I'm ignoring already mapped LOCKONFAULT
> pages? I'd consider that a bug.

I've had the following path in mind
__mm_populate
populate_vma_page_range
if (vma->vm_flags & VM_LOCKONFAULT)
return nr_page

which means that __get_user_pages is not called at all. This also means
that follow_page_mask is skipped. The page table walk used to mark
already mapped pages as mlocked so unless I miss some other path it
would stay on its original LRU list and only get real mlock protection
when encountered by the reclaim or migration.

> It is the case, isn't it, that a VM_LOCKONFAULT area always has VM_LOCKED
> set too? If I've got that wrong, yes, I'll need to revisit conditions.

Yes, I did't really mean we would lose the mlock protection. We would
just do the lazy mlock also on pages which are already mapped. This is
certainly not a correctness issue - althoug stats might be off - but it
could polute existing LRUs with mlocked pages rather easily.

As I've said. Either I am still missing something or this might even not
be a big deal in real life. I was mostly curious about the choice to
exclude the page table walk for LOCKONFAULT.
--
Michal Hocko
SUSE Labs