Skip to contentSkip to conversation

Page host virtual assist: unused / free pages.

PATCH In review Martin Schwidefsky 4 participants 8 messages Apr 24, 2006 – Apr 25, 2006

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

PATCH 1/8 Page host virtual assist: unused / free pages.

[patch 1/8] Page host virtual assist: unused / free pages.

A very simple but already quite effective improvement in the handling of guest memory vs. host memory is to tell the host when pages are free. That allows the host to avoid the paging of guest pages without meaningful content. The host can "forget" the page content and provide a fresh frame containing zeroes instead.

To communicate the two page states "unused" and "stable" to the host two architecture defined primitives page_hva_set_unused() and page_hva_set_stable() are introduced, which are used in the page allocator.

---

 include/linux/mm.h       |    2 ++
 include/linux/page_hva.h |   28 ++++++++++++++++++++++++++++
 mm/page_alloc.c          |   14 +++++++++++---
 3 files changed, 41 insertions(+), 3 deletions(-)
include/linux/mm.h +2 -0
diff -urpN linux-2.6/include/linux/mm.h linux-2.6-patched/include/linux/mm.h
@@ -298,6 +298,8 @@ struct page {
  * routine so they can be sure the page doesn't go away from under them.
  */
 
+#include <linux/page_hva.h>
+
 /*
  * Drop a ref, return true if the logical refcount fell to zero (the page has
  * no users)
include/linux/page_hva.h +28 -0
diff -urpN linux-2.6/include/linux/page_hva.h linux-2.6-patched/include/linux/page_hva.h
@@ -0,0 +1,28 @@
+#ifndef _LINUX_PAGE_HVA_H
+#define _LINUX_PAGE_HVA_H
+
+/*
+ * include/linux/page_hva.h
+ *
+ * (C) Copyright IBM Corp. 2005, 2006
+ *
+ * Host virtual assist functions.
+ *
+ * Authors: Martin Schwidefsky <[email protected]>
+ *          Hubertus Franke <[email protected]>
+ *          Himanshu Raj <[email protected]>
+ */
+#if defined(CONFIG_PAGE_HVA)
+
+#include <asm/page_hva.h>
+
+#else
+
+#define page_hva_enabled()			(0)
+
+#define page_hva_set_unused(_page)		do { } while (0)
+#define page_hva_set_stable(_page)		do { } while (0)
+
+#endif
+
+#endif /* _LINUX_PAGE_HVA_H */
mm/page_alloc.c +11 -3
diff -urpN linux-2.6/mm/page_alloc.c linux-2.6-patched/mm/page_alloc.c
@@ -457,8 +457,13 @@ static void __free_pages_ok(struct page 
 		debug_check_no_locks_freed(page_address(page),
 					   PAGE_SIZE<<order);
 
-	for (i = 0 ; i < (1 << order) ; ++i)
-		reserved += free_pages_check(page + i);
+	for (i = 0 ; i < (1 << order) ; ++i) {
+		if (free_pages_check(page + i)) {
+			reserved++;
+			continue;
+		}
+		page_hva_set_unused(page+i);
+	}
 	if (reserved)
 		return;
 
@@ -753,6 +758,7 @@ static void fastcall free_hot_cold_page(
 		page->mapping = NULL;
 	if (free_pages_check(page))
 		return;
+	page_hva_set_unused(page);
 
 	kernel_map_pages(page, 1, 0);
 
@@ -808,7 +814,7 @@ static struct page *buffered_rmqueue(str
 	unsigned long flags;
 	struct page *page;
 	int cold = !!(gfp_flags & __GFP_COLD);
-	int cpu;
+	int cpu, i;
 
 again:
 	cpu  = get_cpu();
@@ -840,6 +846,8 @@ again:
 	put_cpu();
 
 	VM_BUG_ON(bad_range(zone, page));
+	for (i = 0 ; i < (1 << order) ; ++i)
+		page_hva_set_stable(page+i);
 	if (prep_new_page(page, order, gfp_flags))
 		goto again;
 	return 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>

#1 lore raw

include/linux/page_hva.h line 24

Quoted 2 lines · Martin Schwidefsky
include/linux/page_hva.h +2 -0
+#define page_hva_set_unused(_page)		do { } while (0)
+#define page_hva_set_stable(_page)		do { } while (0)

The whole thing seems quite under commented in the code and illnamed (if you didn't know what page_hva_set_unused() is supposed to do already would you figure it out from the name?)

-Andi

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

#2 lore raw
Quoted 8 lines · Andi Kleen

include/linux/page_hva.h line 24

Quoted 2 lines · Martin Schwidefsky
include/linux/page_hva.h +2 -0
+#define page_hva_set_unused(_page)		do { } while (0)
+#define page_hva_set_stable(_page)		do { } while (0)

The whole thing seems quite under commented in the code and illnamed (if you didn't know what page_hva_set_unused() is supposed to do already would you figure it out from the name?)

Well, we can always add comments if something is unclear. The name should give you a good hint though: page-(hva)-set-unused. You set the page to the unused state. Is the name really that confusing ?

Signature · 15 lines
blue skies,
  Martin.

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH

"Reality continues to ruin my life." - Calvin.


--
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>
#3 lore raw
Quoted 10 lines · Martin Schwidefsky
Quoted 8 lines · Andi Kleen

include/linux/page_hva.h line 24

Quoted 2 lines · Martin Schwidefsky
include/linux/page_hva.h +2 -0
+#define page_hva_set_unused(_page)		do { } while (0)
+#define page_hva_set_stable(_page)		do { } while (0)

The whole thing seems quite under commented in the code and illnamed (if you didn't know what page_hva_set_unused() is supposed to do already would you figure it out from the name?)

Quoted 3 lines

Well, we can always add comments if something is unclear. The name should give you a good hint though: page-(hva)-set-unused. You set the page to the unused state. Is the name really that confusing ?

How about page_set_free / page_set_used ?

-Andi

--
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 11 lines · Andi Kleen
Quoted 10 lines · Martin Schwidefsky
Quoted 8 lines · Andi Kleen

include/linux/page_hva.h line 24

Quoted 2 lines · Martin Schwidefsky
include/linux/page_hva.h +2 -0
+#define page_hva_set_unused(_page)		do { } while (0)
+#define page_hva_set_stable(_page)		do { } while (0)

The whole thing seems quite under commented in the code and illnamed (if you didn't know what page_hva_set_unused() is supposed to do already would you figure it out from the name?)

Quoted 5 lines
Quoted 3 lines

Well, we can always add comments if something is unclear. The name should give you a good hint though: page-(hva)-set-unused. You set the page to the unused state. Is the name really that confusing ?

How about page_set_free / page_set_used ?

Ok, sounds reasonable. Do we need to drop the _hva name component? If we do that then something like page_hva_unmap_all will be named page_unmap_all which might be a bit confusing as well.

I've noted the lack of comments in the page_hva.h header on my to-do list.

Signature · 15 lines
blue skies,
  Martin.

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH

"Reality continues to ruin my life." - Calvin.


--
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>
#5 lore raw
Quoted 3 lines · Martin Schwidefsky

Ok, sounds reasonable. Do we need to drop the _hva name component? If we do that then something like page_hva_unmap_all will be named page_unmap_all which might be a bit confusing as well.

I would drop it because it seems like a very s390 specific term.

-Andi
P.S.: I read somewhere that M$ calls such Hypervisor
hints enlightenments. Seems like a cool term to me. Maybe it can be used.

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

#6 lore raw
Quoted 11 lines · Andi Kleen
Quoted 3 lines · Martin Schwidefsky

Ok, sounds reasonable. Do we need to drop the _hva name component? If we do that then something like page_hva_unmap_all will be named page_unmap_all which might be a bit confusing as well.

I would drop it because it seems like a very s390 specific term.

-Andi

First, let's decide whether the functionality and the page states should be considered an "explicit concept" within linux like for instance the KMAP.

So residency information of the hypervisor is thus exposed in the OS. Having 3 or 4 states which seem easily understood ( unused, stable, volatile, p-volatile ) seems easy enough to us.

We can drop the _hva_ from the function calls and the name collisions we can solved differently or leave them there with _hva_ or what ever name makes sense. They don't show up in the general code path anyway.

Anybody else have a thought on this, Andrew ?

-- Hubertus

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

#7 lore raw
In reply to Martin Schwidefsky
Quoted 8 lines · Himanshu Raj

[patch 1/8] Page host virtual assist: unused / free pages.

A very simple but already quite effective improvement in the handling of guest memory vs. host memory is to tell the host when pages are free. That allows the host to avoid the paging of guest pages without meaningful content. The host can "forget" the page content and provide a fresh frame containing zeroes instead.

Quoted 6 lines

To communicate the two page states "unused" and "stable" to the host two architecture defined primitives page_hva_set_unused() and page_hva_set_stable() are introduced, which are used in the page allocator.

This seems reasonable to me. But again, there is no reason for the mm to know about this "hva" thing.

We already have arch_free_page. Can't you introduce an arch_alloc_page and use those?

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

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