summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Čerman2020-02-16 15:52:13 +0100
committerOndrej Čerman2020-02-16 15:52:13 +0100
commite8b4b33b8973fd53473af2e8c550de1cb4c5e24c (patch)
tree712b85436a99c8c1eb63d54c465aab595c015bbb
parent523cdc315bbc9486fd8cb0c9cc557e0e0879dbe1 (diff)
Fixed wrong readings when energy counter overflow occurs, FIX #17
-rw-r--r--src/ss/msr.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/ss/msr.c b/src/ss/msr.c
index f64c534..61fcc15 100644
--- a/src/ss/msr.c
+++ b/src/ss/msr.c
@@ -125,18 +125,24 @@ void msr_update() {
core_eng_a[i] = get_core_energy(i);
}
- package_power = (package_eng_a - package_eng_b) * energy_unit / MESUREMENT_TIME;
- if (package_power < package_power_min)
- package_power_min = package_power;
- if (package_power > package_power_max)
- package_power_max = package_power;
+ if (package_eng_a >= package_eng_b) {
+ package_power = (package_eng_a - package_eng_b) * energy_unit / MESUREMENT_TIME;
+
+ if (package_power < package_power_min)
+ package_power_min = package_power;
+ if (package_power > package_power_max)
+ package_power_max = package_power;
+ }
for (i = 0; i < cores; i++) {
- core_power[i] = (core_eng_a[i] - core_eng_b[i]) * energy_unit / MESUREMENT_TIME;
- if (core_power[i] < core_power_min[i])
- core_power_min[i] = core_power[i];
- if (core_power[i] > core_power_max[i])
- core_power_max[i] = core_power[i];
+ if (core_eng_a[i] >= core_eng_b[i]) {
+ core_power[i] = (core_eng_a[i] - core_eng_b[i]) * energy_unit / MESUREMENT_TIME;
+
+ if (core_power[i] < core_power_min[i])
+ core_power_min[i] = core_power[i];
+ if (core_power[i] > core_power_max[i])
+ core_power_max[i] = core_power[i];
+ }
}
}