linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/8] Page host virtual assist: unused / free pages.
@ 2006-04-24 12:34 Martin Schwidefsky, Martin Schwidefsky, Hubertus Franke, Himanshu Raj
  2006-04-24 14:07 ` Andi Kleen
  2006-04-25 12:20 ` Nick Piggin
  0 siblings, 2 replies; 8+ messages in thread
From: Martin Schwidefsky, Martin Schwidefsky, Hubertus Franke, Himanshu Raj @ 2006-04-24 12:34 UTC (permalink / raw)
  To: linux-mm, akpm, frankeh, rhim

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

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 include/linux/mm.h       |    2 ++
 include/linux/page_hva.h |   28 ++++++++++++++++++++++++++++
 mm/page_alloc.c          |   14 +++++++++++---
 3 files changed, 41 insertions(+), 3 deletions(-)

diff -urpN linux-2.6/include/linux/mm.h linux-2.6-patched/include/linux/mm.h
--- linux-2.6/include/linux/mm.h	2006-04-24 12:51:20.000000000 +0200
+++ linux-2.6-patched/include/linux/mm.h	2006-04-24 12:51:24.000000000 +0200
@@ -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)
diff -urpN linux-2.6/include/linux/page_hva.h linux-2.6-patched/include/linux/page_hva.h
--- linux-2.6/include/linux/page_hva.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6-patched/include/linux/page_hva.h	2006-04-24 12:51:24.000000000 +0200
@@ -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 <schwidefsky@de.ibm.com>
+ *          Hubertus Franke <frankeh@watson.ibm.com>
+ *          Himanshu Raj <rhim@cc.gatech.edu>
+ */
+#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 */
diff -urpN linux-2.6/mm/page_alloc.c linux-2.6-patched/mm/page_alloc.c
--- linux-2.6/mm/page_alloc.c	2006-04-24 12:51:20.000000000 +0200
+++ linux-2.6-patched/mm/page_alloc.c	2006-04-24 12:51:24.000000000 +0200
@@ -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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 1/8] Page host virtual assist: unused / free pages.
  2006-04-24 12:34 [patch 1/8] Page host virtual assist: unused / free pages Martin Schwidefsky, Martin Schwidefsky, Hubertus Franke, Himanshu Raj
@ 2006-04-24 14:07 ` Andi Kleen
  2006-04-24 14:41   ` Martin Schwidefsky
  2006-04-25 12:20 ` Nick Piggin
  1 sibling, 1 reply; 8+ messages in thread
From: Andi Kleen @ 2006-04-24 14:07 UTC (permalink / raw)
  To: Martin Schwidefsky; +Cc: linux-mm, akpm, frankeh, rhim

On Monday 24 April 2006 14:34, Martin Schwidefsky wrote:

> +#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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 1/8] Page host virtual assist: unused / free pages.
  2006-04-24 14:07 ` Andi Kleen
@ 2006-04-24 14:41   ` Martin Schwidefsky
  2006-04-24 14:49     ` Andi Kleen
  0 siblings, 1 reply; 8+ messages in thread
From: Martin Schwidefsky @ 2006-04-24 14:41 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-mm, akpm, frankeh, rhim

On Mon, 2006-04-24 at 16:07 +0200, Andi Kleen wrote:
> On Monday 24 April 2006 14:34, Martin Schwidefsky wrote:
> 
> > +#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 ?

-- 
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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 1/8] Page host virtual assist: unused / free pages.
  2006-04-24 14:41   ` Martin Schwidefsky
@ 2006-04-24 14:49     ` Andi Kleen
  2006-04-24 14:59       ` Martin Schwidefsky
  0 siblings, 1 reply; 8+ messages in thread
From: Andi Kleen @ 2006-04-24 14:49 UTC (permalink / raw)
  To: schwidefsky; +Cc: linux-mm, akpm, frankeh, rhim

On Monday 24 April 2006 16:41, Martin Schwidefsky wrote:
> On Mon, 2006-04-24 at 16:07 +0200, Andi Kleen wrote:
> > On Monday 24 April 2006 14:34, Martin Schwidefsky wrote:
> > 
> > > +#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 ?

How about page_set_free / page_set_used ?

-Andi

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

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

* Re: [patch 1/8] Page host virtual assist: unused / free pages.
  2006-04-24 14:49     ` Andi Kleen
@ 2006-04-24 14:59       ` Martin Schwidefsky
  2006-04-24 15:06         ` Andi Kleen
  0 siblings, 1 reply; 8+ messages in thread
From: Martin Schwidefsky @ 2006-04-24 14:59 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-mm, akpm, frankeh, rhim

On Mon, 2006-04-24 at 16:49 +0200, Andi Kleen wrote:
> On Monday 24 April 2006 16:41, Martin Schwidefsky wrote:
> > On Mon, 2006-04-24 at 16:07 +0200, Andi Kleen wrote:
> > > On Monday 24 April 2006 14:34, Martin Schwidefsky wrote:
> > > 
> > > > +#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 ?
> 
> 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.

-- 
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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 1/8] Page host virtual assist: unused / free pages.
  2006-04-24 14:59       ` Martin Schwidefsky
@ 2006-04-24 15:06         ` Andi Kleen
  2006-04-24 15:43           ` Hubertus Franke
  0 siblings, 1 reply; 8+ messages in thread
From: Andi Kleen @ 2006-04-24 15:06 UTC (permalink / raw)
  To: schwidefsky; +Cc: linux-mm, akpm, frankeh, rhim

On Monday 24 April 2006 16:59, Martin Schwidefsky wrote:

> 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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 1/8] Page host virtual assist: unused / free pages.
  2006-04-24 15:06         ` Andi Kleen
@ 2006-04-24 15:43           ` Hubertus Franke
  0 siblings, 0 replies; 8+ messages in thread
From: Hubertus Franke @ 2006-04-24 15:43 UTC (permalink / raw)
  To: Andi Kleen; +Cc: schwidefsky, linux-mm, akpm, rhim

Andi Kleen wrote:
> On Monday 24 April 2006 16:59, Martin Schwidefsky wrote:
> 
> 
>>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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 1/8] Page host virtual assist: unused / free pages.
  2006-04-24 12:34 [patch 1/8] Page host virtual assist: unused / free pages Martin Schwidefsky, Martin Schwidefsky, Hubertus Franke, Himanshu Raj
  2006-04-24 14:07 ` Andi Kleen
@ 2006-04-25 12:20 ` Nick Piggin
  1 sibling, 0 replies; 8+ messages in thread
From: Nick Piggin @ 2006-04-25 12:20 UTC (permalink / raw)
  To: Martin Schwidefsky; +Cc: linux-mm, akpm, frankeh

Himanshu Raj wrote:
> [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.
> 
> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

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?

-- 
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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2006-04-25 12:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-24 12:34 [patch 1/8] Page host virtual assist: unused / free pages Martin Schwidefsky, Martin Schwidefsky, Hubertus Franke, Himanshu Raj
2006-04-24 14:07 ` Andi Kleen
2006-04-24 14:41   ` Martin Schwidefsky
2006-04-24 14:49     ` Andi Kleen
2006-04-24 14:59       ` Martin Schwidefsky
2006-04-24 15:06         ` Andi Kleen
2006-04-24 15:43           ` Hubertus Franke
2006-04-25 12:20 ` Nick Piggin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox