From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Vlastimil Babka <vbabka@suse.cz>, Hugh Dickins <hughd@google.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Sasha Levin <sasha.levin@oracle.com>,
linux-mm@kvack.org
Subject: Re: [PATCH 2/2] mm, thp: clear PG_mlocked when last mapping gone
Date: Tue, 5 Jan 2016 16:37:03 +0200 [thread overview]
Message-ID: <20160105143702.GB19907@node.shutemov.name> (raw)
In-Reply-To: <568B8ECE.7020605@suse.cz>
On Tue, Jan 05, 2016 at 10:37:18AM +0100, Vlastimil Babka wrote:
> On 12/29/2015 09:46 PM, Kirill A. Shutemov wrote:
> >I missed clear_page_mlock() in page_remove_anon_compound_rmap().
> >It usually shouldn't cause any problems since we munlock pages
> >explicitly, but in conjunction with missed munlock in __oom_reap_vmas()
> >it causes problems:
> > http://lkml.kernel.org/r/5661FBB6.6050307@oracle.com
> >
> >Let's put it in place an mirror behaviour for small pages.
> >
> >NOTE: I'm not entirely sure why we ever need clear_page_mlock() in
> >page_remove_rmap() codepath. It looks redundant to me as we munlock
> >pages anyway. But this is out of scope of the patch.
>
> Git blame actually quickly points to commit e6c509f854550 which explains it
> :)
Okay, it explains situation somewhat.
The thing which still makes me a bit uncomfortable with the situation is
that we remove PG_mlocked only when the last mapping of the page gone.
It's not necessary the mapping which was VM_LOCKED. It means we can rely
on the clear_page_mlock() inside page_remove_rmap() only when remove all
page mappings at once (like in truncate case).
The clear_page_mlock() also helps hide real mlock leak bugs, like fixed by
patch 1/2: we saliently munlock page when last mapping gone, even if the
VMA was never been mlocked in the first place.
That's kinda suboptimal.
>
> >
> >The patch can be folded into
> > "thp: allow mlocked THP again"
> >
> >Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>
> Ack.
>
> >Reported-by: Sasha Levin <sasha.levin@oracle.com>
> >---
> > mm/rmap.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> >diff --git a/mm/rmap.c b/mm/rmap.c
> >index 384516fb7495..68af2e32f7ed 100644
> >--- a/mm/rmap.c
> >+++ b/mm/rmap.c
> >@@ -1356,6 +1356,9 @@ static void page_remove_anon_compound_rmap(struct page *page)
> > nr = HPAGE_PMD_NR;
> > }
> >
> >+ if (unlikely(PageMlocked(page)))
> >+ clear_page_mlock(page);
> >+
> > if (nr) {
> > __mod_zone_page_state(page_zone(page), NR_ANON_PAGES, -nr);
> > deferred_split_huge_page(page);
> >
>
> --
> 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>
--
Kirill A. Shutemov
--
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>
next prev parent reply other threads:[~2016-01-05 14:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-29 20:46 [PATCH 0/2] THP mlock fix Kirill A. Shutemov
2015-12-29 20:46 ` [PATCH 1/2] mm, oom: skip mlocked VMAs in __oom_reap_vmas() Kirill A. Shutemov
2016-01-05 12:47 ` Michal Hocko
2016-01-05 13:10 ` Kirill A. Shutemov
2016-01-05 13:31 ` Michal Hocko
2016-01-05 15:03 ` Kirill A. Shutemov
2016-01-05 15:45 ` Michal Hocko
2016-01-05 13:33 ` Michal Hocko
2016-01-05 15:03 ` Kirill A. Shutemov
2016-01-05 15:44 ` Sasha Levin
2015-12-29 20:46 ` [PATCH 2/2] mm, thp: clear PG_mlocked when last mapping gone Kirill A. Shutemov
2016-01-05 9:37 ` Vlastimil Babka
2016-01-05 14:37 ` Kirill A. Shutemov [this message]
2015-12-29 20:52 ` [PATCH 0/2] THP mlock fix Sasha Levin
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=20160105143702.GB19907@node.shutemov.name \
--to=kirill@shutemov.name \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=sasha.levin@oracle.com \
--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;
as well as URLs for NNTP newsgroup(s).