diff options
author | arjan <arjan@arjan-desktop.localdomain> | 2010-09-02 23:23:30 -0700 |
---|---|---|
committer | arjan <arjan@arjan-desktop.localdomain> | 2010-09-02 23:23:30 -0700 |
commit | 1681e26e00aab1aab71892e04ddf6c960cb5d7b4 (patch) | |
tree | d7dba96287bfad6e9c7f30ac775ad726288fb617 /cpu | |
parent | 4874efc49664ef55a2c7c7270290527dd1757088 (diff) | |
download | powertop-1681e26e00aab1aab71892e04ddf6c960cb5d7b4.tar.gz |
fix a lot of the accounting stuff
Diffstat (limited to 'cpu')
-rw-r--r-- | cpu/cpudevice.cpp | 46 | ||||
-rw-r--r-- | cpu/intel_cpus.cpp | 5 |
2 files changed, 50 insertions, 1 deletions
diff --git a/cpu/cpudevice.cpp b/cpu/cpudevice.cpp index d3e1a6f..7ba1a4f 100644 --- a/cpu/cpudevice.cpp +++ b/cpu/cpudevice.cpp @@ -16,7 +16,7 @@ cpudevice::cpudevice(const char *classname, const char *device_name, class abstr double cpudevice::power_usage(struct result_bundle *result, struct parameter_bundle *bundle) { double power = 0; - unsigned int i; + unsigned int i, j; for (i = 0; i < cpu->pstates.size(); i ++) { double factor; @@ -29,6 +29,50 @@ double cpudevice::power_usage(struct result_bundle *result, struct parameter_bun power += factor * util / 100.0; } + + for (i = 0; i < cpu->cstates.size(); i ++) { + double factor; + double util; + char buffer[128]; + sprintf(buffer,"package-idle-%s", cpu->cstates[i]->human_name); + factor = get_parameter_value(buffer, bundle); + sprintf(buffer,"package-%i-idle-%s", cpu->number, cpu->cstates[i]->human_name); + util = get_result_value(buffer, result); + + power += factor * util / 100.0; + } + + for (j = 0; j < cpu->children.size(); j++) { + class abstract_cpu *child; + child = cpu->children[j]; + if (!child) + continue; + + for (i = 0; i < child->pstates.size(); i ++) { + double factor; + double util; + char buffer[128]; + sprintf(buffer,"core-freq-%s", child->pstates[i]->human_name); + factor = get_parameter_value(buffer, bundle); + sprintf(buffer,"core-%i-freq-%s", child->number, child->pstates[i]->human_name); + util = get_result_value(buffer, result); + + power += factor * util / 100.0; + } + + for (i = 0; i < child->cstates.size(); i ++) { + double factor; + double util; + char buffer[128]; + sprintf(buffer,"core-idle-%s", child->cstates[i]->human_name); + factor = get_parameter_value(buffer, bundle); + sprintf(buffer,"core-%i-idle-%s", child->number, child->cstates[i]->human_name); + util = get_result_value(buffer, result); + + power += factor * util / 100.0; + } + + } return power; } diff --git a/cpu/intel_cpus.cpp b/cpu/intel_cpus.cpp index 0f3b186..2e77397 100644 --- a/cpu/intel_cpus.cpp +++ b/cpu/intel_cpus.cpp @@ -425,12 +425,17 @@ void nhm_package::report_out(void) if (cstates.size() > 1) { for (i = 0; i < cstates.size() - 1; i ++) { + if (!cstates[i]) + continue; sprintf(buffer,"package-idle-%s", cstates[i]->human_name); + printf("i is %i, human name is %s\n", i, cstates[i]->human_name); printf("registering %s \n", buffer); register_parameter(buffer, 1); } for (i = 0; i < cstates.size() - 1; i ++) { + if (!cstates[i]) + continue; sprintf(buffer,"package-%i-idle-%s", number, cstates[i]->human_name); report_utilization(buffer, percentage(cstates[i]->duration_delta / time_factor)); } |