linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, hugetlb, soft_offline: save compound page order before page migration
@ 2017-09-12 20:43 Alexandru Moise
  2017-09-12 20:54 ` Andrew Morton
  2017-09-13  0:13 ` Naoya Horiguchi
  0 siblings, 2 replies; 7+ messages in thread
From: Alexandru Moise @ 2017-09-12 20:43 UTC (permalink / raw)
  To: linux-kernel, khandual, akpm, mhocko, aarcange, minchan, hillf.zj,
	shli, rppt, kirill.shutemov, mgorman, rientjes, riel, linux-mm

This fixes a bug in madvise() where if you'd try to soft offline a
hugepage via madvise(), while walking the address range you'd end up,
using the wrong page offset due to attempting to get the compound
order of a former but presently not compound page, due to dissolving
the huge page (since c3114a8).

Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com>
---
 mm/madvise.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index 21261ff0466f..25bade36e9ca 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -625,18 +625,26 @@ static int madvise_inject_error(int behavior,
 {
 	struct page *page;
 	struct zone *zone;
+	unsigned int order;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	for (; start < end; start += PAGE_SIZE <<
-				compound_order(compound_head(page))) {
+
+	for (; start < end; start += PAGE_SIZE << order) {
 		int ret;
 
 		ret = get_user_pages_fast(start, 1, 0, &page);
 		if (ret != 1)
 			return ret;
 
+		/*
+		 * When soft offlining hugepages, after migrating the page
+		 * we dissolve it, therefore in the second loop "page" will
+		 * no longer be a compound page, and order will be 0.
+		 */
+		order = compound_order(compound_head(page));
+
 		if (PageHWPoison(page)) {
 			put_page(page);
 			continue;
-- 
2.14.1

--
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>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-09-13  8:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 20:43 [PATCH] mm, hugetlb, soft_offline: save compound page order before page migration Alexandru Moise
2017-09-12 20:54 ` Andrew Morton
2017-09-12 20:58   ` Andrew Morton
2017-09-12 21:12     ` Alexandru Moise
2017-09-12 21:10   ` Alexandru Moise
2017-09-13  0:13 ` Naoya Horiguchi
2017-09-13  8:32   ` Alexandru Moise

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).