90 lines
3.5 KiB
Diff
90 lines
3.5 KiB
Diff
|
xenpaging: no poll timeout while page-out is in progress
|
||
|
|
||
|
The main loop calls xenpaging_wait_for_event_or_timeout() unconditionally
|
||
|
before doing any work. This function calls poll() with a timeout of 100ms. As
|
||
|
a result the page-out process is very slow due to the delay in poll().
|
||
|
|
||
|
Call poll() without timeout so that it returns immediately until the page-out
|
||
|
is done. Page-out is done when either the policy finds no more pages to
|
||
|
nominate or when the requested number of pages is reached.
|
||
|
|
||
|
The condition is cleared when a watch event arrives, so that processing the
|
||
|
new target is not delayed once again by poll().
|
||
|
|
||
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
||
|
|
||
|
---
|
||
|
tools/xenpaging/policy_default.c | 1 +
|
||
|
tools/xenpaging/xenpaging.c | 12 +++++++++++-
|
||
|
tools/xenpaging/xenpaging.h | 1 +
|
||
|
3 files changed, 13 insertions(+), 1 deletion(-)
|
||
|
|
||
|
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
|
||
|
@@ -90,6 +90,7 @@ int policy_choose_victim(xenpaging_t *pa
|
||
|
/* Could not nominate any gfn */
|
||
|
if ( wrap == current_gfn )
|
||
|
{
|
||
|
+ paging->use_poll_timeout = 1;
|
||
|
/* Count wrap arounds */
|
||
|
unconsumed_cleared++;
|
||
|
/* Force retry every few seconds (depends on poll() timeout) */
|
||
|
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
|
||
|
@@ -85,6 +85,7 @@ static int xenpaging_wait_for_event_or_t
|
||
|
struct pollfd fd[2];
|
||
|
int port;
|
||
|
int rc;
|
||
|
+ int timeout;
|
||
|
|
||
|
/* Wait for event channel and xenstore */
|
||
|
fd[0].fd = xc_evtchn_fd(xce);
|
||
|
@@ -92,7 +93,9 @@ static int xenpaging_wait_for_event_or_t
|
||
|
fd[1].fd = xs_fileno(paging->xs_handle);
|
||
|
fd[1].events = POLLIN | POLLERR;
|
||
|
|
||
|
- rc = poll(fd, 2, 100);
|
||
|
+ /* No timeout while page-out is still in progress */
|
||
|
+ timeout = paging->use_poll_timeout ? 100 : 0;
|
||
|
+ rc = poll(fd, 2, timeout);
|
||
|
if ( rc < 0 )
|
||
|
{
|
||
|
if (errno == EINTR)
|
||
|
@@ -134,6 +137,8 @@ static int xenpaging_wait_for_event_or_t
|
||
|
if ( target_tot_pages < 0 || target_tot_pages > paging->max_pages )
|
||
|
target_tot_pages = paging->max_pages;
|
||
|
paging->target_tot_pages = target_tot_pages;
|
||
|
+ /* Disable poll() delay while new target is not yet reached */
|
||
|
+ paging->use_poll_timeout = 0;
|
||
|
DPRINTF("new target_tot_pages %d\n", target_tot_pages);
|
||
|
}
|
||
|
free(val);
|
||
|
@@ -1002,6 +1007,11 @@ int main(int argc, char *argv[])
|
||
|
}
|
||
|
resume_pages(paging, num);
|
||
|
}
|
||
|
+ /* Now target was reached, enable poll() timeout */
|
||
|
+ else
|
||
|
+ {
|
||
|
+ paging->use_poll_timeout = 1;
|
||
|
+ }
|
||
|
|
||
|
}
|
||
|
DPRINTF("xenpaging got signal %d\n", interrupted);
|
||
|
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
|
||
|
@@ -52,6 +52,7 @@ typedef struct xenpaging {
|
||
|
int num_paged_out;
|
||
|
int target_tot_pages;
|
||
|
int policy_mru_size;
|
||
|
+ int use_poll_timeout;
|
||
|
int debug;
|
||
|
unsigned long pagein_queue[XENPAGING_PAGEIN_QUEUE_SIZE];
|
||
|
} xenpaging_t;
|