Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 00 of 22] xenpaging and libxc fixes for xen-unstable
The following series of changes for xenpaging and libxc obsoletes the series I sent on 2011-06-07. As suggested by Ian Campell, the xc.c in xenpaging directory was removed. While working on that I merged the various bitop code into a single header, see patch 2 of this series. The change to watch for guest shutdown was merged into the new xenpaging_wait_for_event_or_timeout() function. Please review and apply. Olaf [PATCH 01] xenpaging: remove unused spinlock in pager [PATCH 02] tools: merge several bitop functions into xc_bitops.h [PATCH 03] xenpaging: add xs_handle to struct xenpaging [PATCH 04] xenpaging: drop xc.c, remove ASSERT [PATCH 05] xenpaging: drop xc.c, remove xc_platform_info_t [PATCH 06] xenpaging: drop xc.c, remove xc_wait_for_event [PATCH 07] xenpaging: drop xc.c, move xc_mem_paging_flush_ioemu_cache [PATCH 08] xenpaging: drop xc.c, move xc_wait_for_event_or_timeout [PATCH 09] xenpaging: drop xc.c, remove xc files [PATCH 10] xenpaging: correct dropping of pages to avoid full ring buffer [PATCH 11] xenpaging: do not bounce p2mt to xenpaging [PATCH 12] xenpaging: remove srand call [PATCH 13] xenpaging: remove return values from functions that can not fail [PATCH 14] xenpaging: catch xc_mem_paging_resume errors [PATCH 15] xenpaging: remove local domain_id variable [PATCH 16] xenpaging: move num_pages into xenpaging struct [PATCH 17] xenpaging: start paging in the middle of gfn range [PATCH 18] xenpaging: pass integer to xenpaging_populate_page [PATCH 19] xenpaging: add helper function for unlinking pagefile [PATCH 20] xenpaging: add watch thread to catch guest shutdown [PATCH 21] xenpaging: implement stopping of pager by sending SIGTERM/SIGINT [PATCH 22] xenpaging: remove private mem_event.h tools/blktap2/drivers/block-log.c | 29 -- tools/libxc/ia64/xc_ia64_linux_restore.c | 14 tools/libxc/ia64/xc_ia64_linux_save.c | 29 -- tools/libxc/ia64/xc_ia64_save_restore.h | 20 - tools/libxc/xc_bitops.h | 57 +++ tools/libxc/xc_domain_save.c | 66 ---- tools/xenpaging/Makefile | 3 tools/xenpaging/bitops.h | 448 ------------------------------- tools/xenpaging/mem_event.h | 63 ---- tools/xenpaging/pagein.c | 68 ++++ tools/xenpaging/policy_default.c | 25 - tools/xenpaging/spinlock.h | 69 ---- tools/xenpaging/xc.c | 133 --------- tools/xenpaging/xc.h | 74 ----- tools/xenpaging/xenpaging.c | 310 +++++++++++++-------- tools/xenpaging/xenpaging.h | 20 - xen/arch/x86/mm/p2m.c | 1 17 files changed, 372 insertions(+), 1057 deletions(-) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 01 of 22] xenpaging: remove unused spinlock in pager
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695622 -7200 # Node ID 5553bd24a3d950d7d1388a95fd9a69b215cd798a # Parent 2ef6bbee50371e1135236035ed1a9a7b8748e09f xenpaging: remove unused spinlock in pager The spinlock code in the pager is a no-op because xenpaging is a single threaded application. There is no locking when put_response() places a response into the ringbuffer. The only locking is inside the hypervisor, where mem_event_put_request() and mem_event_get_response() lock the ringbuffer to protect multiple vcpus from each other. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 2ef6bbee5037 -r 5553bd24a3d9 tools/xenpaging/mem_event.h --- a/tools/xenpaging/mem_event.h Fri Jun 10 08:32:47 2011 +0100 +++ b/tools/xenpaging/mem_event.h Fri Jun 10 10:47:02 2011 +0200 @@ -25,7 +25,6 @@ #define __XEN_MEM_EVENT_H__ -#include "spinlock.h" #include "xc.h" #include <xc_private.h> @@ -33,9 +32,6 @@ #include <xen/mem_event.h> -#define mem_event_ring_lock_init(_m) spin_lock_init(&(_m)->ring_lock) -#define mem_event_ring_lock(_m) spin_lock(&(_m)->ring_lock) -#define mem_event_ring_unlock(_m) spin_unlock(&(_m)->ring_lock) typedef struct mem_event { @@ -45,7 +41,6 @@ typedef struct mem_event { mem_event_back_ring_t back_ring; mem_event_shared_page_t *shared_page; void *ring_page; - spinlock_t ring_lock; } mem_event_t; diff -r 2ef6bbee5037 -r 5553bd24a3d9 tools/xenpaging/spinlock.h --- a/tools/xenpaging/spinlock.h Fri Jun 10 08:32:47 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/****************************************************************************** - * tools/xenpaging/spinlock.h - * - * Spinlock implementation. - * - * Copyright (c) 2009 Citrix Systems, Inc. (Patrick Colp) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef __SPINLOCK_H__ -#define __SPINLOCK_H__ - - -#include "bitops.h" - - -#define SPIN_LOCK_UNLOCKED 0 - - -typedef int spinlock_t; - - -static inline void spin_lock(spinlock_t *lock) -{ - while ( test_and_set_bit(1, lock) ); -} - -static inline void spin_lock_init(spinlock_t *lock) -{ - *lock = SPIN_LOCK_UNLOCKED; -} - -static inline void spin_unlock(spinlock_t *lock) -{ - *lock = SPIN_LOCK_UNLOCKED; -} - -static inline int spin_trylock(spinlock_t *lock) -{ - return !test_and_set_bit(1, lock); -} - - -#endif // __SPINLOCK_H__ - - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff -r 2ef6bbee5037 -r 5553bd24a3d9 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 08:32:47 2011 +0100 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:02 2011 +0200 @@ -32,7 +32,6 @@ #include <xen/mem_event.h> #include "bitops.h" -#include "spinlock.h" #include "file_ops.h" #include "xc.h" @@ -127,9 +126,6 @@ static xenpaging_t *xenpaging_init(domid BACK_RING_INIT(&paging->mem_event.back_ring, (mem_event_sring_t *)paging->mem_event.ring_page, PAGE_SIZE); - - /* Initialise lock */ - mem_event_ring_lock_init(&paging->mem_event); /* Initialise Xen */ rc = xc_mem_event_enable(xch, paging->mem_event.domain_id, @@ -302,8 +298,6 @@ static int get_request(mem_event_t *mem_ mem_event_back_ring_t *back_ring; RING_IDX req_cons; - mem_event_ring_lock(mem_event); - back_ring = &mem_event->back_ring; req_cons = back_ring->req_cons; @@ -315,8 +309,6 @@ static int get_request(mem_event_t *mem_ back_ring->req_cons = req_cons; back_ring->sring->req_event = req_cons + 1; - mem_event_ring_unlock(mem_event); - return 0; } @@ -325,8 +317,6 @@ static int put_response(mem_event_t *mem mem_event_back_ring_t *back_ring; RING_IDX rsp_prod; - mem_event_ring_lock(mem_event); - back_ring = &mem_event->back_ring; rsp_prod = back_ring->rsp_prod_pvt; @@ -338,8 +328,6 @@ static int put_response(mem_event_t *mem back_ring->rsp_prod_pvt = rsp_prod; RING_PUSH_RESPONSES(back_ring); - mem_event_ring_unlock(mem_event); - return 0; } diff -r 2ef6bbee5037 -r 5553bd24a3d9 tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Fri Jun 10 08:32:47 2011 +0100 +++ b/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:02 2011 +0200 @@ -25,7 +25,6 @@ #define __XEN_PAGING2_H__ -#include "spinlock.h" #include "xc.h" #include <xc_private.h> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695623 -7200 # Node ID 9476d85932e5eb8f1e7ce0a6814b6c0634341e61 # Parent 5553bd24a3d950d7d1388a95fd9a69b215cd798a tools: merge several bitop functions into xc_bitops.h Bitmaps are used in save/restore, xenpaging and blktap2. Merge the code into a private xc_bitops.h file. All users are single threaded, so locking is not an issue. The array of bits is handled as volatile because the x86 save/restore code passes the bitmap to the hypervisor which in turn modifies the bitmap. blktap2 uses a private bitmap. There was a possible overflow in the bitmap_size() function, the remainder was not considered. ia64 save/restore uses a bitmap to send the number of vcpus to the host. x86 save/restore uses a bitmap to track dirty pages. This bitmap is shared with the hypervisor. An unused function count_bits() was removed and a new bitmap_size() function is now used. xenpaging uses 3 private bitmaps to track the gfns which are in paged-out state. It had a copy of some Linux bitops.h, which is now obsolete. Also the BITS_PER_LONG macro was hardcoded to 64 which made it impossible to run 32bit tools on a 64bit host. Wether this works at all has to be tested, yet. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 5553bd24a3d9 -r 9476d85932e5 tools/blktap2/drivers/block-log.c --- a/tools/blktap2/drivers/block-log.c Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/blktap2/drivers/block-log.c Fri Jun 10 10:47:03 2011 +0200 @@ -47,6 +47,7 @@ #include <sys/socket.h> #include <sys/un.h> +#include "xc_bitops.h" #include "log.h" #include "tapdisk.h" #include "tapdisk-server.h" @@ -89,31 +90,6 @@ static void ctl_request(event_id_t, char /* large flat bitmaps don''t scale particularly well either in size or scan * time, but they''ll do for now */ -#define BITS_PER_LONG (sizeof(unsigned long) * 8) -#define BITS_TO_LONGS(bits) (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) - -#define BITMAP_ENTRY(_nr, _bmap) ((unsigned long*)(_bmap))[(_nr)/BITS_PER_LONG] -#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG) - -static inline int test_bit(int nr, void* bmap) -{ - return (BITMAP_ENTRY(nr, bmap) >> BITMAP_SHIFT(nr)) & 1; -} - -static inline void clear_bit(int nr, void* bmap) -{ - BITMAP_ENTRY(nr, bmap) &= ~(1UL << BITMAP_SHIFT(nr)); -} - -static inline void set_bit(int nr, void* bmap) -{ - BITMAP_ENTRY(nr, bmap) |= (1UL << BITMAP_SHIFT(nr)); -} - -static inline int bitmap_size(uint64_t sz) -{ - return sz >> 3; -} static int writelog_create(struct tdlog_state *s) { @@ -123,7 +99,8 @@ static int writelog_create(struct tdlog_ BDPRINTF("allocating %"PRIu64" bytes for dirty bitmap", bmsize); - if (!(s->writelog = calloc(bmsize, 1))) { + s->writelog = bitmap_alloc(s->size); + if (!s->writelog) { BWPRINTF("could not allocate dirty bitmap of size %"PRIu64, bmsize); return -1; } diff -r 5553bd24a3d9 -r 9476d85932e5 tools/libxc/ia64/xc_ia64_linux_restore.c --- a/tools/libxc/ia64/xc_ia64_linux_restore.c Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c Fri Jun 10 10:47:03 2011 +0200 @@ -218,14 +218,12 @@ xc_ia64_recv_vcpumap(xc_interface *xch, max_virt_cpus, info->max_vcpu_id); return -1; } - vcpumap_size = (max_virt_cpus + 1 + sizeof(vcpumap[0]) - 1) / - sizeof(vcpumap[0]); - vcpumap = malloc(vcpumap_size); - if (vcpumap == NULL) { + vcpumap_size = bitmap_size(max_virt_cpus); + rc = bitmap_alloc(&vcpumap, max_virt_cpus); + if (rc < 0) { ERROR("memory alloc for vcpumap"); - return -1; + return rc; } - memset(vcpumap, 0, vcpumap_size); if (read_exact(io_fd, vcpumap, vcpumap_size)) { ERROR("read vcpumap"); free(vcpumap); @@ -353,7 +351,7 @@ xc_ia64_pv_recv_context_ver_three(xc_int /* vcpu context */ for (i = 0; i <= info.max_vcpu_id; i++) { - if (!__test_bit(i, vcpumap)) + if (!test_bit(i, vcpumap)) continue; rc = xc_ia64_pv_recv_vcpu_context(xch, io_fd, dom, i); @@ -454,7 +452,7 @@ xc_ia64_hvm_recv_context(xc_interface *x /* A copy of the CPU context of the guest. */ vcpu_guest_context_any_t ctxt_any; - if (!__test_bit(i, vcpumap)) + if (!test_bit(i, vcpumap)) continue; if (xc_ia64_recv_vcpu_context(xch, io_fd, dom, i, &ctxt_any)) diff -r 5553bd24a3d9 -r 9476d85932e5 tools/libxc/ia64/xc_ia64_linux_save.c --- a/tools/libxc/ia64/xc_ia64_linux_save.c Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/libxc/ia64/xc_ia64_linux_save.c Fri Jun 10 10:47:03 2011 +0200 @@ -32,6 +32,7 @@ #include <sys/time.h> #include "xg_private.h" +#include "xc_bitops.h" #include "xc_ia64.h" #include "xc_ia64_save_restore.h" #include "xc_efi.h" @@ -51,20 +52,6 @@ ** During (live) save/migrate, we maintain a number of bitmaps to track ** which pages we have to send, and to skip. */ -static inline int test_bit(int nr, volatile void * addr) -{ - return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1; -} - -static inline void clear_bit(int nr, volatile void * addr) -{ - BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr)); -} - -static inline void set_bit(int nr, volatile void * addr) -{ - BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr)); -} static int suspend_and_state(int (*suspend)(void*), void* data, @@ -207,19 +194,17 @@ xc_ia64_send_vcpumap(xc_interface *xch, unsigned long vcpumap_size; uint64_t *vcpumap = NULL; - vcpumap_size = (max_virt_cpus + 1 + sizeof(vcpumap[0]) - 1) / - sizeof(vcpumap[0]); - vcpumap = malloc(vcpumap_size); - if (vcpumap == NULL) { + vcpumap_size = bitmap_size(max_virt_cpus); + rc = bitmap_alloc(&vcpumap, max_virt_cpus); + if (rc < 0) { ERROR("memory alloc for vcpumap"); goto out; } - memset(vcpumap, 0, vcpumap_size); for (i = 0; i <= info->max_vcpu_id; i++) { xc_vcpuinfo_t vinfo; if ((xc_vcpu_getinfo(xch, dom, i, &vinfo) == 0) && vinfo.online) - __set_bit(i, vcpumap); + set_bit(i, vcpumap); } if (write_exact(io_fd, &max_virt_cpus, sizeof(max_virt_cpus))) { @@ -265,7 +250,7 @@ xc_ia64_pv_send_context(xc_interface *xc char *mem; - if (!__test_bit(i, vcpumap)) + if (!test_bit(i, vcpumap)) continue; if (xc_ia64_send_vcpu_context(xch, io_fd, dom, i, &ctxt_any)) @@ -332,7 +317,7 @@ xc_ia64_hvm_send_context(xc_interface *x /* A copy of the CPU context of the guest. */ vcpu_guest_context_any_t ctxt_any; - if (!__test_bit(i, vcpumap)) + if (!test_bit(i, vcpumap)) continue; if (xc_ia64_send_vcpu_context(xch, io_fd, dom, i, &ctxt_any)) diff -r 5553bd24a3d9 -r 9476d85932e5 tools/libxc/ia64/xc_ia64_save_restore.h --- a/tools/libxc/ia64/xc_ia64_save_restore.h Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/libxc/ia64/xc_ia64_save_restore.h Fri Jun 10 10:47:03 2011 +0200 @@ -33,26 +33,6 @@ #define XC_IA64_SR_FORMAT_VER_CURRENT XC_IA64_SR_FORMAT_VER_THREE -/* -** During (live) save/migrate, we maintain a number of bitmaps to track -** which pages we have to send, and to skip. -*/ -#define BITS_PER_LONG (sizeof(unsigned long) * 8) - -#define BITMAP_ENTRY(_nr,_bmap) \ - ((unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG] - -#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG) - -static inline int __test_bit(int nr, void * addr) -{ - return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1; -} - -static inline void __set_bit(int nr, void * addr) -{ - BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr)); -} #endif /* XC_IA64_SAVE_RESTORE_H */ diff -r 5553bd24a3d9 -r 9476d85932e5 tools/libxc/xc_bitops.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxc/xc_bitops.h Fri Jun 10 10:47:03 2011 +0200 @@ -0,0 +1,57 @@ +#ifndef XC_BITOPS_H +#define XC_BITOPS_H 1 + +/* bitmap operations for single threaded access */ + +#include <stdlib.h> + +#define BITS_PER_LONG (sizeof(unsigned long) * 8) +#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6) + +#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG] +#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG) + +/* calculate required space for number of longs needed to hold nr_bits */ +static inline int bitmap_size(int nr_bits) +{ + int nr_long, nr_bytes; + nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG; + nr_bytes = nr_long * sizeof(unsigned long); + return nr_bytes; +} + +static inline unsigned long *bitmap_alloc(int nr_bits) +{ + return calloc(1, bitmap_size(nr_bits)); +} + +static inline int test_bit(int nr, volatile unsigned long *addr) +{ + return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1; +} + +static inline void clear_bit(int nr, volatile unsigned long *addr) +{ + BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr)); +} + +static inline void set_bit(int nr, volatile unsigned long *addr) +{ + BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr)); +} + +static inline int test_and_clear_bit(int nr, volatile unsigned long *addr) +{ + int oldbit = test_bit(nr, addr); + clear_bit(nr, addr); + return oldbit; +} + +static inline int test_and_set_bit(int nr, volatile unsigned long *addr) +{ + int oldbit = test_bit(nr, addr); + set_bit(nr, addr); + return oldbit; +} + +#endif /* XC_BITOPS_H */ diff -r 5553bd24a3d9 -r 9476d85932e5 tools/libxc/xc_domain_save.c --- a/tools/libxc/xc_domain_save.c Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/libxc/xc_domain_save.c Fri Jun 10 10:47:03 2011 +0200 @@ -27,6 +27,7 @@ #include <sys/time.h> #include "xc_private.h" +#include "xc_bitops.h" #include "xc_dom.h" #include "xg_private.h" #include "xg_save_restore.h" @@ -88,57 +89,6 @@ struct outbuf { #define SUPER_PAGE_START(pfn) (((pfn) & (SUPERPAGE_NR_PFNS-1)) == 0 ) -/* -** During (live) save/migrate, we maintain a number of bitmaps to track -** which pages we have to send, to fixup, and to skip. -*/ - -#define BITS_PER_LONG (sizeof(unsigned long) * 8) -#define BITS_TO_LONGS(bits) (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) -#define BITMAP_SIZE (BITS_TO_LONGS(dinfo->p2m_size) * sizeof(unsigned long)) - -#define BITMAP_ENTRY(_nr,_bmap) \ - ((volatile unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG] - -#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG) - -#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6) - -static inline int test_bit (int nr, volatile void * addr) -{ - return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1; -} - -static inline void clear_bit (int nr, volatile void * addr) -{ - BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr)); -} - -static inline void set_bit ( int nr, volatile void * addr) -{ - BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr)); -} - -/* Returns the hamming weight (i.e. the number of bits set) in a N-bit word */ -static inline unsigned int hweight32(unsigned int w) -{ - unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555); - res = (res & 0x33333333) + ((res >> 2) & 0x33333333); - res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F); - res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF); - return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF); -} - -static inline int count_bits ( int nr, volatile void *addr) -{ - int i, count = 0; - volatile unsigned long *p = (volatile unsigned long *)addr; - /* We know that the array is padded to unsigned long. */ - for ( i = 0; i < (nr / (sizeof(unsigned long)*8)); i++, p++ ) - count += hweight32(*p); - return count; -} - static uint64_t tv_to_us(struct timeval *new) { return (new->tv_sec * 1000000) + new->tv_usec; @@ -974,9 +924,9 @@ int xc_domain_save(xc_interface *xch, in sent_last_iter = dinfo->p2m_size; /* Setup to_send / to_fix and to_skip bitmaps */ - to_send = xc_hypercall_buffer_alloc_pages(xch, to_send, NRPAGES(BITMAP_SIZE)); - to_skip = xc_hypercall_buffer_alloc_pages(xch, to_skip, NRPAGES(BITMAP_SIZE)); - to_fix = calloc(1, BITMAP_SIZE); + to_send = xc_hypercall_buffer_alloc_pages(xch, to_send, NRPAGES(bitmap_size(dinfo->p2m_size))); + to_skip = xc_hypercall_buffer_alloc_pages(xch, to_skip, NRPAGES(bitmap_size(dinfo->p2m_size))); + to_fix = calloc(1, bitmap_size(dinfo->p2m_size)); if ( !to_send || !to_fix || !to_skip ) { @@ -984,7 +934,7 @@ int xc_domain_save(xc_interface *xch, in goto out; } - memset(to_send, 0xff, BITMAP_SIZE); + memset(to_send, 0xff, bitmap_size(dinfo->p2m_size)); if ( hvm ) { @@ -1407,7 +1357,7 @@ int xc_domain_save(xc_interface *xch, in if ( last_iter && debug ) { int id = XC_SAVE_ID_ENABLE_VERIFY_MODE; - memset(to_send, 0xff, BITMAP_SIZE); + memset(to_send, 0xff, bitmap_size(dinfo->p2m_size)); debug = 0; DPRINTF("Entering debug resend-all mode\n"); @@ -1875,8 +1825,8 @@ int xc_domain_save(xc_interface *xch, in if ( ctx->live_m2p ) munmap(ctx->live_m2p, M2P_SIZE(ctx->max_mfn)); - xc_hypercall_buffer_free_pages(xch, to_send, NRPAGES(BITMAP_SIZE)); - xc_hypercall_buffer_free_pages(xch, to_skip, NRPAGES(BITMAP_SIZE)); + xc_hypercall_buffer_free_pages(xch, to_send, NRPAGES(bitmap_size(dinfo->p2m_size))); + xc_hypercall_buffer_free_pages(xch, to_skip, NRPAGES(bitmap_size(dinfo->p2m_size))); free(pfn_type); free(pfn_batch); diff -r 5553bd24a3d9 -r 9476d85932e5 tools/xenpaging/bitops.h --- a/tools/xenpaging/bitops.h Fri Jun 10 10:47:02 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,448 +0,0 @@ -#ifndef _X86_BITOPS_H -#define _X86_BITOPS_H - -/* - * Copyright 1992, Linus Torvalds. - */ - -//#include <xen/config.h> - -#ifdef CONFIG_SMP -#define LOCK_PREFIX "lock ; " -#else -#define LOCK_PREFIX "" -#endif - -/* - * We specify the memory operand as both input and output because the memory - * operand is both read from and written to. Since the operand is in fact a - * word array, we also specify "memory" in the clobbers list to indicate that - * words other than the one directly addressed by the memory operand may be - * modified. We don''t use "+m" because the gcc manual says that it should be - * used only when the constraint allows the operand to reside in a register. - */ - -#define ADDR (*(volatile long *) addr) -#define CONST_ADDR (*(const volatile long *) addr) - -extern void __bitop_bad_size(void); -#define bitop_bad_size(addr) (sizeof(*(addr)) < 4) - -/** - * set_bit - Atomically set a bit in memory - * @nr: the bit to set - * @addr: the address to start counting from - * - * This function is atomic and may not be reordered. See __set_bit() - * if you do not require the atomic guarantees. - * Note that @nr may be almost arbitrarily large; this function is not - * restricted to acting on a single-word quantity. - */ -static inline void set_bit(int nr, volatile void *addr) -{ - asm volatile ( - LOCK_PREFIX - "btsl %1,%0" - : "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); -} -#define set_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - set_bit(nr, addr); \ -}) - -/** - * __set_bit - Set a bit in memory - * @nr: the bit to set - * @addr: the address to start counting from - * - * Unlike set_bit(), this function is non-atomic and may be reordered. - * If it''s called on the same region of memory simultaneously, the effect - * may be that only one operation succeeds. - */ -static inline void __set_bit(int nr, volatile void *addr) -{ - asm volatile ( - "btsl %1,%0" - : "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); -} -#define __set_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - __set_bit(nr, addr); \ -}) - -/** - * clear_bit - Clears a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - * - * clear_bit() is atomic and may not be reordered. However, it does - * not contain a memory barrier, so if it is used for locking purposes, - * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() - * in order to ensure changes are visible on other processors. - */ -static inline void clear_bit(int nr, volatile void *addr) -{ - asm volatile ( - LOCK_PREFIX - "btrl %1,%0" - : "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); -} -#define clear_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - clear_bit(nr, addr); \ -}) - -/** - * __clear_bit - Clears a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - * - * Unlike clear_bit(), this function is non-atomic and may be reordered. - * If it''s called on the same region of memory simultaneously, the effect - * may be that only one operation succeeds. - */ -static inline void __clear_bit(int nr, volatile void *addr) -{ - asm volatile ( - "btrl %1,%0" - : "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); -} -#define __clear_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - __clear_bit(nr, addr); \ -}) - -#define smp_mb__before_clear_bit() ((void)0) -#define smp_mb__after_clear_bit() ((void)0) - -/** - * __change_bit - Toggle a bit in memory - * @nr: the bit to set - * @addr: the address to start counting from - * - * Unlike change_bit(), this function is non-atomic and may be reordered. - * If it''s called on the same region of memory simultaneously, the effect - * may be that only one operation succeeds. - */ -static inline void __change_bit(int nr, volatile void *addr) -{ - asm volatile ( - "btcl %1,%0" - : "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); -} -#define __change_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - __change_bit(nr, addr); \ -}) - -/** - * change_bit - Toggle a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - * - * change_bit() is atomic and may not be reordered. - * Note that @nr may be almost arbitrarily large; this function is not - * restricted to acting on a single-word quantity. - */ -static inline void change_bit(int nr, volatile void *addr) -{ - asm volatile ( - LOCK_PREFIX - "btcl %1,%0" - : "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); -} -#define change_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - change_bit(nr, addr); \ -}) - -/** - * test_and_set_bit - Set a bit and return its old value - * @nr: Bit to set - * @addr: Address to count from - * - * This operation is atomic and cannot be reordered. - * It also implies a memory barrier. - */ -static inline int test_and_set_bit(int nr, volatile void *addr) -{ - int oldbit; - - asm volatile ( - LOCK_PREFIX - "btsl %2,%1\n\tsbbl %0,%0" - : "=r" (oldbit), "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); - return oldbit; -} -#define test_and_set_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - test_and_set_bit(nr, addr); \ -}) - -/** - * __test_and_set_bit - Set a bit and return its old value - * @nr: Bit to set - * @addr: Address to count from - * - * This operation is non-atomic and can be reordered. - * If two examples of this operation race, one can appear to succeed - * but actually fail. You must protect multiple accesses with a lock. - */ -static inline int __test_and_set_bit(int nr, volatile void *addr) -{ - int oldbit; - - asm volatile ( - "btsl %2,%1\n\tsbbl %0,%0" - : "=r" (oldbit), "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); - return oldbit; -} -#define __test_and_set_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - __test_and_set_bit(nr, addr); \ -}) - -/** - * test_and_clear_bit - Clear a bit and return its old value - * @nr: Bit to set - * @addr: Address to count from - * - * This operation is atomic and cannot be reordered. - * It also implies a memory barrier. - */ -static inline int test_and_clear_bit(int nr, volatile void *addr) -{ - int oldbit; - - asm volatile ( - LOCK_PREFIX - "btrl %2,%1\n\tsbbl %0,%0" - : "=r" (oldbit), "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); - return oldbit; -} -#define test_and_clear_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - test_and_clear_bit(nr, addr); \ -}) - -/** - * __test_and_clear_bit - Clear a bit and return its old value - * @nr: Bit to set - * @addr: Address to count from - * - * This operation is non-atomic and can be reordered. - * If two examples of this operation race, one can appear to succeed - * but actually fail. You must protect multiple accesses with a lock. - */ -static inline int __test_and_clear_bit(int nr, volatile void *addr) -{ - int oldbit; - - asm volatile ( - "btrl %2,%1\n\tsbbl %0,%0" - : "=r" (oldbit), "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); - return oldbit; -} -#define __test_and_clear_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - __test_and_clear_bit(nr, addr); \ -}) - -/* WARNING: non atomic and it can be reordered! */ -static inline int __test_and_change_bit(int nr, volatile void *addr) -{ - int oldbit; - - asm volatile ( - "btcl %2,%1\n\tsbbl %0,%0" - : "=r" (oldbit), "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); - return oldbit; -} -#define __test_and_change_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - __test_and_change_bit(nr, addr); \ -}) - -/** - * test_and_change_bit - Change a bit and return its new value - * @nr: Bit to set - * @addr: Address to count from - * - * This operation is atomic and cannot be reordered. - * It also implies a memory barrier. - */ -static inline int test_and_change_bit(int nr, volatile void *addr) -{ - int oldbit; - - asm volatile ( - LOCK_PREFIX - "btcl %2,%1\n\tsbbl %0,%0" - : "=r" (oldbit), "=m" (ADDR) - : "Ir" (nr), "m" (ADDR) : "memory"); - return oldbit; -} -#define test_and_change_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - test_and_change_bit(nr, addr); \ -}) - -static inline int constant_test_bit(int nr, const volatile void *addr) -{ - return ((1U << (nr & 31)) & - (((const volatile unsigned int *)addr)[nr >> 5])) != 0; -} - -static inline int variable_test_bit(int nr, const volatile void *addr) -{ - int oldbit; - - asm volatile ( - "btl %2,%1\n\tsbbl %0,%0" - : "=r" (oldbit) - : "m" (CONST_ADDR), "Ir" (nr) : "memory" ); - return oldbit; -} - -#define test_bit(nr, addr) ({ \ - if ( bitop_bad_size(addr) ) __bitop_bad_size(); \ - (__builtin_constant_p(nr) ? \ - constant_test_bit((nr),(addr)) : \ - variable_test_bit((nr),(addr))); \ -}) - -extern unsigned int __find_first_bit( - const unsigned long *addr, unsigned int size); -extern unsigned int __find_next_bit( - const unsigned long *addr, unsigned int size, unsigned int offset); -extern unsigned int __find_first_zero_bit( - const unsigned long *addr, unsigned int size); -extern unsigned int __find_next_zero_bit( - const unsigned long *addr, unsigned int size, unsigned int offset); - -static inline unsigned int __scanbit(unsigned long val, unsigned long max) -{ - asm ( "bsf %1,%0 ; cmovz %2,%0" : "=&r" (val) : "r" (val), "r" (max) ); - return (unsigned int)val; -} - -/** - * find_first_bit - find the first set bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit-number of the first set bit, not the number of the byte - * containing a bit. - */ -#define find_first_bit(addr,size) \ -((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ - (__scanbit(*(const unsigned long *)addr, size)) : \ - __find_first_bit(addr,size))) - -/** - * find_next_bit - find the first set bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The maximum size to search - */ -#define find_next_bit(addr,size,off) \ -((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ - ((off) + (__scanbit((*(const unsigned long *)addr) >> (off), size))) : \ - __find_next_bit(addr,size,off))) - -/** - * find_first_zero_bit - find the first zero bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit-number of the first zero bit, not the number of the byte - * containing a bit. - */ -#define find_first_zero_bit(addr,size) \ -((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ - (__scanbit(~*(const unsigned long *)addr, size)) : \ - __find_first_zero_bit(addr,size))) - -/** - * find_next_zero_bit - find the first zero bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The maximum size to search - */ -#define find_next_zero_bit(addr,size,off) \ -((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ - ((off)+(__scanbit(~(((*(const unsigned long *)addr)) >> (off)), size))) : \ - __find_next_zero_bit(addr,size,off))) - - -/** - * find_first_set_bit - find the first set bit in @word - * @word: the word to search - * - * Returns the bit-number of the first set bit. The input must *not* be zero. - */ -static inline unsigned int find_first_set_bit(unsigned long word) -{ - asm ( "bsf %1,%0" : "=r" (word) : "r" (word) ); - return (unsigned int)word; -} - -/** - * ffs - find first bit set - * @x: the word to search - * - * This is defined the same way as the libc and compiler builtin ffs routines. - */ -#if 0 -static inline int ffs(unsigned long x) -{ - long r; - - asm ( "bsf %1,%0\n\t" - "jnz 1f\n\t" - "mov $-1,%0\n" - "1:" : "=r" (r) : "rm" (x)); - return (int)r+1; -} -#endif - -/** - * fls - find last bit set - * @x: the word to search - * - * This is defined the same way as ffs. - */ -static inline int fls(unsigned long x) -{ - long r; - - asm ( "bsr %1,%0\n\t" - "jnz 1f\n\t" - "mov $-1,%0\n" - "1:" : "=r" (r) : "rm" (x)); - return (int)r+1; -} - -/** - * hweightN - returns the hamming weight of a N-bit word - * @x: the word to weigh - * - * The Hamming Weight of a number is the total number of bits set in it. - */ -#define hweight64(x) generic_hweight64(x) -#define hweight32(x) generic_hweight32(x) -#define hweight16(x) generic_hweight16(x) -#define hweight8(x) generic_hweight8(x) - -#endif /* _X86_BITOPS_H */ diff -r 5553bd24a3d9 -r 9476d85932e5 tools/xenpaging/policy_default.c --- a/tools/xenpaging/policy_default.c Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/xenpaging/policy_default.c Fri Jun 10 10:47:03 2011 +0200 @@ -21,8 +21,7 @@ */ -#include "bitops.h" -#include "xc.h" +#include "xc_bitops.h" #include "policy.h" @@ -35,26 +34,23 @@ static unsigned int mru_size; static unsigned long *bitmap; static unsigned long *unconsumed; static unsigned long current_gfn; -static unsigned long bitmap_size; static unsigned long max_pages; int policy_init(xenpaging_t *paging) { int i; - int rc; + int rc = -ENOMEM; /* Allocate bitmap for pages not to page out */ - rc = alloc_bitmap(&bitmap, paging->bitmap_size); - if ( rc != 0 ) + bitmap = bitmap_alloc(paging->domain_info->max_pages); + if ( !bitmap ) goto out; /* Allocate bitmap to track unusable pages */ - rc = alloc_bitmap(&unconsumed, paging->bitmap_size); - if ( rc != 0 ) + unconsumed = bitmap_alloc(paging->domain_info->max_pages); + if ( !unconsumed ) goto out; - /* record bitmap_size */ - bitmap_size = paging->bitmap_size; max_pages = paging->domain_info->max_pages; /* Initialise MRU list of paged in pages */ @@ -65,10 +61,7 @@ int policy_init(xenpaging_t *paging) mru = malloc(sizeof(*mru) * mru_size); if ( mru == NULL ) - { - rc = -ENOMEM; goto out; - } for ( i = 0; i < mru_size; i++ ) mru[i] = INVALID_MFN; @@ -76,6 +69,7 @@ int policy_init(xenpaging_t *paging) /* Don''t page out page 0 */ set_bit(0, bitmap); + rc = 0; out: return rc; } diff -r 5553bd24a3d9 -r 9476d85932e5 tools/xenpaging/xc.c --- a/tools/xenpaging/xc.c Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/xenpaging/xc.c Fri Jun 10 10:47:03 2011 +0200 @@ -31,20 +31,6 @@ #include "xc.h" -int alloc_bitmap(unsigned long **bitmap, unsigned long bitmap_size) -{ - if ( *bitmap == NULL ) - { - *bitmap = calloc(bitmap_size / BITS_PER_LONG, sizeof(unsigned long)); - - if ( *bitmap == NULL ) - return -ENOMEM; - } - - memset(*bitmap, 0, bitmap_size / 8); - - return 0; -} int xc_mem_paging_flush_ioemu_cache(domid_t domain_id) { diff -r 5553bd24a3d9 -r 9476d85932e5 tools/xenpaging/xc.h --- a/tools/xenpaging/xc.h Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/xenpaging/xc.h Fri Jun 10 10:47:03 2011 +0200 @@ -39,7 +39,6 @@ #endif -#define BITS_PER_LONG 64 typedef struct xc_platform_info { @@ -50,7 +49,6 @@ typedef struct xc_platform_info { } xc_platform_info_t; -int alloc_bitmap(unsigned long **bitmap, unsigned long bitmap_size); int xc_mem_paging_flush_ioemu_cache(domid_t domain_id); int xc_wait_for_event(xc_interface *xch, xc_evtchn *xce); diff -r 5553bd24a3d9 -r 9476d85932e5 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:03 2011 +0200 @@ -31,7 +31,7 @@ #include <xen/mem_event.h> -#include "bitops.h" +#include "xc_bitops.h" #include "file_ops.h" #include "xc.h" @@ -200,11 +200,8 @@ static xenpaging_t *xenpaging_init(domid } /* Allocate bitmap for tracking pages that have been paged out */ - paging->bitmap_size = (paging->domain_info->max_pages + BITS_PER_LONG) & - ~(BITS_PER_LONG - 1); - - rc = alloc_bitmap(&paging->bitmap, paging->bitmap_size); - if ( rc != 0 ) + paging->bitmap = bitmap_alloc(paging->domain_info->max_pages); + if ( !paging->bitmap ) { ERROR("Error allocating bitmap"); goto err; diff -r 5553bd24a3d9 -r 9476d85932e5 tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:02 2011 +0200 +++ b/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:03 2011 +0200 @@ -40,7 +40,6 @@ typedef struct xenpaging { xc_platform_info_t *platform_info; xc_domaininfo_t *domain_info; - unsigned long bitmap_size; unsigned long *bitmap; mem_event_t mem_event; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 03 of 22] xenpaging: add xs_handle to struct xenpaging
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695625 -7200 # Node ID 2d2fe3e2bd73d0c257bb852ecb00052d0dcef301 # Parent 9476d85932e5eb8f1e7ce0a6814b6c0634341e61 xenpaging: add xs_handle to struct xenpaging A xs_handle is currently used in the xc_mem_paging_flush_ioemu_cache() function and will be used by a subsequent patch. Add it to struct xenpaging. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 9476d85932e5 -r 2d2fe3e2bd73 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:03 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:05 2011 +0200 @@ -28,6 +28,7 @@ #include <signal.h> #include <unistd.h> #include <xc_private.h> +#include <xs.h> #include <xen/mem_event.h> @@ -92,6 +93,14 @@ static xenpaging_t *xenpaging_init(domid paging = malloc(sizeof(xenpaging_t)); memset(paging, 0, sizeof(xenpaging_t)); + /* Open connection to xenstore */ + paging->xs_handle = xs_daemon_open(); + if ( paging->xs_handle == NULL ) + { + ERROR("Error initialising xenstore connection"); + goto err; + } + p = getenv("XENPAGING_POLICY_MRU_SIZE"); if ( p && *p ) { @@ -221,6 +230,8 @@ static xenpaging_t *xenpaging_init(domid err: if ( paging ) { + if ( paging->xs_handle ) + xs_daemon_close(paging->xs_handle); xc_interface_close(xch); if ( paging->mem_event.shared_page ) { @@ -277,6 +288,9 @@ static int xenpaging_teardown(xenpaging_ } paging->mem_event.xce_handle = NULL; + /* Close connection to xenstore */ + xs_daemon_close(paging->xs_handle); + /* Close connection to Xen */ rc = xc_interface_close(xch); if ( rc != 0 ) diff -r 9476d85932e5 -r 2d2fe3e2bd73 tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:03 2011 +0200 +++ b/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:05 2011 +0200 @@ -36,6 +36,7 @@ typedef struct xenpaging { xc_interface *xc_handle; + struct xs_handle *xs_handle; xc_platform_info_t *platform_info; xc_domaininfo_t *domain_info; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 04 of 22] xenpaging: drop xc.c, remove ASSERT
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695626 -7200 # Node ID 53623b8a03575e5e42a7e7d8eaf9020b4a3138f1 # Parent 2d2fe3e2bd73d0c257bb852ecb00052d0dcef301 xenpaging: drop xc.c, remove ASSERT The ASSERT is not needed, victim is never NULL. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 2d2fe3e2bd73 -r 53623b8a0357 tools/xenpaging/policy_default.c --- a/tools/xenpaging/policy_default.c Fri Jun 10 10:47:05 2011 +0200 +++ b/tools/xenpaging/policy_default.c Fri Jun 10 10:47:06 2011 +0200 @@ -78,7 +78,6 @@ int policy_choose_victim(xenpaging_t *pa { xc_interface *xch = paging->xc_handle; unsigned long wrap = current_gfn; - ASSERT(victim != NULL); do { diff -r 2d2fe3e2bd73 -r 53623b8a0357 tools/xenpaging/xc.h --- a/tools/xenpaging/xc.h Fri Jun 10 10:47:05 2011 +0200 +++ b/tools/xenpaging/xc.h Fri Jun 10 10:47:06 2011 +0200 @@ -30,13 +30,6 @@ #include <xen/mem_event.h> -#if 1 -#define ASSERT(_p) \ - if ( !(_p) ) { DPRINTF("Assertion ''%s'' failed, line %d, file %s", #_p , \ - __LINE__, __FILE__); *(int*)0=0; } -#else -#define ASSERT(_p) ((void)0) -#endif _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 05 of 22] xenpaging: drop xc.c, remove xc_platform_info_t
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695627 -7200 # Node ID 681dfb0dde8ba3bb661d25b060a186a72116ecd3 # Parent 53623b8a03575e5e42a7e7d8eaf9020b4a3138f1 xenpaging: drop xc.c, remove xc_platform_info_t xc_platform_info_t is not used in xenpaging. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 53623b8a0357 -r 681dfb0dde8b tools/xenpaging/xc.c --- a/tools/xenpaging/xc.c Fri Jun 10 10:47:06 2011 +0200 +++ b/tools/xenpaging/xc.c Fri Jun 10 10:47:07 2011 +0200 @@ -26,7 +26,6 @@ #include <stdarg.h> #include <sys/poll.h> #include <xc_private.h> -#include <xg_save_restore.h> #include <xs.h> #include "xc.h" @@ -97,15 +96,6 @@ int xc_wait_for_event(xc_interface *xch, return xc_wait_for_event_or_timeout(xch, xce, -1); } -int xc_get_platform_info(xc_interface *xc_handle, domid_t domain_id, - xc_platform_info_t *platform_info) -{ - return get_platform_info(xc_handle, domain_id, - &platform_info->max_mfn, - &platform_info->hvirt_start, - &platform_info->pt_levels, - &platform_info->guest_width); -} /* diff -r 53623b8a0357 -r 681dfb0dde8b tools/xenpaging/xc.h --- a/tools/xenpaging/xc.h Fri Jun 10 10:47:06 2011 +0200 +++ b/tools/xenpaging/xc.h Fri Jun 10 10:47:07 2011 +0200 @@ -34,12 +34,6 @@ -typedef struct xc_platform_info { - unsigned long max_mfn; - unsigned long hvirt_start; - unsigned int pt_levels; - unsigned int guest_width; -} xc_platform_info_t; @@ -47,8 +41,6 @@ int xc_mem_paging_flush_ioemu_cache(domi int xc_wait_for_event(xc_interface *xch, xc_evtchn *xce); int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned long ms); -int xc_get_platform_info(xc_interface *xc_handle, domid_t domain_id, - xc_platform_info_t *platform_info); #endif // __XC_H__ diff -r 53623b8a0357 -r 681dfb0dde8b tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:06 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:07 2011 +0200 @@ -176,22 +176,6 @@ static xenpaging_t *xenpaging_init(domid paging->mem_event.port = rc; - /* Get platform info */ - paging->platform_info = malloc(sizeof(xc_platform_info_t)); - if ( paging->platform_info == NULL ) - { - ERROR("Error allocating memory for platform info"); - goto err; - } - - rc = xc_get_platform_info(xch, paging->mem_event.domain_id, - paging->platform_info); - if ( rc != 1 ) - { - ERROR("Error getting platform info"); - goto err; - } - /* Get domaininfo */ paging->domain_info = malloc(sizeof(xc_domaininfo_t)); if ( paging->domain_info == NULL ) @@ -246,7 +230,6 @@ static xenpaging_t *xenpaging_init(domid } free(paging->bitmap); - free(paging->platform_info); free(paging->domain_info); free(paging); } diff -r 53623b8a0357 -r 681dfb0dde8b tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:06 2011 +0200 +++ b/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:07 2011 +0200 @@ -38,7 +38,6 @@ typedef struct xenpaging { xc_interface *xc_handle; struct xs_handle *xs_handle; - xc_platform_info_t *platform_info; xc_domaininfo_t *domain_info; unsigned long *bitmap; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 06 of 22] xenpaging: drop xc.c, remove xc_wait_for_event
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695628 -7200 # Node ID 44997646bd69e746fbf7421009f5175268da28ce # Parent 681dfb0dde8ba3bb661d25b060a186a72116ecd3 xenpaging: drop xc.c, remove xc_wait_for_event xc_wait_for_event is not used in xenpaging. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 681dfb0dde8b -r 44997646bd69 tools/xenpaging/xc.c --- a/tools/xenpaging/xc.c Fri Jun 10 10:47:07 2011 +0200 +++ b/tools/xenpaging/xc.c Fri Jun 10 10:47:08 2011 +0200 @@ -91,10 +91,6 @@ int xc_wait_for_event_or_timeout(xc_inte return -errno; } -int xc_wait_for_event(xc_interface *xch, xc_evtchn *xce) -{ - return xc_wait_for_event_or_timeout(xch, xce, -1); -} diff -r 681dfb0dde8b -r 44997646bd69 tools/xenpaging/xc.h --- a/tools/xenpaging/xc.h Fri Jun 10 10:47:07 2011 +0200 +++ b/tools/xenpaging/xc.h Fri Jun 10 10:47:08 2011 +0200 @@ -38,7 +38,6 @@ int xc_mem_paging_flush_ioemu_cache(domid_t domain_id); -int xc_wait_for_event(xc_interface *xch, xc_evtchn *xce); int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned long ms); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 07 of 22] xenpaging: drop xc.c, move xc_mem_paging_flush_ioemu_cache
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695630 -7200 # Node ID fe8cb47be2adc95e6181de8c166e4460e1a2e40f # Parent 44997646bd69e746fbf7421009f5175268da28ce xenpaging: drop xc.c, move xc_mem_paging_flush_ioemu_cache Move xc_mem_paging_flush_ioemu_cache() into xenpaging and massage it a bit to use the required members from xenpaging_t. Also update type of rc to match xs_write() return value. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 44997646bd69 -r fe8cb47be2ad tools/xenpaging/xc.c --- a/tools/xenpaging/xc.c Fri Jun 10 10:47:08 2011 +0200 +++ b/tools/xenpaging/xc.c Fri Jun 10 10:47:10 2011 +0200 @@ -31,24 +31,6 @@ -int xc_mem_paging_flush_ioemu_cache(domid_t domain_id) -{ - struct xs_handle *xsh = NULL; - char path[80]; - int rc; - - sprintf(path, "/local/domain/0/device-model/%u/command", domain_id); - - xsh = xs_daemon_open(); - if ( xsh == NULL ) - return -EIO; - - rc = xs_write(xsh, XBT_NULL, path, "flush-cache", strlen("flush-cache")); - - xs_daemon_close(xsh); - - return rc ? 0 : -1; -} int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned long ms) { diff -r 44997646bd69 -r fe8cb47be2ad tools/xenpaging/xc.h --- a/tools/xenpaging/xc.h Fri Jun 10 10:47:08 2011 +0200 +++ b/tools/xenpaging/xc.h Fri Jun 10 10:47:10 2011 +0200 @@ -37,7 +37,6 @@ -int xc_mem_paging_flush_ioemu_cache(domid_t domain_id); int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned long ms); diff -r 44997646bd69 -r fe8cb47be2ad tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:08 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:10 2011 +0200 @@ -48,6 +48,20 @@ static void close_handler(int sig) unlink(filename); } +static int xenpaging_mem_paging_flush_ioemu_cache(xenpaging_t *paging) +{ + struct xs_handle *xsh = paging->xs_handle; + domid_t domain_id = paging->mem_event.domain_id; + char path[80]; + bool rc; + + sprintf(path, "/local/domain/0/device-model/%u/command", domain_id); + + rc = xs_write(xsh, XBT_NULL, path, "flush-cache", strlen("flush-cache")); + + return rc == true ? 0 : -1; +} + static void *init_page(void) { void *buffer; @@ -484,7 +498,7 @@ static int evict_victim(xenpaging_t *pag else { if ( j++ % 1000 == 0 ) - if ( xc_mem_paging_flush_ioemu_cache(paging->mem_event.domain_id) ) + if ( xenpaging_mem_paging_flush_ioemu_cache(paging) ) ERROR("Error flushing ioemu cache"); } } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 08 of 22] xenpaging: drop xc.c, move xc_wait_for_event_or_timeout
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695631 -7200 # Node ID b4e8bdedc0eaf9f1615e01152240d74a9996e07f # Parent fe8cb47be2adc95e6181de8c166e4460e1a2e40f xenpaging: drop xc.c, move xc_wait_for_event_or_timeout Move xc_wait_for_event_or_timeout() into xenpaging and massage it a bit for further changes in subsequent patches. Include poll.h instead of sys/poll.h. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r fe8cb47be2ad -r b4e8bdedc0ea tools/xenpaging/xc.c --- a/tools/xenpaging/xc.c Fri Jun 10 10:47:10 2011 +0200 +++ b/tools/xenpaging/xc.c Fri Jun 10 10:47:11 2011 +0200 @@ -32,46 +32,6 @@ -int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned long ms) -{ - struct pollfd fd = { .fd = xc_evtchn_fd(xce), .events = POLLIN | POLLERR }; - int port; - int rc; - - rc = poll(&fd, 1, ms); - if ( rc == -1 ) - { - if (errno == EINTR) - return 0; - - ERROR("Poll exited with an error"); - goto err; - } - - if ( rc == 1 ) - { - port = xc_evtchn_pending(xce); - if ( port == -1 ) - { - ERROR("Failed to read port from event channel"); - goto err; - } - - rc = xc_evtchn_unmask(xce, port); - if ( rc != 0 ) - { - ERROR("Failed to unmask event channel port"); - goto err; - } - } - else - port = -1; - - return port; - - err: - return -errno; -} diff -r fe8cb47be2ad -r b4e8bdedc0ea tools/xenpaging/xc.h --- a/tools/xenpaging/xc.h Fri Jun 10 10:47:10 2011 +0200 +++ b/tools/xenpaging/xc.h Fri Jun 10 10:47:11 2011 +0200 @@ -37,7 +37,6 @@ -int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned long ms); diff -r fe8cb47be2ad -r b4e8bdedc0ea tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:10 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:11 2011 +0200 @@ -27,6 +27,7 @@ #include <time.h> #include <signal.h> #include <unistd.h> +#include <poll.h> #include <xc_private.h> #include <xs.h> @@ -62,6 +63,47 @@ static int xenpaging_mem_paging_flush_io return rc == true ? 0 : -1; } +static int xenpaging_wait_for_event_or_timeout(xenpaging_t *paging) +{ + xc_interface *xch = paging->xc_handle; + xc_evtchn *xce = paging->mem_event.xce_handle; + struct pollfd fd[1]; + int port; + int rc; + + fd[0].fd = xc_evtchn_fd(xce); + fd[0].events = POLLIN | POLLERR; + rc = poll(fd, 1, 100); + if ( rc < 0 ) + { + if (errno == EINTR) + return 0; + + ERROR("Poll exited with an error"); + return -errno; + } + + if ( rc && fd[0].revents & POLLIN ) + { + DPRINTF("Got event from evtchn\n"); + port = xc_evtchn_pending(xce); + if ( port == -1 ) + { + ERROR("Failed to read port from event channel"); + rc = -1; + goto err; + } + + rc = xc_evtchn_unmask(xce, port); + if ( rc < 0 ) + { + ERROR("Failed to unmask event channel port"); + } + } +err: + return rc; +} + static void *init_page(void) { void *buffer; @@ -598,13 +640,13 @@ int main(int argc, char *argv[]) while ( !interrupted ) { /* Wait for Xen to signal that a page needs paged in */ - rc = xc_wait_for_event_or_timeout(xch, paging->mem_event.xce_handle, 100); - if ( rc < -1 ) + rc = xenpaging_wait_for_event_or_timeout(paging); + if ( rc < 0 ) { ERROR("Error getting event"); goto out; } - else if ( rc != -1 ) + else if ( rc != 0 ) { DPRINTF("Got event from Xen\n"); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 09 of 22] xenpaging: drop xc.c, remove xc files
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695632 -7200 # Node ID 9c42376aac05dc21a617d1d9fd62037cb8a9700d # Parent b4e8bdedc0eaf9f1615e01152240d74a9996e07f xenpaging: drop xc.c, remove xc files Finally remove xc.c/xc.h and its references since both are empty now. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r b4e8bdedc0ea -r 9c42376aac05 tools/xenpaging/Makefile --- a/tools/xenpaging/Makefile Fri Jun 10 10:47:11 2011 +0200 +++ b/tools/xenpaging/Makefile Fri Jun 10 10:47:12 2011 +0200 @@ -7,7 +7,7 @@ LDLIBS += $(LDLIBS_libxenctrl) $(LDLIBS_ POLICY = default SRC :-SRCS += file_ops.c xc.c xenpaging.c policy_$(POLICY).c +SRCS += file_ops.c xenpaging.c policy_$(POLICY).c CFLAGS += -Werror CFLAGS += -Wno-unused diff -r b4e8bdedc0ea -r 9c42376aac05 tools/xenpaging/mem_event.h --- a/tools/xenpaging/mem_event.h Fri Jun 10 10:47:11 2011 +0200 +++ b/tools/xenpaging/mem_event.h Fri Jun 10 10:47:12 2011 +0200 @@ -25,7 +25,6 @@ #define __XEN_MEM_EVENT_H__ -#include "xc.h" #include <xc_private.h> #include <xen/event_channel.h> diff -r b4e8bdedc0ea -r 9c42376aac05 tools/xenpaging/xc.c --- a/tools/xenpaging/xc.c Fri Jun 10 10:47:11 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/****************************************************************************** - * tools/xenpaging/lib/xc.c - * - * libxc-type add-ons for paging support. - * - * Copyright (c) 2009 Citrix Systems, Inc. (Patrick Colp) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include <errno.h> -#include <string.h> -#include <stdarg.h> -#include <sys/poll.h> -#include <xc_private.h> -#include <xs.h> -#include "xc.h" - - - - - - - - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff -r b4e8bdedc0ea -r 9c42376aac05 tools/xenpaging/xc.h --- a/tools/xenpaging/xc.h Fri Jun 10 10:47:11 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/****************************************************************************** - * tools/xenpaging/lib/xc.h - * - * libxc add-ons. - * - * Copyright (c) 2009 Citrix Systems, Inc. (Patrick Colp) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef __XC_H__ -#define __XC_H__ - - -#include <stdarg.h> -#include <xc_private.h> -#include <xen/mem_event.h> - - - - - - - - - - - - -#endif // __XC_H__ - - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff -r b4e8bdedc0ea -r 9c42376aac05 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:11 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:12 2011 +0200 @@ -35,7 +35,6 @@ #include "xc_bitops.h" #include "file_ops.h" -#include "xc.h" #include "policy.h" #include "xenpaging.h" diff -r b4e8bdedc0ea -r 9c42376aac05 tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:11 2011 +0200 +++ b/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:12 2011 +0200 @@ -25,7 +25,6 @@ #define __XEN_PAGING2_H__ -#include "xc.h" #include <xc_private.h> #include <xen/event_channel.h> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:12 UTC
[Xen-devel] [PATCH 10 of 22] xenpaging: correct dropping of pages to avoid full ring buffer
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695634 -7200 # Node ID 1de8de108d152fe915fc7f78044c406fed872bca # Parent 9c42376aac05dc21a617d1d9fd62037cb8a9700d xenpaging: correct dropping of pages to avoid full ring buffer Doing a one-way channel from Xen to xenpaging is not possible with the current ring buffer implementation. xenpaging uses the mem_event ring buffer, which expects request/response pairs to make progress. The previous patch, which tried to establish a one-way communication from Xen to xenpaging, stalled the guest once the buffer was filled up with requests. Correct page-dropping by taking the slow path and let p2m_mem_paging_resume() consume the response from xenpaging. This makes room for yet another request/response pair and avoids hanging guests. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 9c42376aac05 -r 1de8de108d15 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:12 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:14 2011 +0200 @@ -690,19 +690,19 @@ int main(int argc, char *argv[]) ERROR("Error populating page"); goto out; } + } - /* Prepare the response */ - rsp.gfn = req.gfn; - rsp.p2mt = req.p2mt; - rsp.vcpu_id = req.vcpu_id; - rsp.flags = req.flags; + /* Prepare the response */ + rsp.gfn = req.gfn; + rsp.p2mt = req.p2mt; + rsp.vcpu_id = req.vcpu_id; + rsp.flags = req.flags; - rc = xenpaging_resume_page(paging, &rsp, 1); - if ( rc != 0 ) - { - ERROR("Error resuming page"); - goto out; - } + rc = xenpaging_resume_page(paging, &rsp, 1); + if ( rc != 0 ) + { + ERROR("Error resuming page"); + goto out; } /* Evict a new page to replace the one we just paged in */ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 11 of 22] xenpaging: do not bounce p2mt to xenpaging
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695635 -7200 # Node ID 17c9aa11b28a867864b104322e19d188dd4bc14e # Parent 1de8de108d152fe915fc7f78044c406fed872bca xenpaging: do not bounce p2mt to xenpaging do not bounce p2mt to xenpaging because p2m_mem_paging_populate() and p2m_mem_paging_resume() dont make use of p2mt Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 1de8de108d15 -r 17c9aa11b28a tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:14 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:15 2011 +0200 @@ -694,7 +694,6 @@ int main(int argc, char *argv[]) /* Prepare the response */ rsp.gfn = req.gfn; - rsp.p2mt = req.p2mt; rsp.vcpu_id = req.vcpu_id; rsp.flags = req.flags; @@ -711,10 +710,8 @@ int main(int argc, char *argv[]) else { DPRINTF("page already populated (domain = %d; vcpu = %d;" - " p2mt = %x;" " gfn = %"PRIx64"; paused = %d)\n", paging->mem_event.domain_id, req.vcpu_id, - req.p2mt, req.gfn, req.flags & MEM_EVENT_FLAG_VCPU_PAUSED); /* Tell Xen to resume the vcpu */ @@ -723,7 +720,6 @@ int main(int argc, char *argv[]) { /* Prepare the response */ rsp.gfn = req.gfn; - rsp.p2mt = req.p2mt; rsp.vcpu_id = req.vcpu_id; rsp.flags = req.flags; diff -r 1de8de108d15 -r 17c9aa11b28a xen/arch/x86/mm/p2m.c --- a/xen/arch/x86/mm/p2m.c Fri Jun 10 10:47:14 2011 +0200 +++ b/xen/arch/x86/mm/p2m.c Fri Jun 10 10:47:15 2011 +0200 @@ -773,7 +773,6 @@ void p2m_mem_paging_populate(struct doma /* Send request to pager */ req.gfn = gfn; - req.p2mt = p2mt; req.vcpu_id = v->vcpu_id; mem_event_put_request(d, &req); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 12 of 22] xenpaging: remove srand call
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695636 -7200 # Node ID ea8f764e530d66463ceb9e97af9756a2a8f96c7c # Parent 17c9aa11b28a867864b104322e19d188dd4bc14e xenpaging: remove srand call The policy uses now a linear algorithm instead of a random one. Remove the call to srand(). Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 17c9aa11b28a -r ea8f764e530d tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:15 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:16 2011 +0200 @@ -581,9 +581,6 @@ int main(int argc, char *argv[]) domain_id = atoi(argv[1]); num_pages = atoi(argv[2]); - /* Seed random-number generator */ - srand(time(NULL)); - /* Initialise domain paging */ paging = xenpaging_init(domain_id); if ( paging == NULL ) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 13 of 22] xenpaging: remove return values from functions that can not fail
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695638 -7200 # Node ID f26f07e19318b112b58ee370c16bee8bf5605d3f # Parent ea8f764e530d66463ceb9e97af9756a2a8f96c7c xenpaging: remove return values from functions that can not fail get_request() and put_response() can not fail, remove return value and update calling functions. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r ea8f764e530d -r f26f07e19318 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:16 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:18 2011 +0200 @@ -342,7 +342,7 @@ static int xenpaging_teardown(xenpaging_ return -1; } -static int get_request(mem_event_t *mem_event, mem_event_request_t *req) +static void get_request(mem_event_t *mem_event, mem_event_request_t *req) { mem_event_back_ring_t *back_ring; RING_IDX req_cons; @@ -357,11 +357,9 @@ static int get_request(mem_event_t *mem_ /* Update ring */ back_ring->req_cons = req_cons; back_ring->sring->req_event = req_cons + 1; - - return 0; } -static int put_response(mem_event_t *mem_event, mem_event_response_t *rsp) +static void put_response(mem_event_t *mem_event, mem_event_response_t *rsp) { mem_event_back_ring_t *back_ring; RING_IDX rsp_prod; @@ -376,8 +374,6 @@ static int put_response(mem_event_t *mem /* Update ring */ back_ring->rsp_prod_pvt = rsp_prod; RING_PUSH_RESPONSES(back_ring); - - return 0; } static int xenpaging_evict_page(xenpaging_t *paging, @@ -437,9 +433,7 @@ static int xenpaging_resume_page(xenpagi int ret; /* Put the page info on the ring */ - ret = put_response(&paging->mem_event, rsp); - if ( ret != 0 ) - goto out; + put_response(&paging->mem_event, rsp); /* Notify policy of page being paged in */ if ( notify_policy ) @@ -649,12 +643,7 @@ int main(int argc, char *argv[]) while ( RING_HAS_UNCONSUMED_REQUESTS(&paging->mem_event.back_ring) ) { - rc = get_request(&paging->mem_event, &req); - if ( rc != 0 ) - { - ERROR("Error getting request"); - goto out; - } + get_request(&paging->mem_event, &req); /* Check if the page has already been paged in */ if ( test_and_clear_bit(req.gfn, paging->bitmap) ) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 14 of 22] xenpaging: catch xc_mem_paging_resume errors
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695639 -7200 # Node ID c67d7c0936969d076e30700c9a8f57080238be4e # Parent f26f07e19318b112b58ee370c16bee8bf5605d3f xenpaging: catch xc_mem_paging_resume errors In the unlikely event that xc_mem_paging_resume() fails, do not overwrite the error with the return value from xc_evtchn_notify() Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r f26f07e19318 -r c67d7c093696 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:18 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:19 2011 +0200 @@ -442,8 +442,9 @@ static int xenpaging_resume_page(xenpagi /* Tell Xen page is ready */ ret = xc_mem_paging_resume(paging->xc_handle, paging->mem_event.domain_id, rsp->gfn); - ret = xc_evtchn_notify(paging->mem_event.xce_handle, - paging->mem_event.port); + if ( ret == 0 ) + ret = xc_evtchn_notify(paging->mem_event.xce_handle, + paging->mem_event.port); out: return ret; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 15 of 22] xenpaging: remove local domain_id variable
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695640 -7200 # Node ID 8913a5fda8d0b3739af4265bc363b02745fa7d01 # Parent c67d7c0936969d076e30700c9a8f57080238be4e xenpaging: remove local domain_id variable Remove the local domain_id variable, it is already fetched from paging->mem_event in other places. Update the sprintf format string to use unsigned argument. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r c67d7c093696 -r 8913a5fda8d0 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:19 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:20 2011 +0200 @@ -552,7 +552,6 @@ static int evict_victim(xenpaging_t *pag int main(int argc, char *argv[]) { struct sigaction act; - domid_t domain_id; int num_pages; xenpaging_t *paging; xenpaging_victim_t *victims; @@ -573,11 +572,10 @@ int main(int argc, char *argv[]) return -1; } - domain_id = atoi(argv[1]); num_pages = atoi(argv[2]); /* Initialise domain paging */ - paging = xenpaging_init(domain_id); + paging = xenpaging_init(atoi(argv[1])); if ( paging == NULL ) { fprintf(stderr, "Error initialising paging"); @@ -585,10 +583,10 @@ int main(int argc, char *argv[]) } xch = paging->xc_handle; - DPRINTF("starting %s %u %d\n", argv[0], domain_id, num_pages); + DPRINTF("starting %s %u %d\n", argv[0], paging->mem_event.domain_id, num_pages); /* Open file */ - sprintf(filename, "page_cache_%d", domain_id); + sprintf(filename, "page_cache_%u", paging->mem_event.domain_id); fd = open(filename, open_flags, open_mode); if ( fd < 0 ) { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 16 of 22] xenpaging: move num_pages into xenpaging struct
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695642 -7200 # Node ID 6fafd6e85a20f667c9546d76569049d411b96fb1 # Parent 8913a5fda8d0b3739af4265bc363b02745fa7d01 xenpaging: move num_pages into xenpaging struct Move num_pages into struct xenpaging. num_pages will be used by the policy in a subsequent patch. Also remove a memset, the victims array is allocated with calloc. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 8913a5fda8d0 -r 6fafd6e85a20 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:20 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:22 2011 +0200 @@ -128,7 +128,7 @@ static void *init_page(void) return NULL; } -static xenpaging_t *xenpaging_init(domid_t domain_id) +static xenpaging_t *xenpaging_init(domid_t domain_id, int num_pages) { xenpaging_t *paging; xc_interface *xch; @@ -256,6 +256,13 @@ static xenpaging_t *xenpaging_init(domid } DPRINTF("max_pages = %"PRIx64"\n", paging->domain_info->max_pages); + if ( num_pages < 0 || num_pages > paging->domain_info->max_pages ) + { + num_pages = paging->domain_info->max_pages; + DPRINTF("setting num_pages to %d\n", num_pages); + } + paging->num_pages = num_pages; + /* Initialise policy */ rc = policy_init(paging); if ( rc != 0 ) @@ -552,7 +559,6 @@ static int evict_victim(xenpaging_t *pag int main(int argc, char *argv[]) { struct sigaction act; - int num_pages; xenpaging_t *paging; xenpaging_victim_t *victims; mem_event_request_t req; @@ -572,10 +578,8 @@ int main(int argc, char *argv[]) return -1; } - num_pages = atoi(argv[2]); - /* Initialise domain paging */ - paging = xenpaging_init(atoi(argv[1])); + paging = xenpaging_init(atoi(argv[1]), atoi(argv[2])); if ( paging == NULL ) { fprintf(stderr, "Error initialising paging"); @@ -583,7 +587,7 @@ int main(int argc, char *argv[]) } xch = paging->xc_handle; - DPRINTF("starting %s %u %d\n", argv[0], paging->mem_event.domain_id, num_pages); + DPRINTF("starting %s %u %d\n", argv[0], paging->mem_event.domain_id, paging->num_pages); /* Open file */ sprintf(filename, "page_cache_%u", paging->mem_event.domain_id); @@ -594,12 +598,7 @@ int main(int argc, char *argv[]) return 2; } - if ( num_pages < 0 || num_pages > paging->domain_info->max_pages ) - { - num_pages = paging->domain_info->max_pages; - DPRINTF("setting num_pages to %d\n", num_pages); - } - victims = calloc(num_pages, sizeof(xenpaging_victim_t)); + victims = calloc(paging->num_pages, sizeof(xenpaging_victim_t)); /* ensure that if we get a signal, we''ll do cleanup, then exit */ act.sa_handler = close_handler; @@ -611,8 +610,7 @@ int main(int argc, char *argv[]) sigaction(SIGALRM, &act, NULL); /* Evict pages */ - memset(victims, 0, sizeof(xenpaging_victim_t) * num_pages); - for ( i = 0; i < num_pages; i++ ) + for ( i = 0; i < paging->num_pages; i++ ) { rc = evict_victim(paging, &victims[i], fd, i); if ( rc == -ENOSPC ) @@ -648,13 +646,13 @@ int main(int argc, char *argv[]) if ( test_and_clear_bit(req.gfn, paging->bitmap) ) { /* Find where in the paging file to read from */ - for ( i = 0; i < num_pages; i++ ) + for ( i = 0; i < paging->num_pages; i++ ) { if ( victims[i].gfn == req.gfn ) break; } - if ( i >= num_pages ) + if ( i >= paging->num_pages ) { DPRINTF("Couldn''t find page %"PRIx64"\n", req.gfn); goto out; diff -r 8913a5fda8d0 -r 6fafd6e85a20 tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:20 2011 +0200 +++ b/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:22 2011 +0200 @@ -42,6 +42,7 @@ typedef struct xenpaging { unsigned long *bitmap; mem_event_t mem_event; + int num_pages; int policy_mru_size; } xenpaging_t; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 17 of 22] xenpaging: start paging in the middle of gfn range
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695643 -7200 # Node ID 6c7c51f831bfe143093146d67a205b6660490021 # Parent 6fafd6e85a20f667c9546d76569049d411b96fb1 xenpaging: start paging in the middle of gfn range Set the starting gfn to somewhere in the middle of the gfn range to avoid paging during BIOS startup. This can speedup booting of a guest. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 6fafd6e85a20 -r 6c7c51f831bf tools/xenpaging/policy_default.c --- a/tools/xenpaging/policy_default.c Fri Jun 10 10:47:22 2011 +0200 +++ b/tools/xenpaging/policy_default.c Fri Jun 10 10:47:23 2011 +0200 @@ -69,6 +69,10 @@ int policy_init(xenpaging_t *paging) /* Don''t page out page 0 */ set_bit(0, bitmap); + /* Start in the middle to avoid paging during BIOS startup */ + current_gfn = max_pages / 2; + current_gfn -= paging->num_pages / 2; + rc = 0; out: return rc; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 18 of 22] xenpaging: pass integer to xenpaging_populate_page
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695644 -7200 # Node ID 3d8e65d22c13aeebe3f1e25e2dd9724c3efcf8d6 # Parent 6c7c51f831bfe143093146d67a205b6660490021 xenpaging: pass integer to xenpaging_populate_page Pass gfn as integer to xenpaging_populate_page(). xc_map_foreign_pages() takes a pointer to a list of gfns, but its a const pointer. So writing the value back to the caller is not needed. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 6c7c51f831bf -r 3d8e65d22c13 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:23 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:24 2011 +0200 @@ -458,27 +458,24 @@ static int xenpaging_resume_page(xenpagi } static int xenpaging_populate_page(xenpaging_t *paging, - uint64_t *gfn, int fd, int i) + xen_pfn_t gfn, int fd, int i) { xc_interface *xch = paging->xc_handle; - unsigned long _gfn; void *page; int ret; unsigned char oom = 0; - _gfn = *gfn; - DPRINTF("populate_page < gfn %lx pageslot %d\n", _gfn, i); + DPRINTF("populate_page < gfn %"PRI_xen_pfn" pageslot %d\n", gfn, i); do { /* Tell Xen to allocate a page for the domain */ - ret = xc_mem_paging_prep(xch, paging->mem_event.domain_id, - _gfn); + ret = xc_mem_paging_prep(xch, paging->mem_event.domain_id, gfn); if ( ret != 0 ) { if ( errno == ENOMEM ) { if ( oom++ == 0 ) - DPRINTF("ENOMEM while preparing gfn %lx\n", _gfn); + DPRINTF("ENOMEM while preparing gfn %"PRI_xen_pfn"\n", gfn); sleep(1); continue; } @@ -491,8 +488,7 @@ static int xenpaging_populate_page(xenpa /* Map page */ ret = -EFAULT; page = xc_map_foreign_pages(xch, paging->mem_event.domain_id, - PROT_READ | PROT_WRITE, &_gfn, 1); - *gfn = _gfn; + PROT_READ | PROT_WRITE, &gfn, 1); if ( page == NULL ) { ERROR("Error mapping page: page is null"); @@ -667,7 +663,7 @@ int main(int argc, char *argv[]) else { /* Populate the page */ - rc = xenpaging_populate_page(paging, &req.gfn, fd, i); + rc = xenpaging_populate_page(paging, req.gfn, fd, i); if ( rc != 0 ) { ERROR("Error populating page"); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 19 of 22] xenpaging: add helper function for unlinking pagefile
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695645 -7200 # Node ID c375ced18c763dd7dcebfdc923f1d5154656b578 # Parent 3d8e65d22c13aeebe3f1e25e2dd9724c3efcf8d6 xenpaging: add helper function for unlinking pagefile Unlink pagefile in the signal handler and also in the exit path. This does not leave a stale pagefile if an error occoured. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 3d8e65d22c13 -r c375ced18c76 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:24 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:25 2011 +0200 @@ -41,11 +41,20 @@ static char filename[80]; static int interrupted; + +static void unlink_pagefile(void) +{ + if ( filename[0] ) + { + unlink(filename); + filename[0] = ''\0''; + } +} + static void close_handler(int sig) { interrupted = sig; - if ( filename[0] ) - unlink(filename); + unlink_pagefile(); } static int xenpaging_mem_paging_flush_ioemu_cache(xenpaging_t *paging) @@ -716,6 +725,7 @@ int main(int argc, char *argv[]) out: close(fd); + unlink_pagefile(); free(victims); /* Tear down domain paging */ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 20 of 22] xenpaging: add watch thread to catch guest shutdown
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695647 -7200 # Node ID 3446ab4866249018b1611fdfe430cbb2ff2a5b31 # Parent c375ced18c763dd7dcebfdc923f1d5154656b578 xenpaging: add watch thread to catch guest shutdown If xenpaging is started manually then no event is sent to xenpaging when the guest is shutdown or rebooted. Add a watch on the @releaseDomain node to leave the loop and gracefully shutdown the pager. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r c375ced18c76 -r 3446ab486624 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:25 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:27 2011 +0200 @@ -39,6 +39,7 @@ #include "policy.h" #include "xenpaging.h" +static char watch_token[16]; static char filename[80]; static int interrupted; @@ -75,13 +76,19 @@ static int xenpaging_wait_for_event_or_t { xc_interface *xch = paging->xc_handle; xc_evtchn *xce = paging->mem_event.xce_handle; - struct pollfd fd[1]; + char **vec; + unsigned int num; + struct pollfd fd[2]; int port; int rc; + /* Wait for event channel and xenstore */ fd[0].fd = xc_evtchn_fd(xce); fd[0].events = POLLIN | POLLERR; - rc = poll(fd, 1, 100); + fd[1].fd = xs_fileno(paging->xs_handle); + fd[1].events = POLLIN | POLLERR; + + rc = poll(fd, 2, 100); if ( rc < 0 ) { if (errno == EINTR) @@ -91,6 +98,27 @@ static int xenpaging_wait_for_event_or_t return -errno; } + /* First check for guest shutdown */ + if ( rc && fd[1].revents & POLLIN ) + { + DPRINTF("Got event from xenstore\n"); + vec = xs_read_watch(paging->xs_handle, &num); + if ( vec ) + { + if ( strcmp(vec[XS_WATCH_TOKEN], watch_token) == 0 ) + { + /* If our guest disappeared, set interrupt flag and fall through */ + if ( xs_is_domain_introduced(paging->xs_handle, paging->mem_event.domain_id) == false ) + { + xs_unwatch(paging->xs_handle, "@releaseDomain", watch_token); + interrupted = SIGQUIT; + rc = 0; + } + } + free(vec); + } + } + if ( rc && fd[0].revents & POLLIN ) { DPRINTF("Got event from evtchn\n"); @@ -165,6 +193,14 @@ static xenpaging_t *xenpaging_init(domid goto err; } + /* write domain ID to watch so we can ignore other domain shutdowns */ + snprintf(watch_token, sizeof(watch_token), "%u", domain_id); + if ( xs_watch(paging->xs_handle, "@releaseDomain", watch_token) == false ) + { + ERROR("Could not bind to shutdown watch\n"); + goto err; + } + p = getenv("XENPAGING_POLICY_MRU_SIZE"); if ( p && *p ) { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 21 of 22] xenpaging: implement stopping of pager by sending SIGTERM/SIGINT
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695648 -7200 # Node ID 39e5460d899872c9654634a24c66160495f4d3c2 # Parent 3446ab4866249018b1611fdfe430cbb2ff2a5b31 xenpaging: implement stopping of pager by sending SIGTERM/SIGINT Write all paged-out pages back into the guest if the pager is interrupted by ctrl-c or if it receives SIGTERM. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 3446ab486624 -r 39e5460d8998 tools/xenpaging/Makefile --- a/tools/xenpaging/Makefile Fri Jun 10 10:47:27 2011 +0200 +++ b/tools/xenpaging/Makefile Fri Jun 10 10:47:28 2011 +0200 @@ -8,6 +8,7 @@ POLICY = default SRC : SRCS += file_ops.c xenpaging.c policy_$(POLICY).c +SRCS += pagein.c CFLAGS += -Werror CFLAGS += -Wno-unused diff -r 3446ab486624 -r 39e5460d8998 tools/xenpaging/pagein.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xenpaging/pagein.c Fri Jun 10 10:47:28 2011 +0200 @@ -0,0 +1,68 @@ +/* Trigger a page-in in a separate thread-of-execution to avoid deadlock */ +#include <pthread.h> +#include "xc_private.h" + +struct page_in_args { + domid_t dom; + xc_interface *xch; +}; + +static struct page_in_args page_in_args; +static unsigned long page_in_gfn; +static unsigned int page_in_possible; + +static pthread_t page_in_thread; +static pthread_cond_t page_in_cond = PTHREAD_COND_INITIALIZER; +static pthread_mutex_t page_in_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void *page_in(void *arg) +{ + struct page_in_args *pia = arg; + void *page; + xen_pfn_t gfn; + + while (1) + { + pthread_mutex_lock(&page_in_mutex); + while (!page_in_gfn) + pthread_cond_wait(&page_in_cond, &page_in_mutex); + gfn = page_in_gfn; + page_in_gfn = 0; + pthread_mutex_unlock(&page_in_mutex); + + /* Ignore errors */ + page = xc_map_foreign_pages(pia->xch, pia->dom, PROT_READ, &gfn, 1); + if (page) + munmap(page, PAGE_SIZE); + } + page_in_possible = 0; + pthread_exit(NULL); +} + +void page_in_trigger(unsigned long gfn) +{ + if (!page_in_possible) + return; + + pthread_mutex_lock(&page_in_mutex); + page_in_gfn = gfn; + pthread_mutex_unlock(&page_in_mutex); + pthread_cond_signal(&page_in_cond); +} + +void create_page_in_thread(domid_t domain_id, xc_interface *xch) +{ + page_in_args.dom = domain_id; + page_in_args.xch = xch; + if (pthread_create(&page_in_thread, NULL, page_in, &page_in_args) == 0) + page_in_possible = 1; +} + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff -r 3446ab486624 -r 39e5460d8998 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:27 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:28 2011 +0200 @@ -650,6 +650,9 @@ int main(int argc, char *argv[]) sigaction(SIGINT, &act, NULL); sigaction(SIGALRM, &act, NULL); + /* listen for page-in events to stop pager */ + create_page_in_thread(paging->mem_event.domain_id, xch); + /* Evict pages */ for ( i = 0; i < paging->num_pages; i++ ) { @@ -665,7 +668,7 @@ int main(int argc, char *argv[]) DPRINTF("%d pages evicted. Done.\n", i); /* Swap pages in and out */ - while ( !interrupted ) + while ( 1 ) { /* Wait for Xen to signal that a page needs paged in */ rc = xenpaging_wait_for_event_or_timeout(paging); @@ -728,8 +731,12 @@ int main(int argc, char *argv[]) goto out; } - /* Evict a new page to replace the one we just paged in */ - evict_victim(paging, &victims[i], fd, i); + /* Evict a new page to replace the one we just paged in, + * or clear this pagefile slot on exit */ + if ( interrupted ) + victims[i].gfn = INVALID_MFN; + else + evict_victim(paging, &victims[i], fd, i); } else { @@ -756,6 +763,28 @@ int main(int argc, char *argv[]) } } } + + /* Write all pages back into the guest */ + if ( interrupted == SIGTERM || interrupted == SIGINT ) + { + for ( i = 0; i < paging->domain_info->max_pages; i++ ) + { + if ( test_bit(i, paging->bitmap) ) + { + page_in_trigger(i); + break; + } + } + /* If no more pages to process, exit loop */ + if ( i == paging->domain_info->max_pages ) + break; + } + else + { + /* Exit on any other signal */ + if ( interrupted ) + break; + } } DPRINTF("xenpaging got signal %d\n", interrupted); diff -r 3446ab486624 -r 39e5460d8998 tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:27 2011 +0200 +++ b/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:28 2011 +0200 @@ -53,6 +53,9 @@ typedef struct xenpaging_victim { } xenpaging_victim_t; +extern void create_page_in_thread(domid_t domain_id, xc_interface *xch); +extern void page_in_trigger(unsigned long gfn); + #endif // __XEN_PAGING_H__ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-10 09:13 UTC
[Xen-devel] [PATCH 22 of 22] xenpaging: remove private mem_event.h
# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1307695649 -7200 # Node ID 2b17fb49efd404627bdfff40f0be36e7076b5c00 # Parent 39e5460d899872c9654634a24c66160495f4d3c2 xenpaging: remove private mem_event.h tools/xenpaging/mem_event.h is only included in xenpaging.h. Add the contents into that file and remove mem_event.h. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 39e5460d8998 -r 2b17fb49efd4 tools/xenpaging/mem_event.h --- a/tools/xenpaging/mem_event.h Fri Jun 10 10:47:28 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/****************************************************************************** - * tools/xenpaging/mem_event.h - * - * Memory event structures. - * - * Copyright (c) 2009 Citrix Systems, Inc. (Patrick Colp) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef __XEN_MEM_EVENT_H__ -#define __XEN_MEM_EVENT_H__ - - -#include <xc_private.h> - -#include <xen/event_channel.h> -#include <xen/mem_event.h> - - - - -typedef struct mem_event { - domid_t domain_id; - xc_evtchn *xce_handle; - int port; - mem_event_back_ring_t back_ring; - mem_event_shared_page_t *shared_page; - void *ring_page; -} mem_event_t; - - -#endif // __XEN_MEM_EVENT_H__ - - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff -r 39e5460d8998 -r 2b17fb49efd4 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:28 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:29 2011 +0200 @@ -31,11 +31,8 @@ #include <xc_private.h> #include <xs.h> -#include <xen/mem_event.h> - #include "xc_bitops.h" #include "file_ops.h" - #include "policy.h" #include "xenpaging.h" diff -r 39e5460d8998 -r 2b17fb49efd4 tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:28 2011 +0200 +++ b/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:29 2011 +0200 @@ -26,12 +26,17 @@ #include <xc_private.h> - #include <xen/event_channel.h> #include <xen/mem_event.h> -#include "mem_event.h" - +typedef struct mem_event { + domid_t domain_id; + xc_evtchn *xce_handle; + int port; + mem_event_back_ring_t back_ring; + mem_event_shared_page_t *shared_page; + void *ring_page; +} mem_event_t; typedef struct xenpaging { xc_interface *xc_handle; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Tim Deegan
2011-Jun-13 10:48 UTC
Re: [Xen-devel] [PATCH 11 of 22] xenpaging: do not bounce p2mt to xenpaging
At 11:13 +0200 on 10 Jun (1307704380), Olaf Hering wrote:> diff -r 1de8de108d15 -r 17c9aa11b28a xen/arch/x86/mm/p2m.c > --- a/xen/arch/x86/mm/p2m.c Fri Jun 10 10:47:14 2011 +0200 > +++ b/xen/arch/x86/mm/p2m.c Fri Jun 10 10:47:15 2011 +0200 > @@ -773,7 +773,6 @@ void p2m_mem_paging_populate(struct doma > > /* Send request to pager */ > req.gfn = gfn; > - req.p2mt = p2mt; > req.vcpu_id = v->vcpu_id; > > mem_event_put_request(d, &req);Might as well leave this hypervisor-side part here; it''s pretty much free and if we do decide to start using p2mt in a paging client it will save us reintroducing it. Cheers, Tim. -- Tim Deegan <Tim.Deegan@citrix.com> Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jun-14 11:05 UTC
Re: [Xen-devel] [PATCH 03 of 22] xenpaging: add xs_handle to struct xenpaging
On Fri, 2011-06-10 at 10:12 +0100, Olaf Hering wrote:> # HG changeset patch > # User Olaf Hering <olaf@aepfle.de> > # Date 1307695625 -7200 > # Node ID 2d2fe3e2bd73d0c257bb852ecb00052d0dcef301 > # Parent 9476d85932e5eb8f1e7ce0a6814b6c0634341e61 > xenpaging: add xs_handle to struct xenpaging > > A xs_handle is currently used in the xc_mem_paging_flush_ioemu_cache() > function and will be used by a subsequent patch. > Add it to struct xenpaging. > > Signed-off-by: Olaf Hering <olaf@aepfle.de> > > diff -r 9476d85932e5 -r 2d2fe3e2bd73 tools/xenpaging/xenpaging.c > --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:03 2011 +0200 > +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:05 2011 +0200 > @@ -28,6 +28,7 @@ > #include <signal.h> > #include <unistd.h> > #include <xc_private.h> > +#include <xs.h> > > #include <xen/mem_event.h> > > @@ -92,6 +93,14 @@ static xenpaging_t *xenpaging_init(domid > paging = malloc(sizeof(xenpaging_t)); > memset(paging, 0, sizeof(xenpaging_t)); > > + /* Open connection to xenstore */ > + paging->xs_handle = xs_daemon_open();xs_daemon_open is deprecated, please use xs_open(0).> + if ( paging->xs_handle == NULL ) > + { > + ERROR("Error initialising xenstore connection"); > + goto err; > + } > + > p = getenv("XENPAGING_POLICY_MRU_SIZE"); > if ( p && *p ) > { > @@ -221,6 +230,8 @@ static xenpaging_t *xenpaging_init(domid > err: > if ( paging ) > { > + if ( paging->xs_handle ) > + xs_daemon_close(paging->xs_handle);Similarly please use xs_close().> xc_interface_close(xch); > if ( paging->mem_event.shared_page ) > { > @@ -277,6 +288,9 @@ static int xenpaging_teardown(xenpaging_ > } > paging->mem_event.xce_handle = NULL; > > + /* Close connection to xenstore */ > + xs_daemon_close(paging->xs_handle); > + > /* Close connection to Xen */ > rc = xc_interface_close(xch); > if ( rc != 0 ) > diff -r 9476d85932e5 -r 2d2fe3e2bd73 tools/xenpaging/xenpaging.h > --- a/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:03 2011 +0200 > +++ b/tools/xenpaging/xenpaging.h Fri Jun 10 10:47:05 2011 +0200 > @@ -36,6 +36,7 @@ > > typedef struct xenpaging { > xc_interface *xc_handle; > + struct xs_handle *xs_handle; > > xc_platform_info_t *platform_info; > xc_domaininfo_t *domain_info; > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-20 09:57 UTC
[Xen-devel] [PATCH 11 of 22 v2] xenpaging: do not bounce p2mt back to the hypervisor
do not bounce p2mt back to the hypervisor because p2m_mem_paging_populate() and p2m_mem_paging_resume() dont make use of p2mt. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r 0f5b7a5a80ea tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Mon Jun 20 11:07:24 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Mon Jun 20 11:08:54 2011 +0200 @@ -694,7 +694,6 @@ int main(int argc, char *argv[]) /* Prepare the response */ rsp.gfn = req.gfn; - rsp.p2mt = req.p2mt; rsp.vcpu_id = req.vcpu_id; rsp.flags = req.flags; @@ -711,10 +710,8 @@ int main(int argc, char *argv[]) else { DPRINTF("page already populated (domain = %d; vcpu = %d;" - " p2mt = %x;" " gfn = %"PRIx64"; paused = %d)\n", paging->mem_event.domain_id, req.vcpu_id, - req.p2mt, req.gfn, req.flags & MEM_EVENT_FLAG_VCPU_PAUSED); /* Tell Xen to resume the vcpu */ @@ -723,7 +720,6 @@ int main(int argc, char *argv[]) { /* Prepare the response */ rsp.gfn = req.gfn; - rsp.p2mt = req.p2mt; rsp.vcpu_id = req.vcpu_id; rsp.flags = req.flags; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-20 09:58 UTC
[Xen-devel] [PATCH 03 of 22 v2] xenpaging: add xs_handle to struct xenpaging
A xs_handle is currently used in the xc_mem_paging_flush_ioemu_cache() function and will be used by a subsequent patch. Add it to struct xenpaging. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r f22ff6847990 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Mon Jun 20 10:58:38 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Mon Jun 20 11:06:21 2011 +0200 @@ -28,6 +28,7 @@ #include <signal.h> #include <unistd.h> #include <xc_private.h> +#include <xs.h> #include <xen/mem_event.h> @@ -92,6 +93,14 @@ static xenpaging_t *xenpaging_init(domid paging = malloc(sizeof(xenpaging_t)); memset(paging, 0, sizeof(xenpaging_t)); + /* Open connection to xenstore */ + paging->xs_handle = xs_open(0); + if ( paging->xs_handle == NULL ) + { + ERROR("Error initialising xenstore connection"); + goto err; + } + p = getenv("XENPAGING_POLICY_MRU_SIZE"); if ( p && *p ) { @@ -221,6 +230,8 @@ static xenpaging_t *xenpaging_init(domid err: if ( paging ) { + if ( paging->xs_handle ) + xs_close(paging->xs_handle); xc_interface_close(xch); if ( paging->mem_event.shared_page ) { @@ -277,6 +288,9 @@ static int xenpaging_teardown(xenpaging_ } paging->mem_event.xce_handle = NULL; + /* Close connection to xenstore */ + xs_daemon_close(paging->xs_handle); + /* Close connection to Xen */ rc = xc_interface_close(xch); if ( rc != 0 ) diff -r f22ff6847990 tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Mon Jun 20 10:58:38 2011 +0200 +++ b/tools/xenpaging/xenpaging.h Mon Jun 20 11:06:21 2011 +0200 @@ -36,6 +36,7 @@ typedef struct xenpaging { xc_interface *xc_handle; + struct xs_handle *xs_handle; xc_platform_info_t *platform_info; xc_domaininfo_t *domain_info; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Tim Deegan
2011-Jun-20 10:36 UTC
Re: [Xen-devel] [PATCH 11 of 22 v2] xenpaging: do not bounce p2mt back to the hypervisor
At 11:57 +0200 on 20 Jun (1308571045), Olaf Hering wrote:> do not bounce p2mt back to the hypervisor because p2m_mem_paging_populate() > and p2m_mem_paging_resume() dont make use of p2mt. > > Signed-off-by: Olaf Hering <olaf@aepfle.de>Acked-by: Tim Deegan <Tim.Deegan@citrix.com>> diff -r 0f5b7a5a80ea tools/xenpaging/xenpaging.c > --- a/tools/xenpaging/xenpaging.c Mon Jun 20 11:07:24 2011 +0200 > +++ b/tools/xenpaging/xenpaging.c Mon Jun 20 11:08:54 2011 +0200 > @@ -694,7 +694,6 @@ int main(int argc, char *argv[]) > > /* Prepare the response */ > rsp.gfn = req.gfn; > - rsp.p2mt = req.p2mt; > rsp.vcpu_id = req.vcpu_id; > rsp.flags = req.flags; > > @@ -711,10 +710,8 @@ int main(int argc, char *argv[]) > else > { > DPRINTF("page already populated (domain = %d; vcpu = %d;" > - " p2mt = %x;" > " gfn = %"PRIx64"; paused = %d)\n", > paging->mem_event.domain_id, req.vcpu_id, > - req.p2mt, > req.gfn, req.flags & MEM_EVENT_FLAG_VCPU_PAUSED); > > /* Tell Xen to resume the vcpu */ > @@ -723,7 +720,6 @@ int main(int argc, char *argv[]) > { > /* Prepare the response */ > rsp.gfn = req.gfn; > - rsp.p2mt = req.p2mt; > rsp.vcpu_id = req.vcpu_id; > rsp.flags = req.flags; > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel-- Tim Deegan <Tim.Deegan@citrix.com> Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jun-21 13:17 UTC
[Xen-devel] Re: [PATCH 03 of 22 v2] xenpaging: add xs_handle to struct xenpaging
On Mon, 2011-06-20 at 10:58 +0100, Olaf Hering wrote:> A xs_handle is currently used in the xc_mem_paging_flush_ioemu_cache() > function and will be used by a subsequent patch. > Add it to struct xenpaging. > > Signed-off-by: Olaf Hering <olaf@aepfle.de>Looks good. Only one quibble...> @@ -277,6 +288,9 @@ static int xenpaging_teardown(xenpaging_ > } > paging->mem_event.xce_handle = NULL; > > + /* Close connection to xenstore */ > + xs_daemon_close(paging->xs_handle); > +...xs_close() please. Other than that: Acked-by: Ian Campbell <ian.campbell@citrix.com> Cheers, Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-21 15:33 UTC
[Xen-devel] [PATCH 03 of 22 v3] xenpaging: add xs_handle to struct xenpaging
A xs_handle is currently used in the xc_mem_paging_flush_ioemu_cache() function and will be used by a subsequent patch. Add it to struct xenpaging. Signed-off-by: Olaf Hering <olaf@aepfle.de> Acked-by: Ian Campbell <ian.campbell@citrix.com> diff -r 2faf6e491708 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Tue Jun 21 17:28:56 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Tue Jun 21 17:31:33 2011 +0200 @@ -28,6 +28,7 @@ #include <signal.h> #include <unistd.h> #include <xc_private.h> +#include <xs.h> #include <xen/mem_event.h> @@ -92,6 +93,14 @@ static xenpaging_t *xenpaging_init(domid paging = malloc(sizeof(xenpaging_t)); memset(paging, 0, sizeof(xenpaging_t)); + /* Open connection to xenstore */ + paging->xs_handle = xs_open(0); + if ( paging->xs_handle == NULL ) + { + ERROR("Error initialising xenstore connection"); + goto err; + } + p = getenv("XENPAGING_POLICY_MRU_SIZE"); if ( p && *p ) { @@ -221,6 +230,8 @@ static xenpaging_t *xenpaging_init(domid err: if ( paging ) { + if ( paging->xs_handle ) + xs_close(paging->xs_handle); xc_interface_close(xch); if ( paging->mem_event.shared_page ) { @@ -277,6 +288,9 @@ static int xenpaging_teardown(xenpaging_ } paging->mem_event.xce_handle = NULL; + /* Close connection to xenstore */ + xs_close(paging->xs_handle); + /* Close connection to Xen */ rc = xc_interface_close(xch); if ( rc != 0 ) diff -r 2faf6e491708 tools/xenpaging/xenpaging.h --- a/tools/xenpaging/xenpaging.h Tue Jun 21 17:28:56 2011 +0200 +++ b/tools/xenpaging/xenpaging.h Tue Jun 21 17:31:33 2011 +0200 @@ -36,6 +36,7 @@ typedef struct xenpaging { xc_interface *xc_handle; + struct xs_handle *xs_handle; xc_platform_info_t *platform_info; xc_domaininfo_t *domain_info; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jun-21 16:16 UTC
Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
Olaf Hering writes ("[Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h"):> tools: merge several bitop functions into xc_bitops.hThis seems to break the stubdom build, I'm afraid. make libs make[3]: Entering directory `/u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32' gcc -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/../extras/mini-os/include -D__MINIOS__ -DHAVE_LIBC -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/../extras/mini-os/include/posix -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/../tools/xenstore -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/../extras/mini-os/include/x86 -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/../extras/mini-os/include/x86/x86_32 -U __linux__ -U __FreeBSD__ -U __sun__ -nostdinc -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/../extras/mini-os/include/posix -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/cross-root-i686/i686-xen-elf/include -isystem /usr/lib/gcc/i486-linux-gnu/4.3.2/include -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/lwip-x86_32/src/include -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/lwip-x86_32/src/include/ipv4 -I/u/iwj/work/xen-unstable-tools.hg/stubdom/include -I/u/iwj/work/xen-unstable-tools.hg/stubdom/../xen/include -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../extras/mini-os/include -D__MINIOS__ -DHAVE_LIBC -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../extras/mini-os/include/posix -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../tools/xenstore -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../extras/mini-os/include/x86 -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../extras/mini-os/include/x86/x86_32 -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../extras/mini-os/include -D__MINIOS__ -DHAVE_LIBC -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../extras/mini-os/include/posix -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../tools/xenstore -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../extras/mini-os/include/x86 -isystem /u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../extras/mini-os/include/x86/x86_32 -O1 -fno-omit-frame-pointer -m32 -march=i686 -m32 -march=i686 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -fno-stack-protector -fno-exceptions -O1 -fno-omit-frame-pointer -m32 -march=i686 -m32 -march=i686 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -D__XEN_TOOLS__ -MMD -MF .build.d -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls -mno-tls-direct-seg-refs -I../../xen/common/libelf -Werror -Wmissing-prototypes -I. -I/u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../tools/include -O1 -fno-omit-frame-pointer -m32 -march=i686 -m32 -march=i686 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -D__XEN_TOOLS__ -MMD -MF .xc_domain_save.o.d -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls -mno-tls-direct-seg-refs -I../../xen/common/libelf -Werror -Wmissing-prototypes -I. -I/u/iwj/work/xen-unstable-tools.hg/stubdom/libxc-x86_32/../../tools/include -c -o xc_domain_save.o xc_domain_save.c xc_domain_save.c:30:23: error: xc_bitops.h: No such file or directory cc1: warnings being treated as errors xc_domain_save.c: In function 'xc_domain_save': xc_domain_save.c:927: error: implicit declaration of function 'bitmap_size' xc_domain_save.c:1077: error: implicit declaration of function 'test_bit' xc_domain_save.c:1090: error: 'ORDER_LONG' undeclared (first use in this function) xc_domain_save.c:1090: error: (Each undeclared identifier is reported only once xc_domain_save.c:1090: error: for each function it appears in.) xc_domain_save.c:1093: error: 'BITS_PER_LONG' undeclared (first use in this function) xc_domain_save.c:1150: error: implicit declaration of function 'set_bit' xc_domain_save.c:1163: error: implicit declaration of function 'clear_bit' make[3]: *** [xc_domain_save.o] Error 1 Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-21 16:20 UTC
Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
On Tue, Jun 21, Ian Jackson wrote:> Olaf Hering writes ("[Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h"): > > tools: merge several bitop functions into xc_bitops.h > > This seems to break the stubdom build, I''m afraid.Sorry for that. What is the command to reproduce this error? Olaf _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jun-21 16:24 UTC
Re: [Xen-devel] [PATCH 01 of 22] xenpaging: remove unused spinlock in pager
Olaf Hering writes ("[Xen-devel] [PATCH 01 of 22] xenpaging: remove unused spinlock in pager"):> xenpaging: remove unused spinlock in pagerI have applied this one. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jun-21 16:25 UTC
Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
Olaf Hering writes ("Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h"):> On Tue, Jun 21, Ian Jackson wrote: > > Olaf Hering writes ("[Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h"): > > > tools: merge several bitop functions into xc_bitops.h > > > > This seems to break the stubdom build, I''m afraid. > > Sorry for that. > What is the command to reproduce this error?I always run this: (make -j4 && echo ok.) 2>&1 | tee ../log but simply "make" should do it if you don''t have stubdom builds turned off. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Olaf Hering
2011-Jun-21 17:17 UTC
Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
On Tue, Jun 21, Ian Jackson wrote:> Olaf Hering writes ("[Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h"): > > tools: merge several bitop functions into xc_bitops.h > > This seems to break the stubdom build, I''m afraid.> xc_domain_save.c:30:23: error: xc_bitops.h: No such file or directory(I just ran ''make tools'' to verify my changes, not make or ''make stubdom'') Why are the symlinks not updated? I can not reproduce the failure in a fresh build. xc_domain_save.c references other files like xc_private.h in the same directory. So I think the bug is not strictly in my change, but may point to some other bug. Maybe its related to the issue I ran often while working on this series: Repeated hg qpush/qpop with a patch that adds a new header or removes an existing one, does not update the .*.d file. As a result, make fails because there is ''no rule to make target foo.h''. The only way is to do a make clean in these directories to remove the .*.d files. ... time passes. ... I can reproduce it now with a fresh build without patches, then apply just this patch and run make again. First tools/xenpaging/ fails because there is now ''no rule to make target bitops.h''. A ''rm tools/xenpaging/.*.d ; make'' fixes it. Now it fails as you describe. Olaf _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jun-21 17:18 UTC
Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
Olaf Hering writes ("Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h"):> First tools/xenpaging/ fails because there is now ''no rule to make > target bitops.h''. A ''rm tools/xenpaging/.*.d ; make'' fixes it. > Now it fails as you describe.Urgh. Sorry about that. I will do a thorough clean of my tree and try again. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Jun-22 14:03 UTC
Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
I wrote:> Olaf Hering writes ("Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h"): > > First tools/xenpaging/ fails because there is now ''no rule to make > > target bitops.h''. A ''rm tools/xenpaging/.*.d ; make'' fixes it. > > Now it fails as you describe. > > Urgh. Sorry about that. I will do a thorough clean of my tree and > try again.That worked. I have applied and pushed the remaining 21 patches. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel