From: Jack Lange Date: Mon, 24 Aug 2009 22:46:22 +0000 (-0500) Subject: telemetry updates X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=1786dcbd1b5a05d2591556db17bff62465713ee1;p=palacios.git telemetry updates --- diff --git a/palacios/include/palacios/vmm_sprintf.h b/palacios/include/palacios/vmm_sprintf.h index dbba4fa..df8ac6f 100644 --- a/palacios/include/palacios/vmm_sprintf.h +++ b/palacios/include/palacios/vmm_sprintf.h @@ -26,10 +26,10 @@ int sprintf(char *buf, const char *cfmt, ...); // __attribute__ ((format (printf, 1, 2))); -int vsprintf(char *buf, const char *cfmt, va_list ap); +//int vsprintf(char *buf, const char * cfmt, va_list ap); int snprintf(char *str, size_t size, const char * fmt, ...); -int vsnprintf(char *str, size_t size, const char * fmt, va_list ap); -int vsnrprintf(char *str, size_t size, int radix, const char * fmt, va_list ap); +//int vsnprintf(char *str, size_t size, const char * fmt, va_list ap); +//int vsnrprintf(char *str, size_t size, int radix, const char * fmt, va_list ap); #define HD_COLUMN_MASK 0xff #define HD_DELIM_MASK 0xff00 diff --git a/palacios/include/palacios/vmm_telemetry.h b/palacios/include/palacios/vmm_telemetry.h index 80ac874..084d90b 100644 --- a/palacios/include/palacios/vmm_telemetry.h +++ b/palacios/include/palacios/vmm_telemetry.h @@ -41,6 +41,7 @@ struct v3_telemetry_state { uint32_t invoke_cnt; uint64_t granularity; + struct list_head cb_list; }; @@ -54,8 +55,8 @@ void v3_print_telemetry(struct guest_info * info); void v3_add_telemetry_cb(struct guest_info * info, - void (*telemetry_fn)(struct guest_info * info, void * private_data), - void * private_data); + void (*telemetry_fn)(struct guest_info * info, void * private_data, char * hdr), + void * private_data); #endif diff --git a/palacios/src/devices/sym_swap.c b/palacios/src/devices/sym_swap.c index 35b46cc..4b7270d 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; @@ -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; } diff --git a/palacios/src/palacios/vmm_shadow_paging_32.h b/palacios/src/palacios/vmm_shadow_paging_32.h index b6ac424..a48c50b 100644 --- a/palacios/src/palacios/vmm_shadow_paging_32.h +++ b/palacios/src/palacios/vmm_shadow_paging_32.h @@ -240,7 +240,8 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault } #endif if (error_code.write == 0) { - PrintError("Page fault on swapped out page (pte=%x) (error_code=%x)\n", *(uint32_t *)guest_pte, *(uint32_t *)&error_code); + V3_Print("Page fault on swapped out page (vaddr=%p) (pte=%x) (error_code=%x)\n", + (void *)fault_addr, *(uint32_t *)guest_pte, *(uint32_t *)&error_code); addr_t swp_pg_addr = v3_get_swapped_pg_addr(info, shadow_pte, guest_pte); @@ -259,7 +260,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault shadow_pte->accessed = 1; shadow_pte->writable = 0; - if (fault_addr & 0xc0000000) { + if ((fault_addr & 0xc0000000) == 0xc0000000) { shadow_pte->user_page = 0; } else { shadow_pte->user_page = 1; diff --git a/palacios/src/palacios/vmm_sym_swap.c b/palacios/src/palacios/vmm_sym_swap.c index 1650c4e..67a245b 100644 --- a/palacios/src/palacios/vmm_sym_swap.c +++ b/palacios/src/palacios/vmm_sym_swap.c @@ -70,13 +70,13 @@ static inline uint32_t get_dev_index(pte32_t * pte) { #ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY -static void telemetry_cb(struct guest_info * info, void * private_data) { +static void telemetry_cb(struct guest_info * info, void * private_data, char * hdr) { struct v3_sym_swap_state * swap_state = &(info->swap_state); - V3_Print("Symbiotic Swap:\n"); - V3_Print("\tRead faults=%d\n", swap_state->read_faults); - V3_Print("\tWrite faults=%d\n", swap_state->write_faults); - V3_Print("\tFlushes=%d\n", swap_state->flushes); + V3_Print("%sSymbiotic Swap:\n", hdr); + V3_Print("%s\tRead faults=%d\n", hdr, swap_state->read_faults); + V3_Print("%s\tWrite faults=%d\n", hdr, swap_state->write_faults); + V3_Print("%s\tFlushes=%d\n", hdr, swap_state->flushes); } #endif diff --git a/palacios/src/palacios/vmm_telemetry.c b/palacios/src/palacios/vmm_telemetry.c index e69af85..4a419a2 100644 --- a/palacios/src/palacios/vmm_telemetry.c +++ b/palacios/src/palacios/vmm_telemetry.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef CONFIG_TELEMETRY_GRANULARITY @@ -33,7 +34,7 @@ struct telemetry_cb { - void (*telemetry_fn)(struct guest_info * info, void * private_data); + void (*telemetry_fn)(struct guest_info * info, void * private_data, char * hdr); void * private_data; struct list_head cb_node; @@ -168,8 +169,8 @@ void v3_telemetry_end_exit(struct guest_info * info, uint_t exit_code) { void v3_add_telemetry_cb(struct guest_info * info, - void (*telemetry_fn)(struct guest_info * info, void * private_data), - void * private_data) { + void (*telemetry_fn)(struct guest_info * info, void * private_data, char * hdr), + void * private_data) { struct v3_telemetry_state * telemetry = &(info->telemetry); struct telemetry_cb * cb = (struct telemetry_cb *)V3_Malloc(sizeof(struct telemetry_cb)); @@ -180,14 +181,17 @@ void v3_add_telemetry_cb(struct guest_info * info, } + void v3_print_telemetry(struct guest_info * info) { struct v3_telemetry_state * telemetry = &(info->telemetry); uint64_t invoke_tsc = 0; + char hdr_buf[32]; rdtscll(invoke_tsc); - V3_Print("Telemetry (%d)\n", telemetry->invoke_cnt++); - V3_Print("\ttelemetry window tsc cnt: %d\n", (uint32_t)(invoke_tsc - telemetry->prev_tsc)); + snprintf(hdr_buf, 32, "telem.%d>", telemetry->invoke_cnt++); + + V3_Print("%stelemetry window tsc cnt: %d\n", hdr_buf, (uint32_t)(invoke_tsc - telemetry->prev_tsc)); // Exit Telemetry { @@ -198,13 +202,13 @@ void v3_print_telemetry(struct guest_info * info) { evt = rb_entry(node, struct exit_event, tree_node); const char * code_str = vmexit_code_to_str(evt->exit_code); - V3_Print("%s:%sCnt=%u,%sAvg. Time=%u\n", - code_str, - (strlen(code_str) > 14) ? "\t" : "\t\t", - evt->cnt, - (evt->cnt >= 100) ? "\t" : "\t\t", - (uint32_t)(evt->handler_time / evt->cnt)); - + V3_Print("%s%s:%sCnt=%u,%sAvg. Time=%u\n", + hdr_buf, + code_str, + (strlen(code_str) > 14) ? "\t" : "\t\t", + evt->cnt, + (evt->cnt >= 100) ? "\t" : "\t\t", + (uint32_t)(evt->handler_time / evt->cnt)); } while ((node = v3_rb_next(node))); } @@ -214,7 +218,7 @@ void v3_print_telemetry(struct guest_info * info) { struct telemetry_cb * cb = NULL; list_for_each_entry(cb, &(telemetry->cb_list), cb_node) { - cb->telemetry_fn(info, cb->private_data); + cb->telemetry_fn(info, cb->private_data, hdr_buf); } }