From: Olaf Hering <olaf@aepfle.de>
To: xen-devel@lists.xensource.com
Subject: [PATCH 02 of 10] xenpaging: no poll timeout while page-out is in progress
Date: Mon, 30 Jan 2012 16:59:25 +0100 [thread overview]
Message-ID: <55b2e9676a5a871833e6.1327939165@probook.site> (raw)
In-Reply-To: <patchbomb.1327939163@probook.site>
# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1327937792 -3600
# Node ID 55b2e9676a5a871833e6c57ec3b424c70f15af2b
# Parent 2d71d8bca0f15d353d28f5a42cc0c4e21002e8d5
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().
v2:
- no poll timeout also when large number of evicts is pending
Signed-off-by: Olaf Hering <olaf@aepfle.de>
diff -r 2d71d8bca0f1 -r 55b2e9676a5a tools/xenpaging/policy_default.c
--- a/tools/xenpaging/policy_default.c
+++ b/tools/xenpaging/policy_default.c
@@ -90,6 +90,7 @@ unsigned long policy_choose_victim(struc
/* 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) */
diff -r 2d71d8bca0f1 -r 55b2e9676a5a tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c
+++ b/tools/xenpaging/xenpaging.c
@@ -84,6 +84,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);
@@ -91,7 +92,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)
@@ -133,6 +136,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);
@@ -970,7 +975,10 @@ int main(int argc, char *argv[])
}
/* Limit the number of evicts to be able to process page-in requests */
if ( num > 42 )
+ {
+ paging->use_poll_timeout = 0;
num = 42;
+ }
evict_pages(paging, fd, num);
}
/* Resume some pages if target not reached */
@@ -984,6 +992,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);
diff -r 2d71d8bca0f1 -r 55b2e9676a5a tools/xenpaging/xenpaging.h
--- a/tools/xenpaging/xenpaging.h
+++ b/tools/xenpaging/xenpaging.h
@@ -55,6 +55,7 @@ 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];
};
next prev parent reply other threads:[~2012-01-30 15:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-30 15:59 [PATCH 00 of 10] tools/xenpaging: cleanups and performance improvements Olaf Hering
2012-01-30 15:59 ` [PATCH 01 of 10] xenpaging: use flat index for pagefile and page-in requests Olaf Hering
2012-01-30 15:59 ` Olaf Hering [this message]
2012-01-30 15:59 ` [PATCH 03 of 10] xenpaging: mmap guest pages read-only Olaf Hering
2012-01-30 15:59 ` [PATCH 04 of 10] xenpaging: reduce number of qemu cache flushes Olaf Hering
2012-01-30 15:59 ` [PATCH 05 of 10] xenpaging: move nominate+evict into single function Olaf Hering
2012-01-30 15:59 ` [PATCH 06 of 10] xenpaging: improve performance in policy_choose_victim Olaf Hering
2012-02-14 21:08 ` Olaf Hering
2012-02-20 17:25 ` [PATCH 06 of 10] xenpaging: improve performance in policy_choose_victim [and 1 more messages] Ian Jackson
2012-02-20 18:48 ` Olaf Hering
2012-01-30 15:59 ` [PATCH 07 of 10] xenpaging: unify error handling Olaf Hering
2012-01-30 15:59 ` [PATCH 08 of 10] xenpaging: move pagefile filedescriptor into struct xenpaging Olaf Hering
2012-01-30 15:59 ` [PATCH 09 of 10] xenpaging: move page_buffer " Olaf Hering
2012-01-30 15:59 ` [PATCH 10 of 10] xenpaging: implement stack of free slots in pagefile Olaf Hering
2012-02-09 17:57 ` [PATCH 00 of 10] tools/xenpaging: cleanups and performance improvements Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55b2e9676a5a871833e6.1327939165@probook.site \
--to=olaf@aepfle.de \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).