diff options
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index b815a12159b2..861d77190206 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -444,6 +444,9 @@ delta_core(struct core_data *new, struct core_data *old) | |||
444 | old->c7 = new->c7 - old->c7; | 444 | old->c7 = new->c7 - old->c7; |
445 | } | 445 | } |
446 | 446 | ||
447 | /* | ||
448 | * old = new - old | ||
449 | */ | ||
447 | void | 450 | void |
448 | delta_thread(struct thread_data *new, struct thread_data *old, | 451 | delta_thread(struct thread_data *new, struct thread_data *old, |
449 | struct core_data *core_delta) | 452 | struct core_data *core_delta) |
@@ -482,19 +485,20 @@ delta_thread(struct thread_data *new, struct thread_data *old, | |||
482 | 485 | ||
483 | 486 | ||
484 | /* | 487 | /* |
485 | * As mperf and tsc collection are not atomic, | 488 | * As counter collection is not atomic, |
486 | * it is possible for mperf's non-halted cycles | 489 | * it is possible for mperf's non-halted cycles + idle states |
487 | * to exceed TSC's all cycles: show c1 = 0% in that case. | 490 | * to exceed TSC's all cycles: show c1 = 0% in that case. |
488 | */ | 491 | */ |
489 | if (old->mperf > old->tsc) | 492 | if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > old->tsc) |
490 | old->c1 = 0; | 493 | old->c1 = 0; |
491 | else { | 494 | else { |
492 | /* normal case, derive c1 */ | 495 | /* normal case, derive c1 */ |
493 | old->c1 = old->tsc - old->mperf - core_delta->c3 | 496 | old->c1 = old->tsc - old->mperf - core_delta->c3 |
494 | - core_delta->c6 - core_delta->c7; | 497 | - core_delta->c6 - core_delta->c7; |
495 | } | 498 | } |
499 | |||
496 | if (old->mperf == 0) { | 500 | if (old->mperf == 0) { |
497 | if (verbose) fprintf(stderr, "cpu%d MPERF 0!\n", old->cpu_id); | 501 | if (verbose > 1) fprintf(stderr, "cpu%d MPERF 0!\n", old->cpu_id); |
498 | old->mperf = 1; /* divide by 0 protection */ | 502 | old->mperf = 1; /* divide by 0 protection */ |
499 | } | 503 | } |
500 | 504 | ||