From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Hering Subject: [PATCH] tools/libxc: send page-in requests in batches in linux_privcmd_map_foreign_bulk Date: Thu, 26 Jan 2012 15:51:02 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User Olaf Hering # Date 1327589312 -3600 # Node ID bace47d7623cb92d5b080c54d3850642b8c52b46 # Parent a87cbe503fed9e15d90d0bf6645d835331ec8874 tools/libxc: send page-in requests in batches in linux_privcmd_map_foreign_bulk One of the bottlenecks with foreign page-in request is the poor retry handling in linux_privcmd_map_foreign_bulk(). It sends one request per paged gfn at a time and it waits until the gfn is accessible. This causes long delays in mmap requests from qemu-dm and xc_save. Instead of sending one request at a time, walk the entire gfn list and send batches of mmap requests. They will eventually end up in the pagers request ring (if it has room again), and will fill up this ring so that in turn the pager can also process page-in in batches. Signed-off-by: Olaf Hering diff -r a87cbe503fed -r bace47d7623c tools/libxc/xc_linux_osdep.c --- a/tools/libxc/xc_linux_osdep.c +++ b/tools/libxc/xc_linux_osdep.c @@ -191,6 +191,59 @@ static void *linux_privcmd_map_foreign_b return addr; } +/* + * Retry mmap of paged gfns in batches + * retuns < 0 on fatal error + * returns 0 if all gfns left paging state + * returns > 0 if some gfns are still in paging state + * + * Walk all gfns are assemble blocks of gfns in paging state. + * This will keep the request ring full and avoids delays. + */ +static int retry_paged(int fd, uint32_t dom, void *addr, + const xen_pfn_t *arr, int *err, unsigned int num) +{ + privcmd_mmapbatch_v2_t ioctlx; + int rc, paged = 0, i = 0; + + do + { + /* Skip gfns not in paging state */ + if ( err[i] != -ENOENT ) + { + i++; + continue; + } + + paged++; + + /* At least one gfn is still in paging state */ + ioctlx.num = 1; + ioctlx.dom = dom; + ioctlx.addr = (unsigned long)addr + ((unsigned long)i< 0 ); } /* Command was not recognized, use fall back */ else if ( rc < 0 && errno == EINVAL && (int)num > 0 )