static u32 ns_to_micros(u64 count) { if (count > ((u64)0xffffffff * 1000)) { count = (u64)0xffffffff * 1000; } return (u32)vmm_udiv64(count, 1000); }
static int printi(char **out, struct vmm_chardev *cdev, long long i, int b, int sg, int width, int pad, int letbase) { char print_buf[PRINT_BUF_LEN]; char *s; int t, neg = 0, pc = 0; unsigned long long u = i; if (i == 0) { print_buf[0] = '0'; print_buf[1] = '\0'; return prints(out, cdev, print_buf, width, pad); } if (sg && b == 10 && i < 0) { neg = 1; u = -i; } s = print_buf + PRINT_BUF_LEN - 1; *s = '\0'; while (u) { t = vmm_umod64(u, b); if (t >= 10) t += letbase - '0' - 10; *--s = t + '0'; u = vmm_udiv64(u, b); } if (neg) { if (width && (pad & PAD_ZERO)) { printc(out, cdev, '-'); ++pc; --width; } else { *--s = '-'; } } return pc + prints(out, cdev, s, width, pad); }
static int cmd_profile_count_iterator(void *data, const char *name, unsigned long addr) { struct count_record *ptr = data; u32 index = kallsyms_get_symbol_pos(addr, NULL, NULL); u32 count = vmm_profiler_get_function_count(addr); u64 time = vmm_profiler_get_function_total_time(addr); ptr += index; /* It would be nice to have the strncpy variant */ vmm_strcpy(ptr->function_name, name); ptr->function_name[39] = 0; ptr->count = count; ptr->total_time = time; if (count) { ptr->time_per_call = vmm_udiv64(time, (u64)count); } return VMM_OK; }
void arch_vcpu_stat_dump(struct vmm_vcpu * vcpu) { #ifdef CONFIG_ARM32_FUNCSTATS int index; if (!vcpu || !arm_priv(vcpu)) { return; } vmm_printf("%-30s %-10s %s\n", "Function Name","Time/Call", "# Calls"); for (index=0; index < ARM_FUNCSTAT_MAX; index++) { if (arm_priv(vcpu)->funcstat[index].exit_count) { vmm_printf("%-30s %-10u %u\n", arm_priv(vcpu)->funcstat[index].function_name, (u32)vmm_udiv64(arm_priv(vcpu)->funcstat[index].time, arm_priv(vcpu)->funcstat[index].exit_count), arm_priv(vcpu)->funcstat[index].exit_count); } } #else vmm_printf("Not selected in Xvisor config\n"); #endif }