linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hugetlb: allow gigantic page allocation to migrate away smaller huge page
@ 2019-06-24  4:21 Pingfan Liu
  2019-06-24  5:03 ` Ira Weiny
  2019-06-24  5:16 ` Anshuman Khandual
  0 siblings, 2 replies; 6+ messages in thread
From: Pingfan Liu @ 2019-06-24  4:21 UTC (permalink / raw)
  To: linux-mm
  Cc: Pingfan Liu, Mike Kravetz, Oscar Salvador, David Hildenbrand,
	Andrew Morton, linux-kernel

The current pfn_range_valid_gigantic() rejects the pud huge page allocation
if there is a pmd huge page inside the candidate range.

But pud huge resource is more rare, which should align on 1GB on x86. It is
worth to allow migrating away pmd huge page to make room for a pud huge
page.

The same logic is applied to pgd and pud huge pages.

Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
---
 mm/hugetlb.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index ac843d3..02d1978 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1081,7 +1081,11 @@ static bool pfn_range_valid_gigantic(struct zone *z,
 			unsigned long start_pfn, unsigned long nr_pages)
 {
 	unsigned long i, end_pfn = start_pfn + nr_pages;
-	struct page *page;
+	struct page *page = pfn_to_page(start_pfn);
+
+	if (PageHuge(page))
+		if (compound_order(compound_head(page)) >= nr_pages)
+			return false;
 
 	for (i = start_pfn; i < end_pfn; i++) {
 		if (!pfn_valid(i))
@@ -1098,8 +1102,6 @@ static bool pfn_range_valid_gigantic(struct zone *z,
 		if (page_count(page) > 0)
 			return false;
 
-		if (PageHuge(page))
-			return false;
 	}
 
 	return true;
-- 
2.7.5


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

end of thread, other threads:[~2019-06-24  8:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-24  4:21 [PATCH] mm/hugetlb: allow gigantic page allocation to migrate away smaller huge page Pingfan Liu
2019-06-24  5:03 ` Ira Weiny
2019-06-24  5:55   ` Pingfan Liu
2019-06-24  5:16 ` Anshuman Khandual
2019-06-24  6:10   ` Pingfan Liu
2019-06-24  8:26     ` Anshuman Khandual

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