70 lines
2.5 KiB
Diff
70 lines
2.5 KiB
Diff
Scanning the victims array for a free slot is expensive.
|
|
Remember the last slots freed during page-in requests and reuse them in evict_victims.
|
|
---
|
|
tools/xenpaging/xenpaging.c | 20 ++++++++++++++++++--
|
|
tools/xenpaging/xenpaging.h | 2 ++
|
|
2 files changed, 20 insertions(+), 2 deletions(-)
|
|
|
|
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
|
|
@@ -787,11 +787,23 @@ static int evict_victim(xenpaging_t *pag
|
|
}
|
|
|
|
/* Evict a batch of pages and write them to a free slot in the paging file */
|
|
-static int evict_pages(xenpaging_t *paging, int fd, xenpaging_victim_t *victims, int num_pages)
|
|
+static void evict_pages(xenpaging_t *paging, int fd, xenpaging_victim_t *victims, int num_pages)
|
|
{
|
|
xc_interface *xch = paging->xc_handle;
|
|
int rc, slot, num = 0;
|
|
|
|
+ while ( paging->stack_count > 0 && num < num_pages )
|
|
+ {
|
|
+ paging->stack_count--;
|
|
+ slot = paging->free_slot_stack[paging->stack_count];
|
|
+ rc = evict_victim(paging, &victims[slot], fd, slot);
|
|
+ if ( rc == -ENOSPC )
|
|
+ return;
|
|
+ if ( rc == -EINTR )
|
|
+ return;
|
|
+ num++;
|
|
+ }
|
|
+
|
|
for ( slot = 0; slot < paging->max_pages && num < num_pages; slot++ )
|
|
{
|
|
/* Slot is allocated */
|
|
@@ -807,7 +819,6 @@ static int evict_pages(xenpaging_t *pagi
|
|
DPRINTF("%d pages evicted\n", num);
|
|
num++;
|
|
}
|
|
- return num;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
@@ -939,6 +950,11 @@ int main(int argc, char *argv[])
|
|
|
|
/* Clear this pagefile slot */
|
|
victims[i].gfn = INVALID_MFN;
|
|
+ if ( paging->stack_count < XENPAGING_PAGEIN_QUEUE_SIZE )
|
|
+ {
|
|
+ paging->free_slot_stack[paging->stack_count] = i;
|
|
+ paging->stack_count++;
|
|
+ }
|
|
}
|
|
else
|
|
{
|
|
Index: xen-4.1.2-testing/tools/xenpaging/xenpaging.h
|
|
===================================================================
|
|
--- xen-4.1.2-testing.orig/tools/xenpaging/xenpaging.h
|
|
+++ xen-4.1.2-testing/tools/xenpaging/xenpaging.h
|
|
@@ -56,6 +56,8 @@ typedef struct xenpaging {
|
|
int policy_mru_size;
|
|
int use_poll_timeout;
|
|
int debug;
|
|
+ int stack_count;
|
|
+ int free_slot_stack[XENPAGING_PAGEIN_QUEUE_SIZE];
|
|
unsigned long pagein_queue[XENPAGING_PAGEIN_QUEUE_SIZE];
|
|
} xenpaging_t;
|
|
|