diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2010-10-24 10:15:10 -0700 |
---|---|---|
committer | Arjan van de Ven <arjan@linux.intel.com> | 2010-10-24 10:15:10 -0700 |
commit | 9114dec5deb700624ca0e0e2efffde450393a3b0 (patch) | |
tree | 4974a19d8636d2e4e97295623eba5b488c2766c6 | |
parent | 764078377f9045d83bacac5dd4d259c036d039e5 (diff) | |
download | powertop-9114dec5deb700624ca0e0e2efffde450393a3b0.tar.gz |
deal with negative going stats when things plug-n-play
-rw-r--r-- | devices/ahci.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/devices/ahci.cpp b/devices/ahci.cpp index b1c3c13..37ac283 100644 --- a/devices/ahci.cpp +++ b/devices/ahci.cpp @@ -199,12 +199,18 @@ void ahci::end_measurement(void) } catch (std::ios_base::failure c) { } + if (end_active < start_active) + end_active = start_active; + p = (end_active - start_active) / (0.001 + end_active + end_partial + end_slumber - start_active - start_partial - start_slumber) * 100.0; if (p < 0) p = 0; sprintf(powername, "%s-active", name); report_utilization(powername, p); + if (end_partial < start_partial) + end_partial = start_partial; + p = (end_partial - start_partial) / (0.001 + end_active + end_partial + end_slumber - start_active - start_partial - start_slumber) * 100.0; if (p < 0) p = 0; |