Loading tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c +9 −11 Original line number Diff line number Diff line Loading @@ -236,10 +236,9 @@ static int amd_fam14h_start(void) int num, cpu; clock_gettime(CLOCK_REALTIME, &start_time); for (num = 0; num < AMD_FAM14H_STATE_NUM; num++) { for (cpu = 0; cpu < cpu_count; cpu++) { for (cpu = 0; cpu < cpu_count; cpu++) amd_fam14h_init(&amd_fam14h_cstates[num], cpu); } } #ifdef DEBUG clock_gettime(CLOCK_REALTIME, &dbg_time); dbg_timediff = timespec_diff_us(start_time, dbg_time); Loading @@ -257,10 +256,9 @@ static int amd_fam14h_stop(void) clock_gettime(CLOCK_REALTIME, &end_time); for (num = 0; num < AMD_FAM14H_STATE_NUM; num++) { for (cpu = 0; cpu < cpu_count; cpu++) { for (cpu = 0; cpu < cpu_count; cpu++) amd_fam14h_disable(&amd_fam14h_cstates[num], cpu); } } #ifdef DEBUG clock_gettime(CLOCK_REALTIME, &dbg_time); dbg_timediff = timespec_diff_us(end_time, dbg_time); Loading @@ -281,8 +279,8 @@ static int is_nbp1_capable(void) return val & (1 << 31); } struct cpuidle_monitor* amd_fam14h_register(void) { struct cpuidle_monitor *amd_fam14h_register(void) { int num; if (cpupower_cpu_info.vendor != X86_VENDOR_AMD) Loading tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c +38 −27 Original line number Diff line number Diff line Loading @@ -55,7 +55,6 @@ static int cpuidle_start(void) dprint("CPU %d - State: %d - Val: %llu\n", cpu, state, previous_count[cpu][state]); } }; return 0; } Loading Loading @@ -84,33 +83,44 @@ void fix_up_intel_idle_driver_name(char *tmp, int num) /* fix up cpuidle name for intel idle driver */ if (!strncmp(tmp, "NHM-", 4)) { switch (num) { case 1: strcpy(tmp, "C1"); case 1: strcpy(tmp, "C1"); break; case 2: strcpy(tmp, "C3"); case 2: strcpy(tmp, "C3"); break; case 3: strcpy(tmp, "C6"); case 3: strcpy(tmp, "C6"); break; } } else if (!strncmp(tmp, "SNB-", 4)) { switch (num) { case 1: strcpy(tmp, "C1"); case 1: strcpy(tmp, "C1"); break; case 2: strcpy(tmp, "C3"); case 2: strcpy(tmp, "C3"); break; case 3: strcpy(tmp, "C6"); case 3: strcpy(tmp, "C6"); break; case 4: strcpy(tmp, "C7"); case 4: strcpy(tmp, "C7"); break; } } else if (!strncmp(tmp, "ATM-", 4)) { switch (num) { case 1: strcpy(tmp, "C1"); case 1: strcpy(tmp, "C1"); break; case 2: strcpy(tmp, "C2"); case 2: strcpy(tmp, "C2"); break; case 3: strcpy(tmp, "C4"); case 3: strcpy(tmp, "C4"); break; case 4: strcpy(tmp, "C6"); case 4: strcpy(tmp, "C6"); break; } } Loading Loading @@ -144,7 +154,8 @@ static struct cpuidle_monitor* cpuidle_register(void) cpuidle_cstates[num].range = RANGE_THREAD; cpuidle_cstates[num].id = num; cpuidle_cstates[num].get_count_percent = cpuidle_get_count_percent; cpuidle_cstates[num].get_count_percent = cpuidle_get_count_percent; }; /* Free this at program termination */ Loading tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c +33 −31 Original line number Diff line number Diff line Loading @@ -169,22 +169,20 @@ void print_results(int topology_depth, int cpu) if (s.get_count_percent) { ret = s.get_count_percent(s.id, &percent, cpu_top.core_info[cpu].cpu); if (ret) { if (ret) printf("******"); } else if (percent >= 100.0) else if (percent >= 100.0) printf("%6.1f", percent); else printf("%6.2f", percent); } else if (s.get_count) { } else if (s.get_count) { ret = s.get_count(s.id, &result, cpu_top.core_info[cpu].cpu); if (ret) { if (ret) printf("******"); } else else printf("%6llu", result); } else { } else { printf(_("Monitor %s, Counter %s has no count " "function. Implementation error\n"), monitors[mon]->name, s.name); Loading Loading @@ -244,18 +242,21 @@ static void parse_monitor_param(char* param) exit(EXIT_FAILURE); } /* Override detected/registerd monitors array with requested one */ memcpy(monitors, tmp_mons, sizeof(struct cpuidle_monitor*) * MONITORS_MAX); memcpy(monitors, tmp_mons, sizeof(struct cpuidle_monitor *) * MONITORS_MAX); avail_monitors = hits; } void list_monitors(void) { void list_monitors(void) { unsigned int mon; int state; cstate_t s; for (mon = 0; mon < avail_monitors; mon++) { printf(_("Monitor \"%s\" (%d states) - Might overflow after %u " "s\n"), monitors[mon]->name, monitors[mon]->hw_states_num, "s\n"), monitors[mon]->name, monitors[mon]->hw_states_num, monitors[mon]->overflow_s); for (state = 0; state < monitors[mon]->hw_states_num; state++) { Loading Loading @@ -308,7 +309,8 @@ int fork_it(char **argv) timediff = timespec_diff_us(start, end); if (WIFEXITED(status)) printf(_("%s took %.5f seconds and exited with status %d\n"), argv[0], timediff / (1000.0 * 1000), WEXITSTATUS(status)); argv[0], timediff / (1000.0 * 1000), WEXITSTATUS(status)); return 0; } Loading @@ -322,9 +324,9 @@ int do_interval_measure(int i) monitors[num]->start(); } sleep(i); for (num = 0; num < avail_monitors; num++) { for (num = 0; num < avail_monitors; num++) monitors[num]->stop(); } return 0; } Loading Loading @@ -438,9 +440,9 @@ int cmd_monitor(int argc, char **argv) print_results(1, cpu); } for (num = 0; num < avail_monitors; num++) { for (num = 0; num < avail_monitors; num++) monitors[num]->unregister(); } cpu_topology_release(cpu_top); return 0; } tools/power/cpupower/utils/idle_monitor/mperf_monitor.c +15 −18 Original line number Diff line number Diff line Loading @@ -145,8 +145,8 @@ static int mperf_get_count_percent(unsigned int id, double *percent, if (id == Cx) *percent = 100.0 - *percent; dprint("%s: previous: %llu - current: %llu - (%u)\n", mperf_cstates[id].name, mperf_diff, aperf_diff, cpu); dprint("%s: previous: %llu - current: %llu - (%u)\n", mperf_cstates[id].name, mperf_diff, aperf_diff, cpu); dprint("%s: %f\n", mperf_cstates[id].name, *percent); return 0; } Loading Loading @@ -206,8 +206,8 @@ static int mperf_stop(void) struct cpuidle_monitor mperf_monitor; struct cpuidle_monitor* mperf_register(void) { struct cpuidle_monitor *mperf_register(void) { unsigned long min; if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF)) Loading @@ -222,20 +222,17 @@ struct cpuidle_monitor* mperf_register(void) { /* Free this at program termination */ is_valid = calloc(cpu_count, sizeof(int)); mperf_previous_count = calloc (cpu_count, sizeof(unsigned long long)); aperf_previous_count = calloc (cpu_count, sizeof(unsigned long long)); mperf_current_count = calloc (cpu_count, sizeof(unsigned long long)); aperf_current_count = calloc (cpu_count, sizeof(unsigned long long)); mperf_previous_count = calloc(cpu_count, sizeof(unsigned long long)); aperf_previous_count = calloc(cpu_count, sizeof(unsigned long long)); mperf_current_count = calloc(cpu_count, sizeof(unsigned long long)); aperf_current_count = calloc(cpu_count, sizeof(unsigned long long)); mperf_monitor.name_len = strlen(mperf_monitor.name); return &mperf_monitor; } void mperf_unregister(void) { void mperf_unregister(void) { free(mperf_previous_count); free(aperf_previous_count); free(mperf_current_count); Loading tools/power/cpupower/utils/idle_monitor/nhm_idle.c +17 −13 Original line number Diff line number Diff line Loading @@ -69,7 +69,8 @@ static unsigned long long *current_count[NHM_CSTATE_COUNT]; /* valid flag for all CPUs. If a MSR read failed it will be zero */ static int *is_valid; static int nhm_get_count(enum intel_nhm_id id, unsigned long long *val, unsigned int cpu) static int nhm_get_count(enum intel_nhm_id id, unsigned long long *val, unsigned int cpu) { int msr; Loading Loading @@ -106,12 +107,13 @@ static int nhm_get_count_percent(unsigned int id, double *percent, if (!is_valid[cpu]) return -1; *percent = (100.0 * (current_count[id][cpu] - previous_count[id][cpu])) / *percent = (100.0 * (current_count[id][cpu] - previous_count[id][cpu])) / (tsc_at_measure_end - tsc_at_measure_start); dprint("%s: previous: %llu - current: %llu - (%u)\n", nhm_cstates[id].name, previous_count[id][cpu], current_count[id][cpu], cpu); dprint("%s: previous: %llu - current: %llu - (%u)\n", nhm_cstates[id].name, previous_count[id][cpu], current_count[id][cpu], cpu); dprint("%s: tsc_diff: %llu - count_diff: %llu - percent: %2.f (%u)\n", nhm_cstates[id].name, Loading Loading @@ -162,7 +164,8 @@ static int nhm_stop(void) struct cpuidle_monitor intel_nhm_monitor; struct cpuidle_monitor* intel_nhm_register(void) { struct cpuidle_monitor *intel_nhm_register(void) { int num; if (cpupower_cpu_info.vendor != X86_VENDOR_INTEL) Loading @@ -187,7 +190,8 @@ struct cpuidle_monitor* intel_nhm_register(void) { return &intel_nhm_monitor; } void intel_nhm_unregister(void) { void intel_nhm_unregister(void) { int num; for (num = 0; num < NHM_CSTATE_COUNT; num++) { Loading Loading
tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c +9 −11 Original line number Diff line number Diff line Loading @@ -236,10 +236,9 @@ static int amd_fam14h_start(void) int num, cpu; clock_gettime(CLOCK_REALTIME, &start_time); for (num = 0; num < AMD_FAM14H_STATE_NUM; num++) { for (cpu = 0; cpu < cpu_count; cpu++) { for (cpu = 0; cpu < cpu_count; cpu++) amd_fam14h_init(&amd_fam14h_cstates[num], cpu); } } #ifdef DEBUG clock_gettime(CLOCK_REALTIME, &dbg_time); dbg_timediff = timespec_diff_us(start_time, dbg_time); Loading @@ -257,10 +256,9 @@ static int amd_fam14h_stop(void) clock_gettime(CLOCK_REALTIME, &end_time); for (num = 0; num < AMD_FAM14H_STATE_NUM; num++) { for (cpu = 0; cpu < cpu_count; cpu++) { for (cpu = 0; cpu < cpu_count; cpu++) amd_fam14h_disable(&amd_fam14h_cstates[num], cpu); } } #ifdef DEBUG clock_gettime(CLOCK_REALTIME, &dbg_time); dbg_timediff = timespec_diff_us(end_time, dbg_time); Loading @@ -281,8 +279,8 @@ static int is_nbp1_capable(void) return val & (1 << 31); } struct cpuidle_monitor* amd_fam14h_register(void) { struct cpuidle_monitor *amd_fam14h_register(void) { int num; if (cpupower_cpu_info.vendor != X86_VENDOR_AMD) Loading
tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c +38 −27 Original line number Diff line number Diff line Loading @@ -55,7 +55,6 @@ static int cpuidle_start(void) dprint("CPU %d - State: %d - Val: %llu\n", cpu, state, previous_count[cpu][state]); } }; return 0; } Loading Loading @@ -84,33 +83,44 @@ void fix_up_intel_idle_driver_name(char *tmp, int num) /* fix up cpuidle name for intel idle driver */ if (!strncmp(tmp, "NHM-", 4)) { switch (num) { case 1: strcpy(tmp, "C1"); case 1: strcpy(tmp, "C1"); break; case 2: strcpy(tmp, "C3"); case 2: strcpy(tmp, "C3"); break; case 3: strcpy(tmp, "C6"); case 3: strcpy(tmp, "C6"); break; } } else if (!strncmp(tmp, "SNB-", 4)) { switch (num) { case 1: strcpy(tmp, "C1"); case 1: strcpy(tmp, "C1"); break; case 2: strcpy(tmp, "C3"); case 2: strcpy(tmp, "C3"); break; case 3: strcpy(tmp, "C6"); case 3: strcpy(tmp, "C6"); break; case 4: strcpy(tmp, "C7"); case 4: strcpy(tmp, "C7"); break; } } else if (!strncmp(tmp, "ATM-", 4)) { switch (num) { case 1: strcpy(tmp, "C1"); case 1: strcpy(tmp, "C1"); break; case 2: strcpy(tmp, "C2"); case 2: strcpy(tmp, "C2"); break; case 3: strcpy(tmp, "C4"); case 3: strcpy(tmp, "C4"); break; case 4: strcpy(tmp, "C6"); case 4: strcpy(tmp, "C6"); break; } } Loading Loading @@ -144,7 +154,8 @@ static struct cpuidle_monitor* cpuidle_register(void) cpuidle_cstates[num].range = RANGE_THREAD; cpuidle_cstates[num].id = num; cpuidle_cstates[num].get_count_percent = cpuidle_get_count_percent; cpuidle_cstates[num].get_count_percent = cpuidle_get_count_percent; }; /* Free this at program termination */ Loading
tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c +33 −31 Original line number Diff line number Diff line Loading @@ -169,22 +169,20 @@ void print_results(int topology_depth, int cpu) if (s.get_count_percent) { ret = s.get_count_percent(s.id, &percent, cpu_top.core_info[cpu].cpu); if (ret) { if (ret) printf("******"); } else if (percent >= 100.0) else if (percent >= 100.0) printf("%6.1f", percent); else printf("%6.2f", percent); } else if (s.get_count) { } else if (s.get_count) { ret = s.get_count(s.id, &result, cpu_top.core_info[cpu].cpu); if (ret) { if (ret) printf("******"); } else else printf("%6llu", result); } else { } else { printf(_("Monitor %s, Counter %s has no count " "function. Implementation error\n"), monitors[mon]->name, s.name); Loading Loading @@ -244,18 +242,21 @@ static void parse_monitor_param(char* param) exit(EXIT_FAILURE); } /* Override detected/registerd monitors array with requested one */ memcpy(monitors, tmp_mons, sizeof(struct cpuidle_monitor*) * MONITORS_MAX); memcpy(monitors, tmp_mons, sizeof(struct cpuidle_monitor *) * MONITORS_MAX); avail_monitors = hits; } void list_monitors(void) { void list_monitors(void) { unsigned int mon; int state; cstate_t s; for (mon = 0; mon < avail_monitors; mon++) { printf(_("Monitor \"%s\" (%d states) - Might overflow after %u " "s\n"), monitors[mon]->name, monitors[mon]->hw_states_num, "s\n"), monitors[mon]->name, monitors[mon]->hw_states_num, monitors[mon]->overflow_s); for (state = 0; state < monitors[mon]->hw_states_num; state++) { Loading Loading @@ -308,7 +309,8 @@ int fork_it(char **argv) timediff = timespec_diff_us(start, end); if (WIFEXITED(status)) printf(_("%s took %.5f seconds and exited with status %d\n"), argv[0], timediff / (1000.0 * 1000), WEXITSTATUS(status)); argv[0], timediff / (1000.0 * 1000), WEXITSTATUS(status)); return 0; } Loading @@ -322,9 +324,9 @@ int do_interval_measure(int i) monitors[num]->start(); } sleep(i); for (num = 0; num < avail_monitors; num++) { for (num = 0; num < avail_monitors; num++) monitors[num]->stop(); } return 0; } Loading Loading @@ -438,9 +440,9 @@ int cmd_monitor(int argc, char **argv) print_results(1, cpu); } for (num = 0; num < avail_monitors; num++) { for (num = 0; num < avail_monitors; num++) monitors[num]->unregister(); } cpu_topology_release(cpu_top); return 0; }
tools/power/cpupower/utils/idle_monitor/mperf_monitor.c +15 −18 Original line number Diff line number Diff line Loading @@ -145,8 +145,8 @@ static int mperf_get_count_percent(unsigned int id, double *percent, if (id == Cx) *percent = 100.0 - *percent; dprint("%s: previous: %llu - current: %llu - (%u)\n", mperf_cstates[id].name, mperf_diff, aperf_diff, cpu); dprint("%s: previous: %llu - current: %llu - (%u)\n", mperf_cstates[id].name, mperf_diff, aperf_diff, cpu); dprint("%s: %f\n", mperf_cstates[id].name, *percent); return 0; } Loading Loading @@ -206,8 +206,8 @@ static int mperf_stop(void) struct cpuidle_monitor mperf_monitor; struct cpuidle_monitor* mperf_register(void) { struct cpuidle_monitor *mperf_register(void) { unsigned long min; if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF)) Loading @@ -222,20 +222,17 @@ struct cpuidle_monitor* mperf_register(void) { /* Free this at program termination */ is_valid = calloc(cpu_count, sizeof(int)); mperf_previous_count = calloc (cpu_count, sizeof(unsigned long long)); aperf_previous_count = calloc (cpu_count, sizeof(unsigned long long)); mperf_current_count = calloc (cpu_count, sizeof(unsigned long long)); aperf_current_count = calloc (cpu_count, sizeof(unsigned long long)); mperf_previous_count = calloc(cpu_count, sizeof(unsigned long long)); aperf_previous_count = calloc(cpu_count, sizeof(unsigned long long)); mperf_current_count = calloc(cpu_count, sizeof(unsigned long long)); aperf_current_count = calloc(cpu_count, sizeof(unsigned long long)); mperf_monitor.name_len = strlen(mperf_monitor.name); return &mperf_monitor; } void mperf_unregister(void) { void mperf_unregister(void) { free(mperf_previous_count); free(aperf_previous_count); free(mperf_current_count); Loading
tools/power/cpupower/utils/idle_monitor/nhm_idle.c +17 −13 Original line number Diff line number Diff line Loading @@ -69,7 +69,8 @@ static unsigned long long *current_count[NHM_CSTATE_COUNT]; /* valid flag for all CPUs. If a MSR read failed it will be zero */ static int *is_valid; static int nhm_get_count(enum intel_nhm_id id, unsigned long long *val, unsigned int cpu) static int nhm_get_count(enum intel_nhm_id id, unsigned long long *val, unsigned int cpu) { int msr; Loading Loading @@ -106,12 +107,13 @@ static int nhm_get_count_percent(unsigned int id, double *percent, if (!is_valid[cpu]) return -1; *percent = (100.0 * (current_count[id][cpu] - previous_count[id][cpu])) / *percent = (100.0 * (current_count[id][cpu] - previous_count[id][cpu])) / (tsc_at_measure_end - tsc_at_measure_start); dprint("%s: previous: %llu - current: %llu - (%u)\n", nhm_cstates[id].name, previous_count[id][cpu], current_count[id][cpu], cpu); dprint("%s: previous: %llu - current: %llu - (%u)\n", nhm_cstates[id].name, previous_count[id][cpu], current_count[id][cpu], cpu); dprint("%s: tsc_diff: %llu - count_diff: %llu - percent: %2.f (%u)\n", nhm_cstates[id].name, Loading Loading @@ -162,7 +164,8 @@ static int nhm_stop(void) struct cpuidle_monitor intel_nhm_monitor; struct cpuidle_monitor* intel_nhm_register(void) { struct cpuidle_monitor *intel_nhm_register(void) { int num; if (cpupower_cpu_info.vendor != X86_VENDOR_INTEL) Loading @@ -187,7 +190,8 @@ struct cpuidle_monitor* intel_nhm_register(void) { return &intel_nhm_monitor; } void intel_nhm_unregister(void) { void intel_nhm_unregister(void) { int num; for (num = 0; num < NHM_CSTATE_COUNT; num++) { Loading