Skip to contentSkip to conversation

Patch "mm/hugetlb: improve locking in dissolve_free_huge_pages()" has been added to the 4.8-stable tree

PATCH [email protected] 1 participant 1 message Oct 29, 2016

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: improve locking in dissolve_free_huge_pages()

to the 4.8-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-improve-locking-in-dissolve_free_huge_pages.patch
and it can be found in the queue-4.8 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 eb03aa008561004257900983193d024e57abdd96 Mon Sep 17 00:00:00 2001

From: Gerald Schaefer <[email protected]>
Date: Fri, 7 Oct 2016 17:01:13 -0700
Subject: mm/hugetlb: improve locking in dissolve_free_huge_pages()

From: Gerald Schaefer <[email protected]>

commit eb03aa008561004257900983193d024e57abdd96 upstream.

For every pfn aligned to minimum_order, dissolve_free_huge_pages() will call dissolve_free_huge_page() which takes the hugetlb spinlock, even if the page is not huge at all or a hugepage that is in-use.

Improve this by doing the PageHuge() and page_count() checks already in dissolve_free_huge_pages() before calling dissolve_free_huge_page(). In dissolve_free_huge_page(), when holding the spinlock, those checks need to be revalidated.

---
 mm/hugetlb.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
mm/hugetlb.c +9 -3
@@ -1476,14 +1476,20 @@ out:
 int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn)
 {
 	unsigned long pfn;
+	struct page *page;
 	int rc = 0;
 
 	if (!hugepages_supported())
 		return rc;
 
-	for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order)
-		if (rc = dissolve_free_huge_page(pfn_to_page(pfn)))
-			break;
+	for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order) {
+		page = pfn_to_page(pfn);
+		if (PageHuge(page) && !page_count(page)) {
+			rc = dissolve_free_huge_page(page);
+			if (rc)
+				break;
+		}
+	}
 
 	return rc;
 }

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

queue-4.8/mm-hugetlb-improve-locking-in-dissolve_free_huge_pages.patch queue-4.8/mm-hugetlb-check-for-reserved-hugepages-during-memory-offline.patch