Re: [PATCH 4/4] cpufreq-aperf: mperf might tick faster than expected, esp on Intel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I sent an old/broken patch (4/4).

This one is better:

cpufreq-aperf: mperf might tick faster than expected, esp on Intel

fixes lines like that:

CPU     Average freq(KHz)  Time in C0      Time in Cx      C0 percentage
000     2601300            05 sec 004 ms   8155059272 sec 192 ms   100


Signed-off-by: Thomas Renninger <trenn@xxxxxxx>
CC: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>
CC: cpufreq@xxxxxxxxxxxxxxx

---
 utils/cpufreq-aperf.c |    5 ++-
 6 files changed, 293 insertions(+), 211 deletions(-)

--- a/utils/cpufreq-aperf.c
+++ b/utils/cpufreq-aperf.c
@@ -153,7 +153,10 @@ static int get_C_state_time(struct timeval time_diff, uint64_t mperf_diff,
 	expected_ticks = max_freq * overall_msecs;
 	*percent = (mperf_diff * 100) / expected_ticks;
 
-	cx_time = (expected_ticks - mperf_diff) / max_freq;
+	if (mperf_diff > expected_ticks)
+		cx_time = 0;
+	else
+		cx_time = (expected_ticks - mperf_diff) / max_freq;
 	c0_time = mperf_diff / max_freq;
 
 	CX_time->tv_sec  = cx_time / 1000;
--
To unsubscribe from this list: send the line "unsubscribe cpufreq" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Devel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Forum]     [Linux SCSI]

  Powered by Linux