From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Sasha Levin <sasha.levin@oracle.com>,
linux-mm@kvack.org
Subject: Re: [PATCH 4/4] thp: increase split_huge_page() success rate
Date: Tue, 29 Dec 2015 22:57:09 +0200 [thread overview]
Message-ID: <20151229205709.GB6260@node.shutemov.name> (raw)
In-Reply-To: <20151228153026.628d44126a848e14bcbbce68@linux-foundation.org>
On Mon, Dec 28, 2015 at 03:30:26PM -0800, Andrew Morton wrote:
> On Thu, 24 Dec 2015 14:51:23 +0300 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote:
>
> > During freeze_page(), we remove the page from rmap. It munlocks the page
> > if it was mlocked. clear_page_mlock() uses of lru cache, which temporary
> > pins page.
> >
> > Let's drain the lru cache before checking page's count vs. mapcount.
> > The change makes mlocked page split on first attempt, if it was not
> > pinned by somebody else.
> >
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > ---
> > mm/huge_memory.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> > index 1a988d9b86ef..4c1c292b7ddd 100644
> > --- a/mm/huge_memory.c
> > +++ b/mm/huge_memory.c
> > @@ -3417,6 +3417,9 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)
> > freeze_page(anon_vma, head);
> > VM_BUG_ON_PAGE(compound_mapcount(head), head);
> >
> > + /* Make sure the page is not on per-CPU pagevec as it takes pin */
> > + lru_add_drain();
> > +
> > /* Prevent deferred_split_scan() touching ->_count */
> > spin_lock(&split_queue_lock);
> > count = page_count(head);
>
> Fair enough.
>
> mlocked pages are rare and lru_add_drain() isn't free. We could easily
> and cheaply make page_remove_rmap() return "bool was_mlocked" (or,
> better, "bool might_be_in_lru_cache") to skip this overhead.
Propagating it back is painful. What about this instead:
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index ecb4ed1a821a..edfa53eda9ca 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3385,6 +3385,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)
struct page *head = compound_head(page);
struct anon_vma *anon_vma;
int count, mapcount, ret;
+ bool mlocked;
VM_BUG_ON_PAGE(is_huge_zero_page(page), page);
VM_BUG_ON_PAGE(!PageAnon(page), page);
@@ -3415,11 +3416,13 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)
goto out_unlock;
}
+ mlocked = PageMlocked(page);
freeze_page(anon_vma, head);
VM_BUG_ON_PAGE(compound_mapcount(head), head);
/* Make sure the page is not on per-CPU pagevec as it takes pin */
- lru_add_drain();
+ if (mlocked)
+ lru_add_drain();
/* Prevent deferred_split_scan() touching ->_count */
spin_lock(&split_queue_lock);
--
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:[~2015-12-29 20:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-24 11:51 [PATCH 0/4] THP updates Kirill A. Shutemov
2015-12-24 11:51 ` [PATCH 1/4] thp: add debugfs handle to split all huge pages Kirill A. Shutemov
2016-01-05 9:44 ` Vlastimil Babka
2015-12-24 11:51 ` [PATCH 2/4] thp: fix regression in handling mlocked pages in __split_huge_pmd() Kirill A. Shutemov
2015-12-24 18:51 ` Dan Williams
2015-12-24 22:56 ` Kirill A. Shutemov
2015-12-25 1:10 ` Sasha Levin
2015-12-25 1:12 ` Dan Williams
2015-12-25 1:17 ` Sasha Levin
2015-12-28 12:58 ` Kirill A. Shutemov
2015-12-24 11:51 ` [PATCH 3/4] mm: stop __munlock_pagevec_fill() if THP enounted Kirill A. Shutemov
2015-12-25 1:09 ` Sasha Levin
2015-12-28 23:22 ` Andrew Morton
2015-12-29 11:27 ` Kirill A. Shutemov
2016-01-05 10:18 ` Vlastimil Babka
2015-12-24 11:51 ` [PATCH 4/4] thp: increase split_huge_page() success rate Kirill A. Shutemov
2015-12-28 23:30 ` Andrew Morton
2015-12-29 20:57 ` Kirill A. Shutemov [this message]
2016-01-05 10:22 ` Vlastimil Babka
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=20151229205709.GB6260@node.shutemov.name \
--to=kirill@shutemov.name \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=sasha.levin@oracle.com \
/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).