From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Andrea Arcangeli <aarcange@redhat.com>,
Hugh Dickins <hughd@google.com>
Cc: Dave Hansen <dave.hansen@intel.com>, Mel Gorman <mgorman@suse.de>,
Rik van Riel <riel@redhat.com>, Vlastimil Babka <vbabka@suse.cz>,
Christoph Lameter <cl@gentwo.org>,
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
Steve Capper <steve.capper@linaro.org>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.cz>,
Jerome Marchand <jmarchan@redhat.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: [PATCHv3 18/24] thp, mm: split_huge_page(): caller need to lock page
Date: Thu, 12 Feb 2015 18:18:32 +0200 [thread overview]
Message-ID: <1423757918-197669-19-git-send-email-kirill.shutemov@linux.intel.com> (raw)
In-Reply-To: <1423757918-197669-1-git-send-email-kirill.shutemov@linux.intel.com>
We're going to use migration entries instead of compound_lock() to
stabilize page refcounts. Setup and remove migration entries require
page to be locked.
Some of split_huge_page() callers already have the page locked. Let's
require everybody to lock the page before calling split_huge_page().
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
mm/huge_memory.c | 1 +
mm/ksm.c | 6 ++++--
mm/memory-failure.c | 12 +++++++++---
mm/migrate.c | 8 ++++++--
4 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index fa79d3b89825..bb9be39de242 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1841,6 +1841,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)
BUG_ON(is_huge_zero_page(page));
BUG_ON(!PageAnon(page));
+ BUG_ON(!PageLocked(page));
/*
* The caller does not necessarily hold an mmap_sem that would prevent
diff --git a/mm/ksm.c b/mm/ksm.c
index 92182eeba87d..a8a88b0f6f62 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -987,9 +987,11 @@ static int page_trans_compound_anon_split(struct page *page)
* Recheck we got the reference while the head
* was still anonymous.
*/
- if (PageAnon(transhuge_head))
+ if (PageAnon(transhuge_head)) {
+ lock_page(transhuge_head);
ret = split_huge_page(transhuge_head);
- else
+ unlock_page(transhuge_head);
+ } else
/*
* Retry later if split_huge_page run
* from under us.
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 1a735fad2a13..006a891c9222 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -950,7 +950,10 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
* enough * to be safe.
*/
if (!PageHuge(hpage) && PageAnon(hpage)) {
- if (unlikely(split_huge_page(hpage))) {
+ lock_page(hpage);
+ ret = split_huge_page(hpage);
+ unlock_page(hpage);
+ if (unlikely(ret)) {
/*
* FIXME: if splitting THP is failed, it is
* better to stop the following operation rather
@@ -1696,10 +1699,13 @@ int soft_offline_page(struct page *page, int flags)
return -EBUSY;
}
if (!PageHuge(page) && PageTransHuge(hpage)) {
- if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) {
+ lock_page(page);
+ ret = split_huge_page(hpage);
+ unlock_page(page);
+ if (unlikely(ret)) {
pr_info("soft offline: %#lx: failed to split THP\n",
pfn);
- return -EBUSY;
+ return ret;
}
}
diff --git a/mm/migrate.c b/mm/migrate.c
index 01449826b914..91a67029bb18 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -920,9 +920,13 @@ static int unmap_and_move(new_page_t get_new_page, free_page_t put_new_page,
goto out;
}
- if (unlikely(PageTransHuge(page)))
- if (unlikely(split_huge_page(page)))
+ if (unlikely(PageTransHuge(page))) {
+ lock_page(page);
+ rc = split_huge_page(page);
+ unlock_page(page);
+ if (rc)
goto out;
+ }
rc = __unmap_and_move(page, newpage, force, mode);
--
2.1.4
--
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-02-12 16:19 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-12 16:18 [PATCHv3 00/24] THP refcounting redesign Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 01/24] thp: cluster split_huge_page* code together Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 02/24] mm: change PageAnon() and page_anon_vma() to work on tail pages Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 03/24] mm: avoid PG_locked " Kirill A. Shutemov
2015-02-12 19:55 ` Rik van Riel
2015-02-12 20:10 ` Rik van Riel
2015-03-03 13:21 ` Aneesh Kumar K.V
2015-03-03 13:35 ` Kirill A. Shutemov
2015-03-03 15:21 ` Aneesh Kumar K.V
2015-02-12 16:18 ` [PATCHv3 04/24] rmap: add argument to charge compound page Kirill A. Shutemov
2015-02-12 21:10 ` Rik van Riel
2015-02-16 15:20 ` Kirill A. Shutemov
2015-02-20 17:39 ` Jerome Marchand
2015-02-23 16:21 ` Vlastimil Babka
2015-03-04 11:52 ` Kirill A. Shutemov
2015-03-04 12:09 ` Vlastimil Babka
2015-03-04 13:26 ` Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 05/24] mm, proc: adjust PSS calculation Kirill A. Shutemov
2015-02-20 17:31 ` Jerome Marchand
2015-02-23 13:52 ` Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 06/24] mm: store mapcount for compound page separately Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 07/24] mm, thp: adjust conditions when we can reuse the page on WP fault Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 08/24] mm: adjust FOLL_SPLIT for new refcounting Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 09/24] thp, mlock: do not allow huge pages in mlocked area Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 10/24] khugepaged: ignore pmd tables with THP mapped with ptes Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 11/24] thp: rename split_huge_page_pmd() to split_huge_pmd() Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 12/24] thp: PMD splitting without splitting compound page Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 13/24] mm, vmstats: new THP splitting event Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 14/24] thp: implement new split_huge_page() Kirill A. Shutemov
2015-02-12 17:07 ` Sasha Levin
2015-02-12 19:24 ` Sasha Levin
2015-02-16 15:57 ` Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 15/24] mm, thp: remove infrastructure for handling splitting PMDs Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 16/24] x86, " Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 17/24] futex, thp: remove special case for THP in get_futex_key Kirill A. Shutemov
2015-02-12 16:18 ` Kirill A. Shutemov [this message]
2015-02-12 16:18 ` [PATCHv3 19/24] thp, mm: use migration entries to freeze page counts on split Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 20/24] mm, thp: remove compound_lock Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 21/24] thp: introduce deferred_split_huge_page() Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 22/24] memcg: adjust to support new THP refcounting Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 23/24] ksm: split huge pages on follow_page() Kirill A. Shutemov
2015-02-12 16:18 ` [PATCHv3 24/24] thp: update documentation Kirill A. Shutemov
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=1423757918-197669-19-git-send-email-kirill.shutemov@linux.intel.com \
--to=kirill.shutemov@linux.intel.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=cl@gentwo.org \
--cc=dave.hansen@intel.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=jmarchan@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=riel@redhat.com \
--cc=steve.capper@linaro.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