All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	Sasha Levin <sasha.levin@oracle.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: [PATCHv5 24/28] thp, mm: split_huge_page(): caller need to lock page
Date: Fri, 24 Apr 2015 00:03:59 +0300	[thread overview]
Message-ID: <1429823043-157133-25-git-send-email-kirill.shutemov@linux.intel.com> (raw)
In-Reply-To: <1429823043-157133-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>
Tested-by: Sasha Levin <sasha.levin@oracle.com>
---
 mm/memory-failure.c | 12 +++++++++---
 mm/migrate.c        |  8 ++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 441eff52d099..d9b06727e480 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -996,7 +996,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
@@ -1750,10 +1753,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 b51e88c9dba2..03b9c4ba56dc 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -932,9 +932,13 @@ static ICE_noinline int unmap_and_move(new_page_t get_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


WARNING: multiple messages have this Message-ID (diff)
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>,
	Sasha Levin <sasha.levin@oracle.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: [PATCHv5 24/28] thp, mm: split_huge_page(): caller need to lock page
Date: Fri, 24 Apr 2015 00:03:59 +0300	[thread overview]
Message-ID: <1429823043-157133-25-git-send-email-kirill.shutemov@linux.intel.com> (raw)
In-Reply-To: <1429823043-157133-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>
Tested-by: Sasha Levin <sasha.levin@oracle.com>
---
 mm/memory-failure.c | 12 +++++++++---
 mm/migrate.c        |  8 ++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 441eff52d099..d9b06727e480 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -996,7 +996,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
@@ -1750,10 +1753,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 b51e88c9dba2..03b9c4ba56dc 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -932,9 +932,13 @@ static ICE_noinline int unmap_and_move(new_page_t get_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>

  parent reply	other threads:[~2015-04-23 21:05 UTC|newest]

Thread overview: 189+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-23 21:03 [PATCHv5 00/28] THP refcounting redesign Kirill A. Shutemov
2015-04-23 21:03 ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 01/28] mm, proc: adjust PSS calculation Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 15:49   ` Jerome Marchand
2015-05-14 14:12   ` Vlastimil Babka
2015-05-14 14:12     ` Vlastimil Babka
2015-05-15 10:56     ` Kirill A. Shutemov
2015-05-15 10:56       ` Kirill A. Shutemov
2015-05-15 11:33       ` Vlastimil Babka
2015-05-15 11:33         ` Vlastimil Babka
2015-05-15 11:43         ` Kirill A. Shutemov
2015-05-15 11:43           ` Kirill A. Shutemov
2015-05-15 12:37           ` Vlastimil Babka
2015-05-15 12:37             ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 02/28] rmap: add argument to charge compound page Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 15:53   ` Jerome Marchand
2015-04-30 11:52     ` Kirill A. Shutemov
2015-04-30 11:52       ` Kirill A. Shutemov
2015-05-14 16:07   ` Vlastimil Babka
2015-05-14 16:07     ` Vlastimil Babka
2015-05-15 11:14     ` Kirill A. Shutemov
2015-05-15 11:14       ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 03/28] memcg: adjust to support new THP refcounting Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-05-15  7:44   ` Vlastimil Babka
2015-05-15  7:44     ` Vlastimil Babka
2015-05-15 11:18     ` Kirill A. Shutemov
2015-05-15 11:18       ` Kirill A. Shutemov
2015-05-15 14:57       ` Dave Hansen
2015-05-15 14:57         ` Dave Hansen
2015-05-16 23:17         ` Kirill A. Shutemov
2015-05-16 23:17           ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 04/28] mm, thp: adjust conditions when we can reuse the page on WP fault Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 15:54   ` Jerome Marchand
2015-05-15  9:15   ` Vlastimil Babka
2015-05-15  9:15     ` Vlastimil Babka
2015-05-15 11:21     ` Kirill A. Shutemov
2015-05-15 11:21       ` Kirill A. Shutemov
2015-05-15 11:35       ` Vlastimil Babka
2015-05-15 11:35         ` Vlastimil Babka
2015-05-15 13:29         ` Kirill A. Shutemov
2015-05-15 13:29           ` Kirill A. Shutemov
2015-05-19 13:00           ` Vlastimil Babka
2015-05-19 13:00             ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 05/28] mm: adjust FOLL_SPLIT for new refcounting Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-05-15 11:05   ` Vlastimil Babka
2015-05-15 11:05     ` Vlastimil Babka
2015-05-15 11:36     ` Kirill A. Shutemov
2015-05-15 11:36       ` Kirill A. Shutemov
2015-05-15 12:01       ` Vlastimil Babka
2015-05-15 12:01         ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 06/28] mm: handle PTE-mapped tail pages in gerneric fast gup implementaiton Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 15:56   ` Jerome Marchand
2015-05-15 12:46   ` Vlastimil Babka
2015-05-15 12:46     ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 07/28] thp, mlock: do not allow huge pages in mlocked area Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 15:58   ` Jerome Marchand
2015-05-15 12:56   ` Vlastimil Babka
2015-05-15 12:56     ` Vlastimil Babka
2015-05-15 13:41     ` Kirill A. Shutemov
2015-05-15 13:41       ` Kirill A. Shutemov
2015-05-19 14:37       ` Vlastimil Babka
2015-05-19 14:37         ` Vlastimil Babka
2015-05-20 12:10         ` Kirill A. Shutemov
2015-05-20 12:10           ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 08/28] khugepaged: ignore pmd tables with THP mapped with ptes Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 15:59   ` Jerome Marchand
2015-05-15 12:59   ` Vlastimil Babka
2015-05-15 12:59     ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 09/28] thp: rename split_huge_page_pmd() to split_huge_pmd() Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 16:00   ` Jerome Marchand
2015-05-15 13:08   ` Vlastimil Babka
2015-05-15 13:08     ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 10/28] mm, vmstats: new THP splitting event Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 16:02   ` Jerome Marchand
2015-05-15 13:10   ` Vlastimil Babka
2015-05-15 13:10     ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 11/28] mm: temporally mark THP broken Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 12/28] thp: drop all split_huge_page()-related code Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 13/28] mm: drop tail page refcounting Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-05-18  9:48   ` Vlastimil Babka
2015-05-18  9:48     ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 14/28] futex, thp: remove special case for THP in get_futex_key Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-05-18 11:49   ` Vlastimil Babka
2015-05-18 11:49     ` Vlastimil Babka
2015-05-18 12:13     ` Kirill A. Shutemov
2015-05-18 12:13       ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 15/28] ksm: prepare to new THP semantics Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-05-18 12:41   ` Vlastimil Babka
2015-05-18 12:41     ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 16/28] mm, thp: remove compound_lock Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 16:11   ` Jerome Marchand
2015-04-30 11:58     ` Kirill A. Shutemov
2015-04-30 11:58       ` Kirill A. Shutemov
2015-05-18 12:57   ` Vlastimil Babka
2015-05-18 12:57     ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 17/28] mm, thp: remove infrastructure for handling splitting PMDs Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 16:14   ` Jerome Marchand
2015-04-30 12:03     ` Kirill A. Shutemov
2015-04-30 12:03       ` Kirill A. Shutemov
2015-05-18 13:40   ` Vlastimil Babka
2015-05-18 13:40     ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 18/28] x86, " Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29  9:13   ` Aneesh Kumar K.V
2015-04-29  9:13     ` Aneesh Kumar K.V
2015-04-23 21:03 ` [PATCHv5 19/28] mm: store mapcount for compound page separately Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-05-18 14:32   ` Vlastimil Babka
2015-05-18 14:32     ` Vlastimil Babka
2015-05-19  3:55     ` Kirill A. Shutemov
2015-05-19  3:55       ` Kirill A. Shutemov
2015-05-19  9:01       ` Vlastimil Babka
2015-05-19  9:01         ` Vlastimil Babka
2015-04-23 21:03 ` [PATCHv5 20/28] mm: differentiate page_mapped() from page_mapcount() for compound pages Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-29 16:20   ` Jerome Marchand
2015-04-30 12:06     ` Kirill A. Shutemov
2015-04-30 12:06       ` Kirill A. Shutemov
2015-05-18 15:35   ` Vlastimil Babka
2015-05-18 15:35     ` Vlastimil Babka
2015-05-19  4:00     ` Kirill A. Shutemov
2015-05-19  4:00       ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 21/28] mm, numa: skip PTE-mapped THP on numa fault Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 22/28] thp: implement split_huge_pmd() Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-05-19  8:25   ` Vlastimil Babka
2015-05-19  8:25     ` Vlastimil Babka
2015-05-20 14:38     ` Kirill A. Shutemov
2015-05-20 14:38       ` Kirill A. Shutemov
2015-04-23 21:03 ` [PATCHv5 23/28] thp: add option to setup migration entiries during PMD split Kirill A. Shutemov
2015-04-23 21:03   ` Kirill A. Shutemov
2015-05-19 13:55   ` Vlastimil Babka
2015-05-19 13:55     ` Vlastimil Babka
2015-04-23 21:03 ` Kirill A. Shutemov [this message]
2015-04-23 21:03   ` [PATCHv5 24/28] thp, mm: split_huge_page(): caller need to lock page Kirill A. Shutemov
2015-05-19 13:55   ` Vlastimil Babka
2015-05-19 13:55     ` Vlastimil Babka
2015-04-23 21:04 ` [PATCHv5 25/28] thp: reintroduce split_huge_page() Kirill A. Shutemov
2015-04-23 21:04   ` Kirill A. Shutemov
2015-05-19 12:43   ` Vlastimil Babka
2015-05-19 12:43     ` Vlastimil Babka
2015-04-23 21:04 ` [PATCHv5 26/28] thp: introduce deferred_split_huge_page() Kirill A. Shutemov
2015-04-23 21:04   ` Kirill A. Shutemov
2015-05-19 13:54   ` Vlastimil Babka
2015-05-19 13:54     ` Vlastimil Babka
2015-04-23 21:04 ` [PATCHv5 27/28] mm: re-enable THP Kirill A. Shutemov
2015-04-23 21:04   ` Kirill A. Shutemov
2015-04-23 21:04 ` [PATCHv5 28/28] thp: update documentation Kirill A. Shutemov
2015-04-23 21:04   ` Kirill A. Shutemov
2015-04-27 23:03 ` [PATCHv5 00/28] THP refcounting redesign Andrew Morton
2015-04-27 23:03   ` Andrew Morton
2015-04-27 23:33   ` Kirill A. Shutemov
2015-04-27 23:33     ` Kirill A. Shutemov
2015-04-30  8:25 ` [RFC PATCH 0/3] Remove _PAGE_SPLITTING from ppc64 Aneesh Kumar K.V
2015-04-30  8:25   ` Aneesh Kumar K.V
2015-04-30  8:25   ` [RFC PATCH 1/3] mm/thp: Use pmdp_splitting_flush_notify to clear pmd on splitting Aneesh Kumar K.V
2015-04-30  8:25     ` Aneesh Kumar K.V
2015-04-30 13:30     ` Kirill A. Shutemov
2015-04-30 13:30       ` Kirill A. Shutemov
2015-04-30 15:59       ` Aneesh Kumar K.V
2015-04-30 15:59         ` Aneesh Kumar K.V
2015-04-30 16:47         ` Aneesh Kumar K.V
2015-04-30 16:47           ` Aneesh Kumar K.V
2015-04-30  8:25   ` [RFC PATCH 2/3] powerpc/thp: Remove _PAGE_SPLITTING and related code Aneesh Kumar K.V
2015-04-30  8:25     ` Aneesh Kumar K.V
2015-04-30  8:25   ` [RFC PATCH 3/3] mm/thp: Add new function to clear pmd on collapse Aneesh Kumar K.V
2015-04-30  8:25     ` Aneesh Kumar K.V
2015-05-15  8:55 ` [PATCHv5 00/28] THP refcounting redesign Vlastimil Babka
2015-05-15  8:55   ` Vlastimil Babka
2015-05-15 13:31   ` Kirill A. Shutemov
2015-05-15 13:31     ` 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=1429823043-157133-25-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=sasha.levin@oracle.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 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.