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
uint32_t invoke_cnt;
uint64_t granularity;
+
struct list_head cb_list;
};
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
#define SWAP_CAPACITY (150 * 1024 * 1024)
+#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY
+#include <palacios/vmm_telemetry.h>
+#endif
/* This is the first page that linux writes to the swap area */
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;
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);
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);
};
+#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
+
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;
}
}
#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);
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;
#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
#include <palacios/vmm_telemetry.h>
#include <palacios/svm_handler.h>
#include <palacios/vmm_rbtree.h>
+#include <palacios/vmm_sprintf.h>
#ifdef CONFIG_TELEMETRY_GRANULARITY
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;
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));
}
+
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
{
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)));
}
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);
}
}