xen/xenpaging.no_domain_id.patch

185 lines
6.5 KiB
Diff
Raw Normal View History

Subject: xenpaging: remove domain_id and mfn from struct xenpaging_victim
Remove unused mfn member from struct xenpaging_victim.
Remove domain_id from struct xenpaging_victim and use the one from
paging->mem_event where needed. Its not used in the policy.
This saves 4MB runtime data with a 1GB pagefile.
(xen-unstable changeset: 22699:f84ae053b7da)
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
tools/xenpaging/policy.h | 7 +++----
tools/xenpaging/policy_default.c | 10 +++-------
tools/xenpaging/xenpaging.c | 21 ++++++++++-----------
tools/xenpaging/xenpaging.h | 4 ----
4 files changed, 16 insertions(+), 26 deletions(-)
Index: xen-4.0.2-testing/tools/xenpaging/policy.h
===================================================================
--- xen-4.0.2-testing.orig/tools/xenpaging/policy.h
+++ xen-4.0.2-testing/tools/xenpaging/policy.h
@@ -29,10 +29,9 @@
int policy_init(xenpaging_t *paging);
-int policy_choose_victim(xenpaging_t *paging, domid_t domain_id,
- xenpaging_victim_t *victim);
-void policy_notify_paged_out(domid_t domain_id, unsigned long gfn);
-void policy_notify_paged_in(domid_t domain_id, unsigned long gfn);
+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);
#endif // __XEN_PAGING_POLICY_H__
Index: xen-4.0.2-testing/tools/xenpaging/policy_default.c
===================================================================
--- xen-4.0.2-testing.orig/tools/xenpaging/policy_default.c
+++ xen-4.0.2-testing/tools/xenpaging/policy_default.c
@@ -68,15 +68,11 @@ int policy_init(xenpaging_t *paging)
return rc;
}
-int policy_choose_victim(xenpaging_t *paging, domid_t domain_id,
- xenpaging_victim_t *victim)
+int policy_choose_victim(xenpaging_t *paging, xenpaging_victim_t *victim)
{
unsigned long wrap = current_gfn;
ASSERT(victim != NULL);
- /* Domain to pick on */
- victim->domain_id = domain_id;
-
do
{
current_gfn++;
@@ -96,13 +92,13 @@ int policy_choose_victim(xenpaging_t *pa
return 0;
}
-void policy_notify_paged_out(domid_t domain_id, unsigned long gfn)
+void policy_notify_paged_out(unsigned long gfn)
{
set_bit(gfn, bitmap);
clear_bit(gfn, unconsumed);
}
-void policy_notify_paged_in(domid_t domain_id, unsigned long gfn)
+void policy_notify_paged_in(unsigned long gfn)
{
unsigned long old_gfn = mru[i_mru & (MRU_SIZE - 1)];
Index: xen-4.0.2-testing/tools/xenpaging/xenpaging.c
===================================================================
--- xen-4.0.2-testing.orig/tools/xenpaging/xenpaging.c
+++ xen-4.0.2-testing/tools/xenpaging/xenpaging.c
@@ -344,7 +344,7 @@ int xenpaging_evict_page(xenpaging_t *pa
/* Map page */
gfn = victim->gfn;
ret = -EFAULT;
- page = xc_map_foreign_pages(paging->xc_handle, victim->domain_id,
+ page = xc_map_foreign_pages(paging->xc_handle, paging->mem_event.domain_id,
PROT_READ | PROT_WRITE, &gfn, 1);
if ( page == NULL )
{
@@ -376,7 +376,7 @@ int xenpaging_evict_page(xenpaging_t *pa
}
/* Notify policy of page being paged out */
- policy_notify_paged_out(paging->mem_event.domain_id, victim->gfn);
+ policy_notify_paged_out(victim->gfn);
out:
return ret;
@@ -393,7 +393,7 @@ static int xenpaging_resume_page(xenpagi
/* Notify policy of page being paged in */
if ( notify_policy )
- policy_notify_paged_in(paging->mem_event.domain_id, rsp->gfn);
+ policy_notify_paged_in(rsp->gfn);
/* Tell Xen page is ready */
ret = xc_mem_paging_resume(paging->xc_handle, paging->mem_event.domain_id,
@@ -459,7 +459,7 @@ static int xenpaging_populate_page(
return ret;
}
-static int evict_victim(xenpaging_t *paging, domid_t domain_id,
+static int evict_victim(xenpaging_t *paging,
xenpaging_victim_t *victim, int fd, int i)
{
int j = 0;
@@ -467,7 +467,7 @@ static int evict_victim(xenpaging_t *pag
do
{
- ret = policy_choose_victim(paging, domain_id, victim);
+ ret = policy_choose_victim(paging, victim);
if ( ret != 0 )
{
if ( ret != -ENOSPC )
@@ -487,7 +487,7 @@ static int evict_victim(xenpaging_t *pag
else
{
if ( j++ % 1000 == 0 )
- if ( xc_mem_paging_flush_ioemu_cache(domain_id) )
+ if ( xc_mem_paging_flush_ioemu_cache(paging->mem_event.domain_id) )
ERROR("Error flushing ioemu cache");
}
}
@@ -570,7 +570,7 @@ int main(int argc, char *argv[])
memset(victims, 0, sizeof(xenpaging_victim_t) * num_pages);
for ( i = 0; i < num_pages; i++ )
{
- rc = evict_victim(paging, domain_id, &victims[i], fd, i);
+ rc = evict_victim(paging, &victims[i], fd, i);
if ( rc == -ENOSPC )
break;
if ( rc == -EINTR )
@@ -611,8 +611,7 @@ int main(int argc, char *argv[])
/* Find where in the paging file to read from */
for ( i = 0; i < num_pages; i++ )
{
- if ( (victims[i].domain_id == paging->mem_event.domain_id) &&
- (victims[i].gfn == req.gfn) )
+ if ( victims[i].gfn == req.gfn )
break;
}
@@ -625,6 +624,7 @@ int main(int argc, char *argv[])
if ( req.flags & MEM_EVENT_FLAG_DROP_PAGE )
{
DPRINTF("Dropping page %"PRIx64" p2mt %x\n", req.gfn, req.p2mt);
+ policy_notify_paged_out(req.gfn);
}
else
{
@@ -651,7 +651,7 @@ int main(int argc, char *argv[])
}
/* Evict a new page to replace the one we just paged in */
- evict_victim(paging, domain_id, &victims[i], fd, i);
+ evict_victim(paging, &victims[i], fd, i);
}
else
{
Index: xen-4.0.2-testing/tools/xenpaging/xenpaging.h
===================================================================
--- xen-4.0.2-testing.orig/tools/xenpaging/xenpaging.h
+++ xen-4.0.2-testing/tools/xenpaging/xenpaging.h
@@ -49,12 +49,8 @@ typedef struct xenpaging {
typedef struct xenpaging_victim {
- /* the domain to evict a page from */
- domid_t domain_id;
/* the gfn of the page to evict */
unsigned long gfn;
- /* the mfn of evicted page */
- unsigned long mfn;
} xenpaging_victim_t;