X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fsym_swap.c;h=d6740c40fca0dc3c65772d0829cea9f73a34bcdf;hb=28cfe68985ef4360c9bd7428a19c222b295e9d85;hp=35b46cc0c65306e31f62244e07f35e120a3c0520;hpb=6fe9fe338ec19b212b43bb2c25322dce3cdbb490;p=palacios.git diff --git a/palacios/src/devices/sym_swap.c b/palacios/src/devices/sym_swap.c index 35b46cc..d6740c4 100644 --- a/palacios/src/devices/sym_swap.c +++ b/palacios/src/devices/sym_swap.c @@ -24,6 +24,9 @@ #define SWAP_CAPACITY (150 * 1024 * 1024) +#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY +#include +#endif /* This is the first page that linux writes to the swap area */ @@ -60,6 +63,12 @@ struct swap_state { union swap_header * hdr; +#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY + uint32_t pages_in; + uint32_t pages_out; +#endif + + uint64_t capacity; uint8_t * swap_space; addr_t swap_base_addr; @@ -107,12 +116,12 @@ static inline void * get_swap_entry(uint32_t pg_index, void * private_data) { struct vm_device * dev = (struct vm_device *)private_data; struct swap_state * swap = (struct swap_state *)(dev->private_data); void * pg_addr = NULL; - int ret = 0; + // int ret = 0; - if ((ret = get_index_usage(swap, pg_index))) { - // CAREFUL: The index might be offset by 1, because the first 4K is the header - pg_addr = (void *)(swap->swap_space + (pg_index * 4096)); - } + // if ((ret = get_index_usage(swap, pg_index))) { + // CAREFUL: The index might be offset by 1, because the first 4K is the header + pg_addr = (void *)(swap->swap_space + (pg_index * 4096)); + // } return pg_addr; } @@ -158,7 +167,11 @@ static int swap_read(uint8_t * buf, int sector_count, uint64_t lba, void * priv if ((swap->active == 1) && (offset != 0)) { int i = 0; // Notify the shadow paging layer - PrintDebug("Swapped in %d pages\n", length / 4096); + +#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY + swap->pages_in += length / 4096; +#endif + for (i = 0; i < length; i += 4096) { set_index_usage(swap, get_swap_index_from_offset(offset + i), 0); v3_swap_in_notify(dev->vm, get_swap_index_from_offset(offset + i), swap->hdr->info.type); @@ -210,7 +223,10 @@ static int swap_write(uint8_t * buf, int sector_count, uint64_t lba, void * priv if ((swap->active == 1) && (offset != 0)) { int i = 0; - PrintDebug("Swapped out %d pages\n", length / 4096); + +#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY + swap->pages_out += length / 4096; +#endif for (i = 0; i < length; i += 4096) { set_index_usage(swap, get_swap_index_from_offset(offset + i), 1); @@ -242,6 +258,18 @@ static struct v3_device_ops dev_ops = { }; +#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY +static void telemetry_cb(struct guest_info * info, void * private_data, char * hdr) { + struct vm_device * dev = (struct vm_device *)private_data; + struct swap_state * swap = (struct swap_state *)(dev->private_data); + + V3_Print("%sSwap Device:\n", hdr); + V3_Print("%s\tPages Swapped in=%d\n", hdr, swap->pages_in); + V3_Print("%s\tPages Swapped out=%d\n", hdr, swap->pages_out); + +} +#endif + @@ -290,6 +318,12 @@ static int swap_init(struct guest_info * vm, void * cfg_data) { v3_virtio_register_harddisk(virtio_blk, &hd_ops, dev); +#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY + if (vm->enable_telemetry) { + v3_add_telemetry_cb(vm, telemetry_cb, dev); + } +#endif + return 0; }