Skip to contentSkip to conversation

hugetlb: call arch_prepare_hugepage() for surplus pages

PATCH In review Gerald Schaefer 4 participants 5 messages Aug 5, 2008 – Aug 6, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hugetlb: call arch_prepare_hugepage() for surplus pages

The s390 software large page emulation implements shared page tables by using page->index of the first tail page from a compound large page to store page table information. This is set up in arch_prepare_hugepage(), which is called from alloc_fresh_huge_page_node().

A similar call to arch_prepare_hugepage() is missing for surplus large pages that are allocated in alloc_buddy_huge_page(), which breaks the software emulation mode for (surplus) large pages on s390. This patch adds the missing call to arch_prepare_hugepage(). It will have no effect on other architectures where arch_prepare_hugepage() is a nop.

---

 mm/hugetlb.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
mm/hugetlb.c +6 -1
Index: linux/mm/hugetlb.c
===================================================================
@@ -565,7 +565,7 @@ static struct page *alloc_fresh_huge_pag
 		huge_page_order(h));
 	if (page) {
 		if (arch_prepare_hugepage(page)) {
-			__free_pages(page, HUGETLB_PAGE_ORDER);
+			__free_pages(page, huge_page_order(h));
 			return NULL;
 		}
 		prep_new_huge_page(h, page, nid);
@@ -665,6 +665,11 @@ static struct page *alloc_buddy_huge_pag
 					__GFP_REPEAT|__GFP_NOWARN,
 					huge_page_order(h));
 
+	if (page && arch_prepare_hugepage(page)) {
+		__free_pages(page, huge_page_order(h));
+		return NULL;
+	}
+
 	spin_lock(&hugetlb_lock);
 	if (page) {
 		/*

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 1/1
#1 lore raw
Quoted 25 lines · Gerald Schaefer

From: Gerald Schaefer <[email protected]>

The s390 software large page emulation implements shared page tables by using page->index of the first tail page from a compound large page to store page table information. This is set up in arch_prepare_hugepage(), which is called from alloc_fresh_huge_page_node().

A similar call to arch_prepare_hugepage() is missing for surplus large pages that are allocated in alloc_buddy_huge_page(), which breaks the software emulation mode for (surplus) large pages on s390. This patch adds the missing call to arch_prepare_hugepage(). It will have no effect on other architectures where arch_prepare_hugepage() is a nop.

---

 mm/hugetlb.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: linux/mm/hugetlb.c
===================================================================

mm/hugetlb.c static struct page *alloc_fresh_huge_pag · line 571

Quoted 8 lines
mm/hugetlb.c +1 -1
@@ -565,7 +565,7 @@ static struct page *alloc_fresh_huge_pag
 		huge_page_order(h));
 	if (page) {
 		if (arch_prepare_hugepage(page)) {
-			__free_pages(page, HUGETLB_PAGE_ORDER);
+			__free_pages(page, huge_page_order(h));
 			return NULL;
 		}
 		prep_new_huge_page(h, page, nid);

This looks like a seperate bugfix?

mm/hugetlb.c static struct page *alloc_buddy_huge_pag · line 675

Quoted 12 lines
mm/hugetlb.c +5 -0
@@ -665,6 +665,11 @@ static struct page *alloc_buddy_huge_pag
 					__GFP_REPEAT|__GFP_NOWARN,
 					huge_page_order(h));
 
+	if (page && arch_prepare_hugepage(page)) {
+		__free_pages(page, huge_page_order(h));
+		return NULL;
+	}
+
 	spin_lock(&hugetlb_lock);
 	if (page) {
 		/*

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 1/1
#2 lore raw
In reply to Gerald Schaefer
Quoted 7 lines · Gerald Schaefer

From: Gerald Schaefer <[email protected]>

The s390 software large page emulation implements shared page tables by using page->index of the first tail page from a compound large page to store page table information. This is set up in arch_prepare_hugepage(), which is called from alloc_fresh_huge_page_node().

Quoted 8 lines

A similar call to arch_prepare_hugepage() is missing for surplus large pages that are allocated in alloc_buddy_huge_page(), which breaks the software emulation mode for (surplus) large pages on s390. This patch adds the missing call to arch_prepare_hugepage(). It will have no effect on other architectures where arch_prepare_hugepage() is a nop.

Seems fine.

Signature · 8 lines
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#3 lore raw
In reply to Gerald Schaefer
Quoted 25 lines · On Tue, 05 Aug 2008 17:29:07 +0200 Gerald Schaefer…

From: Gerald Schaefer <[email protected]>

The s390 software large page emulation implements shared page tables by using page->index of the first tail page from a compound large page to store page table information. This is set up in arch_prepare_hugepage(), which is called from alloc_fresh_huge_page_node().

A similar call to arch_prepare_hugepage() is missing for surplus large pages that are allocated in alloc_buddy_huge_page(), which breaks the software emulation mode for (surplus) large pages on s390. This patch adds the missing call to arch_prepare_hugepage(). It will have no effect on other architectures where arch_prepare_hugepage() is a nop.

---

 mm/hugetlb.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: linux/mm/hugetlb.c
===================================================================

mm/hugetlb.c static struct page *alloc_fresh_huge_pag · line 568

Quoted 5 lines
mm/hugetlb.c +1 -1
@@ -565,7 +565,7 @@ static struct page *alloc_fresh_huge_pag
 		huge_page_order(h));
 	if (page) {
 		if (arch_prepare_hugepage(page)) {
-			__free_pages(page, HUGETLB_PAGE_ORDER);
+			__free_pages(page, huge_page_order(h));

As Nick pointed out, this is an unrelated bugfix. I changelogged it. Really it should have been two patches.

Quoted 5 lines
mm/hugetlb.c +0 -0
 			return NULL;
 		}
 		prep_new_huge_page(h, page, nid);
@@ -665,6 +665,11 @@ static struct page *alloc_buddy_huge_pag
 					__GFP_REPEAT|__GFP_NOWARN,

mm/hugetlb.c static struct page *alloc_buddy_huge_pag · line 675

Quoted 10 lines
mm/hugetlb.c +5 -0
 					huge_page_order(h));
 
+	if (page && arch_prepare_hugepage(page)) {
+		__free_pages(page, huge_page_order(h));
+		return NULL;
+	}
+
 	spin_lock(&hugetlb_lock);
 	if (page) {
 		/*

afaict the second fix is needed in 2.6.26.x (but not 2.6.25.x), but this patch is not applicable to 2.6.26.x.

So if you want this fix to be backported into 2.6.26.x, please send a suitable version of it to [email protected].

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
Quoted 5 lines · Andrew Morton
Quoted 5 lines

---

 mm/hugetlb.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Quoted 13 lines

mm/hugetlb.c static struct page *alloc_fresh_huge_pag · line 568

Quoted 10 lines

Index: linux/mm/hugetlb.c
===================================================================

mm/hugetlb.c +1 -1
@@ -565,7 +565,7 @@ static struct page *alloc_fresh_huge_pag
 		huge_page_order(h));
 	if (page) {
 		if (arch_prepare_hugepage(page)) {
-			__free_pages(page, HUGETLB_PAGE_ORDER);
+			__free_pages(page, huge_page_order(h));

As Nick pointed out, this is an unrelated bugfix. I changelogged it. Really it should have been two patches.

Ok, thanks. I didn't see it as a bugfix because it doesn't make any difference on s390, and nobody else is using arch_prepare_hugepage() so far. But of course this may change, so I should have made two patches.

Quoted 5 lines

afaict the second fix is needed in 2.6.26.x (but not 2.6.25.x), but this patch is not applicable to 2.6.26.x.

So if you want this fix to be backported into 2.6.26.x, please send a suitable version of it to [email protected].

Right, this was missing from the beginning. It affects s390 only, so I'll check if we need a backport.

Thanks,
Gerald

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>