Skip to contentSkip to conversation

Patch "mm, hugetlb, soft_offline: save compound page order before page migration" has been added to the 4.13-stable tree

PATCH [email protected] 1 participant 1 message Oct 9, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

mm, hugetlb, soft_offline: save compound page order before page migration

to the 4.13-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mm-hugetlb-soft_offline-save-compound-page-order-before-page-migration.patch
and it can be found in the queue-4.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 19bfbe22f59a207417b2679e7e83c180419c9ec5 Mon Sep 17 00:00:00 2001

From: Alexandru Moise <[email protected]>
Date: Tue, 3 Oct 2017 16:14:31 -0700
Subject: mm, hugetlb, soft_offline: save compound page order before page migration

From: Alexandru Moise <[email protected]>

commit 19bfbe22f59a207417b2679e7e83c180419c9ec5 upstream.

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 commit c3114a84f7f9: "mm: hugetlb: soft-offline: dissolve source hugepage after successful migration").

As a result I ended up with all my free pages except one being offlined.

Fixes c3114a84f7f9 ("mm: hugetlb: soft-offline: dissolve source hugepage after successful migration")
Cc Anshuman Khandual <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Shaohua Li <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
Cc Mel Gorman <[email protected]>
Cc David Rientjes <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Naoya Horiguchi <[email protected]>
---
 mm/madvise.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
mm/madvise.c +10 -2
@@ -614,18 +614,26 @@ static int madvise_inject_error(int beha
 {
 	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;

Patches currently in stable-queue which might be from [email protected] are

queue-4.13/mm-hugetlb-soft_offline-save-compound-page-order-before-page-migration.patch