xenpaging and libxc fixes for xen-unstable
PATCH 1/1 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(-)
PATCH 1/1 xenpaging: remove unused spinlock in pager
# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/mem_event.h +0 -5
@@ -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;
tools/xenpaging/spinlock.h deleted +0 -69
69 lines not on this page · raw message
tools/xenpaging/xenpaging.c +0 -12
@@ -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(domidBACK_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 *memmem_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 ; }
tools/xenpaging/xenpaging.h +0 -1
@@ -25,7 +25,6 @@#define __XEN_PAGING2_H__ -#include "spinlock.h" #include "xc.h" #include <xc_private.h>
Re: [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"):
Quoted 1 line
xenpaging: remove unused spinlock in pager
I have applied this one.
Ian.
PATCH 1/1 tools: merge several bitop functions into xc_bitops.h
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/blktap2/drivers/block-log.c +3 -26
@@ -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 ; }
tools/libxc/ia64/xc_ia64_linux_restore.c +6 -8
@@ -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))
tools/libxc/ia64/xc_ia64_linux_save.c +7 -22
@@ -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 *xcchar *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))
tools/libxc/ia64/xc_ia64_save_restore.h +0 -20
@@ -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 */
tools/libxc/xc_bitops.h new file +57 -0
57 lines not on this page · raw message
tools/libxc/xc_domain_save.c +8 -58
102 lines not on this page · raw message
tools/xenpaging/bitops.h deleted +0 -448
448 lines not on this page · raw message
tools/xenpaging/policy_default.c +7 -13
@@ -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; }
tools/xenpaging/xc.c +0 -14
@@ -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) {
tools/xenpaging/xc.h +0 -2
@@ -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);
tools/xenpaging/xenpaging.c +3 -6
@@ -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;
tools/xenpaging/xenpaging.h +0 -1
@@ -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;
Re: [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"):
Quoted 1 line
tools: merge several bitop functions into
xc_bitops.h
This 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 errorsxc_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
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
Quoted 4 lines · Ian Jackson
Olaf Hering writes ("[Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into
xc_bitops.h"):Quoted 1 line
tools: merge several bitop functions into
xc_bitops.hThis seems to break the stubdom build, I'm afraid.
Sorry for that.
What is the command to reproduce this error?
Olaf
Re: [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"):
Quoted 8 lines · Ian Jackson
Quoted 4 lines
Olaf Hering writes ("[Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into
xc_bitops.h"):Quoted 1 line
tools: merge several bitop functions into
xc_bitops.hThis 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.
Re: [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
In reply to Ian JacksonQuoted 6 lines · Ian Jackson
Olaf Hering writes ("[Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into
xc_bitops.h"):Quoted 1 line
tools: merge several bitop functions into
xc_bitops.hThis 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
Re: [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"):
Quoted 3 lines
First
tools/xenpaging/fails because there is now 'no rule to make targetbitops.h'. A 'rmtools/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.
Re: [PATCH 02 of 22] tools: merge several bitop functions into xc_bitops.h
Quoted 7 lines · I wrote:
Olaf Hering writes ("Re: [Xen-devel] [PATCH 02 of 22] tools: merge several bitop functions into
xc_bitops.h"):Quoted 3 lines
First
tools/xenpaging/fails because there is now 'no rule to make targetbitops.h'. A 'rmtools/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.
PATCH 1/1 xenpaging: add xs_handle to struct xenpaging
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xenpaging.c +14 -0
@@ -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 )
tools/xenpaging/xenpaging.h +1 -0
@@ -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;
Re: [PATCH 03 of 22] xenpaging: add xs_handle to struct xenpaging
Quoted 25 lines · Olaf Hering
# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1307695625 -7200
# Node ID2d2fe3e2bd73d0c257bb852ecb00052d0dcef301# Parent9476d85932e5eb8f1e7ce0a6814b6c0634341e61
xenpaging: addxs_handleto struct xenpagingA
xs_handleis currently used in thexc_mem_paging_flush_ioemu_cache()function and will be used by a subsequent patch.
Add it to struct xenpaging.Signed-off-by Olaf Hering <[email protected]>diff -r
9476d85932e5-r2d2fe3e2bd73tools/xenpaging/xenpaging.ctools/xenpaging/xenpaging.c +1
-0@@ -28,6 +28,7 @@#include <signal.h> #include <unistd.h> #include <xc_private.h> +#include <xs.h> #include <xen/mem_event.h>
tools/xenpaging/xenpaging.c static xenpaging_t *xenpaging_init(domid · line 97
Quoted 5 lines
tools/xenpaging/xenpaging.c +2
-0@@ -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).
Quoted 10 lines
tools/xenpaging/xenpaging.c +6
-0+if ( paging->xs_handle ==NULL ) + { +ERROR ("Error initialising xenstore connection" ); + goto err; + } + p =getenv ("XENPAGING_POLICY_MRU_SIZE" );if ( p && *p ) {
tools/xenpaging/xenpaging.c static xenpaging_t *xenpaging_init(domid · line 234
Quoted 5 lines
tools/xenpaging/xenpaging.c +2
-0@@ -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().
Quoted 29 lines
tools/xenpaging/xenpaging.c +3
-0xc_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-r2d2fe3e2bd73tools/xenpaging/xenpaging.htools/xenpaging/xenpaging.h +1
-0@@ -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
[email protected]
http://lists.xensource.com/xen-devel
PATCH v2 1/1 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.
tools/xenpaging/xenpaging.c +14 -0
@@ -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 )
tools/xenpaging/xenpaging.h +1 -0
@@ -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;
Re: [PATCH 03 of 22 v2] xenpaging: add xs_handle to struct xenpaging
Quoted 5 lines · Olaf Hering
A
xs_handleis currently used in thexc_mem_paging_flush_ioemu_cache()function and will be used by a subsequent patch.
Add it to struct xenpaging.Signed-off-by Olaf Hering <[email protected]>
Looks good. Only one quibble...
tools/xenpaging/xenpaging.c static int xenpaging_teardown(xenpaging_ · line 293
Quoted 7 lines
tools/xenpaging/xenpaging.c +3
-0@@ -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:
Cheers,
Ian.
PATCH v3 1/1 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.
tools/xenpaging/xenpaging.c +14 -0
@@ -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 )
tools/xenpaging/xenpaging.h +1 -0
@@ -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;
PATCH 1/1 xenpaging: drop xc.c, remove ASSERT
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1307695626 -7200
# Node ID 53623b8a03575e5e42a7e7d8eaf9020b4a3138f1 # Parent 2d2fe3e2bd73d0c257bb852ecb00052d0dcef301
xenpaging: drop xc.c, remove ASSERT
The ASSERT is not needed, victim is never NULL.
tools/xenpaging/policy_default.c +0 -1
@@ -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 {
tools/xenpaging/xc.h +0 -7
@@ -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
PATCH 1/1 xenpaging: drop xc.c, remove xc_platform_info_t
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xc.c +0 -10
@@ -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); -}/*
tools/xenpaging/xc.h +0 -8
@@ -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(domiint 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__
tools/xenpaging/xenpaging.c +0 -17
@@ -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); }
tools/xenpaging/xenpaging.h +0 -1
@@ -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;
PATCH 1/1 xenpaging: drop xc.c, remove xc_wait_for_event
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xc.c +0 -4
@@ -91,10 +91,6 @@ int xc_wait_for_event_or_timeout(xc_intereturn -errno; } -int xc_wait_for_event (xc_interface *xch,xc_evtchn *xce) -{ -return xc_wait_for_event_or_timeout (xch, xce,-1 ); -}
tools/xenpaging/xc.h +0 -1
@@ -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);
PATCH 1/1 xenpaging: drop xc.c, move xc_mem_paging_flush_ioemu_cache
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xc.c +0 -18
@@ -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) {
tools/xenpaging/xc.h +0 -1
@@ -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);
tools/xenpaging/xenpaging.c +15 -1
@@ -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 *pagelse {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" ); } }
PATCH 1/1 xenpaging: drop xc.c, move xc_wait_for_event_or_timeout
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xc.c +0 -40
@@ -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; -}
tools/xenpaging/xc.h +0 -1
@@ -37,7 +37,6 @@ -int xc_wait_for_event_or_timeout (xc_interface *xch,xc_evtchn *xce,unsigned long ms);
tools/xenpaging/xenpaging.c +45 -3
70 lines not on this page · raw message
PATCH 1/1 xenpaging: drop xc.c, remove xc files
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/Makefile +1 -1
@@ -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
tools/xenpaging/mem_event.h +0 -1
@@ -25,7 +25,6 @@#define __XEN_MEM_EVENT_H__ -#include "xc.h" #include <xc_private.h> #include <xen/event_channel.h>
tools/xenpaging/xc.c deleted +0 -47
47 lines not on this page · raw message
tools/xenpaging/xc.h deleted +0 -54
54 lines not on this page · raw message
tools/xenpaging/xenpaging.c +0 -1
@@ -35,7 +35,6 @@#include "xc_bitops.h" #include "file_ops.h" -#include "xc.h" #include "policy.h" #include "xenpaging.h"
tools/xenpaging/xenpaging.h +0 -1
@@ -25,7 +25,6 @@#define __XEN_PAGING2_H__ -#include "xc.h" #include <xc_private.h> #include <xen/event_channel.h>
PATCH 1/1 xenpaging: correct dropping of pages to avoid full ring buffer
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xenpaging.c +11 -11
@@ -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 */
PATCH 1/1 xenpaging: do not bounce p2mt to xenpaging
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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
tools/xenpaging/xenpaging.c +0 -4
@@ -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/arch/x86/mm/p2m.c +0 -1
@@ -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);
Re: [PATCH 11 of 22] xenpaging: do not bounce p2mt to xenpaging
xen/arch/x86/mm/p2m.c void p2m_mem_paging_populate(struct doma · line 778
Quoted 11 lines · Olaf Hering
diff -r
1de8de108d15-r17c9aa11b28axen/arch/x86/mm/p2m.cxen/arch/x86/mm/p2m.c +0
-1@@ -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.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
PATCH v2 1/1 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.
tools/xenpaging/xenpaging.c +0 -4
@@ -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;
Re: [PATCH 11 of 22 v2] xenpaging: do not bounce p2mt back to the hypervisor
Quoted 4 lines · Olaf Hering
do not bounce p2mt back to the hypervisor because
p2m_mem_paging_populate()andp2m_mem_paging_resume()dont make use of p2mt.Signed-off-by Olaf Hering <[email protected]>
Quoted 35 lines
diff -r
0f5b7a5a80eatools/xenpaging/xenpaging.ctools/xenpaging/xenpaging.c +0
-4@@ -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
[email protected]
http://lists.xensource.com/xen-devel
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
PATCH 1/1 xenpaging: remove srand call
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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().
tools/xenpaging/xenpaging.c +0 -3
@@ -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 )
PATCH 1/1 xenpaging: remove return values from functions that can not fail
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xenpaging.c +4 -15
@@ -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(xenpagiint 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) )
PATCH 1/1 xenpaging: catch xc_mem_paging_resume errors
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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()
tools/xenpaging/xenpaging.c +3 -2
@@ -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;
PATCH 1/1 xenpaging: remove local domain_id variable
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xenpaging.c +3 -5
@@ -552,7 +552,6 @@ static int evict_victim(xenpaging_t *pagint 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 ) {
PATCH 1/1 xenpaging: move num_pages into xenpaging struct
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xenpaging.c +14 -16
@@ -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 *pagint 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;
tools/xenpaging/xenpaging.h +1 -0
@@ -42,6 +42,7 @@ typedef struct xenpaging {unsigned long *bitmap;mem_event_t mem_event; +int num_pages;int policy_mru_size; } xenpaging_t;
PATCH 1/1 xenpaging: start paging in the middle of gfn range
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/policy_default.c +4 -0
@@ -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;
PATCH 1/1 xenpaging: pass integer to xenpaging_populate_page
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xenpaging.c +6 -10
@@ -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" );
PATCH 1/1 xenpaging: add helper function for unlinking pagefile
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xenpaging.c +12 -2
@@ -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 */
PATCH 1/1 xenpaging: add watch thread to catch guest shutdown
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/xenpaging.c +38 -2
@@ -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_treturn -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 ) {
PATCH 1/1 xenpaging: implement stopping of pager by sending SIGTERM/SIGINT
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/Makefile +1 -0
@@ -8,6 +8,7 @@ POLICY = default SRC := SRCS += file_ops.c xenpaging.c policy_$(POLICY).c +SRCS += pagein.c CFLAGS += -Werror CFLAGS += -Wno-unused
tools/xenpaging/pagein.c new file +68 -0
68 lines not on this page · raw message
tools/xenpaging/xenpaging.c +32 -3
@@ -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);
tools/xenpaging/xenpaging.h +3 -0
@@ -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__
PATCH 1/1 xenpaging: remove private mem_event.h
In reply to Olaf Hering# HG changeset patch
# User Olaf Hering <[email protected]>
# 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.
tools/xenpaging/mem_event.h deleted +0 -57
@@ -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: -*/
tools/xenpaging/xenpaging.c +0 -3
@@ -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"
tools/xenpaging/xenpaging.h +8 -3
@@ -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;