2011-12-02 21:25:29 +01:00
|
|
|
changeset: 24225:d47d1ad56366
|
|
|
|
user: Olaf Hering <olaf@aepfle.de>
|
|
|
|
date: Sun Nov 20 17:02:50 2011 +0100
|
|
|
|
files: tools/xenpaging/policy.h tools/xenpaging/policy_default.c tools/xenpaging/xenpaging.c
|
|
|
|
description:
|
2011-11-03 23:59:30 +01:00
|
|
|
xenpaging: improve policy mru list handling
|
|
|
|
|
|
|
|
Without this change it is not possible to page-out all guest pages, then
|
|
|
|
trigger a page-in for all pages, and then page-out everything once
|
|
|
|
again. All pages in the mru list can not be paged out because they
|
|
|
|
remain active in the internal bitmap of paged pages.
|
|
|
|
|
|
|
|
Use the mru list only if the number of paged-out pages is larger than
|
|
|
|
the mru list. If the number is smaller, start to clear the mru list. In
|
|
|
|
case the number of paged-out pages drops to zero the mru list and the
|
|
|
|
internal bitmap will be empty as well.
|
|
|
|
|
|
|
|
Also add a new interface for dropped pages. If a gfn was dropped there
|
|
|
|
is no need to adjust the mru list because dropping a page is not usage
|
|
|
|
of a page.
|
|
|
|
|
|
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
2011-12-02 21:25:29 +01:00
|
|
|
Committed-by: Ian Jackson <ian.jackson.citrix.com>
|
|
|
|
|
2011-11-03 23:59:30 +01:00
|
|
|
|
|
|
|
---
|
|
|
|
tools/xenpaging/policy.h | 2 ++
|
|
|
|
tools/xenpaging/policy_default.c | 27 ++++++++++++++++++++++++---
|
|
|
|
tools/xenpaging/xenpaging.c | 11 +++++++++--
|
|
|
|
3 files changed, 35 insertions(+), 5 deletions(-)
|
|
|
|
|
|
|
|
Index: xen-4.1.2-testing/tools/xenpaging/policy.h
|
|
|
|
===================================================================
|
|
|
|
--- xen-4.1.2-testing.orig/tools/xenpaging/policy.h
|
|
|
|
+++ xen-4.1.2-testing/tools/xenpaging/policy.h
|
|
|
|
@@ -32,6 +32,8 @@ int policy_init(xenpaging_t *paging);
|
|
|
|
int policy_choose_victim(xenpaging_t *paging, xenpaging_victim_t *victim);
|
|
|
|
void policy_notify_paged_out(unsigned long gfn);
|
|
|
|
void policy_notify_paged_in(unsigned long gfn);
|
|
|
|
+void policy_notify_paged_in_nomru(unsigned long gfn);
|
|
|
|
+void policy_notify_dropped(unsigned long gfn);
|
|
|
|
|
|
|
|
#endif // __XEN_PAGING_POLICY_H__
|
|
|
|
|
|
|
|
Index: xen-4.1.2-testing/tools/xenpaging/policy_default.c
|
|
|
|
===================================================================
|
|
|
|
--- xen-4.1.2-testing.orig/tools/xenpaging/policy_default.c
|
|
|
|
+++ xen-4.1.2-testing/tools/xenpaging/policy_default.c
|
|
|
|
@@ -57,7 +57,7 @@ int policy_init(xenpaging_t *paging)
|
|
|
|
if ( paging->policy_mru_size > 0 )
|
|
|
|
mru_size = paging->policy_mru_size;
|
|
|
|
else
|
|
|
|
- mru_size = DEFAULT_MRU_SIZE;
|
|
|
|
+ mru_size = paging->policy_mru_size = DEFAULT_MRU_SIZE;
|
|
|
|
|
|
|
|
mru = malloc(sizeof(*mru) * mru_size);
|
|
|
|
if ( mru == NULL )
|
|
|
|
@@ -120,17 +120,38 @@ void policy_notify_paged_out(unsigned lo
|
|
|
|
clear_bit(gfn, unconsumed);
|
|
|
|
}
|
|
|
|
|
|
|
|
-void policy_notify_paged_in(unsigned long gfn)
|
|
|
|
+static void policy_handle_paged_in(unsigned long gfn, int do_mru)
|
|
|
|
{
|
|
|
|
unsigned long old_gfn = mru[i_mru & (mru_size - 1)];
|
|
|
|
|
|
|
|
if ( old_gfn != INVALID_MFN )
|
|
|
|
clear_bit(old_gfn, bitmap);
|
|
|
|
|
|
|
|
- mru[i_mru & (mru_size - 1)] = gfn;
|
|
|
|
+ if (do_mru) {
|
|
|
|
+ mru[i_mru & (mru_size - 1)] = gfn;
|
|
|
|
+ } else {
|
|
|
|
+ clear_bit(gfn, bitmap);
|
|
|
|
+ mru[i_mru & (mru_size - 1)] = INVALID_MFN;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
i_mru++;
|
|
|
|
}
|
|
|
|
|
|
|
|
+void policy_notify_paged_in(unsigned long gfn)
|
|
|
|
+{
|
|
|
|
+ policy_handle_paged_in(gfn, 1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void policy_notify_paged_in_nomru(unsigned long gfn)
|
|
|
|
+{
|
|
|
|
+ policy_handle_paged_in(gfn, 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void policy_notify_dropped(unsigned long gfn)
|
|
|
|
+{
|
|
|
|
+ clear_bit(gfn, bitmap);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
Index: xen-4.1.2-testing/tools/xenpaging/xenpaging.c
|
|
|
|
===================================================================
|
|
|
|
--- xen-4.1.2-testing.orig/tools/xenpaging/xenpaging.c
|
|
|
|
+++ xen-4.1.2-testing/tools/xenpaging/xenpaging.c
|
2011-12-02 21:25:29 +01:00
|
|
|
@@ -615,7 +615,14 @@ static int xenpaging_resume_page(xenpagi
|
2011-11-03 23:59:30 +01:00
|
|
|
/* Notify policy of page being paged in */
|
|
|
|
if ( notify_policy )
|
|
|
|
{
|
|
|
|
- policy_notify_paged_in(rsp->gfn);
|
|
|
|
+ /*
|
|
|
|
+ * Do not add gfn to mru list if the target is lower than mru size.
|
|
|
|
+ * This allows page-out of these gfns if the target grows again.
|
|
|
|
+ */
|
|
|
|
+ if (paging->num_paged_out > paging->policy_mru_size)
|
|
|
|
+ policy_notify_paged_in(rsp->gfn);
|
|
|
|
+ else
|
|
|
|
+ policy_notify_paged_in_nomru(rsp->gfn);
|
|
|
|
|
|
|
|
/* Record number of resumed pages */
|
|
|
|
paging->num_paged_out--;
|
2011-12-02 21:25:29 +01:00
|
|
|
@@ -869,7 +876,7 @@ int main(int argc, char *argv[])
|
2011-11-03 23:59:30 +01:00
|
|
|
{
|
|
|
|
DPRINTF("drop_page ^ gfn %"PRIx64" pageslot %d\n", req.gfn, i);
|
|
|
|
/* Notify policy of page being dropped */
|
|
|
|
- policy_notify_paged_in(req.gfn);
|
|
|
|
+ policy_notify_dropped(req.gfn);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|