| @@ -70,8 +70,8 @@ static int max_freq_mode; · 69 unmodified lines |
| 70 | 70 | */ |
| 71 | 71 | static unsigned long max_frequency; |
| 72 | 72 | |
| 73 | | −static unsigned long long tsc_at_measure_start; |
| 74 | | −static unsigned long long tsc_at_measure_end; |
| 73 | +static unsigned long long *tsc_at_measure_start; |
| 74 | +static unsigned long long *tsc_at_measure_end; |
| 75 | 75 | static unsigned long long *mperf_previous_count; |
| 76 | 76 | static unsigned long long *aperf_previous_count; |
| 77 | 77 | static unsigned long long *mperf_current_count; |
| @@ -169,7 +169,7 @@ static int mperf_get_count_percent(unsigned int id, double *percent, · 91 unmodified lines |
| 169 | 169 | aperf_diff = aperf_current_count[cpu] - aperf_previous_count[cpu]; |
| 170 | 170 | |
| 171 | 171 | if (max_freq_mode == MAX_FREQ_TSC_REF) { |
| 172 | | − tsc_diff = tsc_at_measure_end - tsc_at_measure_start; |
| 172 | + tsc_diff = tsc_at_measure_end[cpu] - tsc_at_measure_start[cpu]; |
| 173 | 173 | *percent = 100.0 * mperf_diff / tsc_diff; |
| 174 | 174 | dprint("%s: TSC Ref - mperf_diff: %llu, tsc_diff: %llu\n", |
| 175 | 175 | mperf_cstates[id].name, mperf_diff, tsc_diff); |
| @@ -206,7 +206,7 @@ static int mperf_get_count_freq(unsigned int id, unsigned long long *count, · 30 unmodified lines |
| 206 | 206 | |
| 207 | 207 | if (max_freq_mode == MAX_FREQ_TSC_REF) { |
| 208 | 208 | /* Calculate max_freq from TSC count */ |
| 209 | | − tsc_diff = tsc_at_measure_end - tsc_at_measure_start; |
| 209 | + tsc_diff = tsc_at_measure_end[cpu] - tsc_at_measure_start[cpu]; |
| 210 | 210 | time_diff = timespec_diff_us(time_start, time_end); |
| 211 | 211 | max_frequency = tsc_diff / time_diff; |
| 212 | 212 | } |
| @@ -225,33 +225,27 @@ static int mperf_get_count_freq(unsigned int id, unsigned long long *count, · 12 unmodified lines |
| 225 | 225 | static int mperf_start(void) |
| 226 | 226 | { |
| 227 | 227 | int cpu; |
| 228 | | − unsigned long long dbg; |
| 229 | 228 | |
| 230 | 229 | clock_gettime(CLOCK_REALTIME, &time_start); |
| 231 | | − mperf_get_tsc(&tsc_at_measure_start); |
| 232 | 230 | |
| 233 | | − for (cpu = 0; cpu < cpu_count; cpu++) |
| 231 | + for (cpu = 0; cpu < cpu_count; cpu++) { |
| 232 | + mperf_get_tsc(&tsc_at_measure_start[cpu]); |
| 234 | 233 | mperf_init_stats(cpu); |
| 234 | + } |
| 235 | 235 | |
| 236 | | − mperf_get_tsc(&dbg); |
| 237 | | − dprint("TSC diff: %llu\n", dbg - tsc_at_measure_start); |
| 238 | 236 | return 0; |
| 239 | 237 | } |
| 240 | 238 | |
| 241 | 239 | static int mperf_stop(void) |
| 242 | 240 | { |
| 243 | | − unsigned long long dbg; |
| 244 | 241 | int cpu; |
| 245 | 242 | |
| 246 | | − for (cpu = 0; cpu < cpu_count; cpu++) |
| 243 | + for (cpu = 0; cpu < cpu_count; cpu++) { |
| 247 | 244 | mperf_measure_stats(cpu); |
| 245 | + mperf_get_tsc(&tsc_at_measure_end[cpu]); |
| 246 | + } |
| 248 | 247 | |
| 249 | | − mperf_get_tsc(&tsc_at_measure_end); |
| 250 | 248 | clock_gettime(CLOCK_REALTIME, &time_end); |
| 251 | | − |
| 252 | | − mperf_get_tsc(&dbg); |
| 253 | | − dprint("TSC diff: %llu\n", dbg - tsc_at_measure_end); |
| 254 | | − |
| 255 | 249 | return 0; |
| 256 | 250 | } |
| 257 | 251 | |
| @@ -353,7 +347,8 @@ struct cpuidle_monitor *mperf_register(void) · 95 unmodified lines |
| 353 | 347 | aperf_previous_count = calloc(cpu_count, sizeof(unsigned long long)); |
| 354 | 348 | mperf_current_count = calloc(cpu_count, sizeof(unsigned long long)); |
| 355 | 349 | aperf_current_count = calloc(cpu_count, sizeof(unsigned long long)); |
| 356 | | − |
| 350 | + tsc_at_measure_start = calloc(cpu_count, sizeof(unsigned long long)); |
| 351 | + tsc_at_measure_end = calloc(cpu_count, sizeof(unsigned long long)); |
| 357 | 352 | mperf_monitor.name_len = strlen(mperf_monitor.name); |
| 358 | 353 | return &mperf_monitor; |
| 359 | 354 | } |
| @@ -364,6 +359,8 @@ void mperf_unregister(void) · 4 unmodified lines |
| 364 | 359 | free(aperf_previous_count); |
| 365 | 360 | free(mperf_current_count); |
| 366 | 361 | free(aperf_current_count); |
| 362 | + free(tsc_at_measure_start); |
| 363 | + free(tsc_at_measure_end); |
| 367 | 364 | free(is_valid); |
| 368 | 365 | } |
| 369 | 366 | |