diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2010-08-05 21:17:16 -0400 |
---|---|---|
committer | Arjan van de Ven <arjan@linux.intel.com> | 2010-08-05 21:17:16 -0400 |
commit | 65c0a2017aa686dc4bcea8f84b70aba863e55ca3 (patch) | |
tree | 5fd8a9b32661d9900f4430267df59f65cb8ef684 /cpu | |
parent | 2eccfa204eb7d6c15830a107e9aac47740281f61 (diff) | |
download | powertop-65c0a2017aa686dc4bcea8f84b70aba863e55ca3.tar.gz |
rename a bunch of methods to "cstate" rather than just state
to prepare for adding p states
Diffstat (limited to 'cpu')
-rw-r--r-- | cpu/abstract_cpu.cpp | 48 | ||||
-rw-r--r-- | cpu/cpu.cpp | 14 | ||||
-rw-r--r-- | cpu/cpu.h | 26 | ||||
-rw-r--r-- | cpu/cpu_core.cpp | 16 | ||||
-rw-r--r-- | cpu/cpu_linux.cpp | 20 | ||||
-rw-r--r-- | cpu/cpu_package.cpp | 16 | ||||
-rw-r--r-- | cpu/intel_cpus.cpp | 32 |
7 files changed, 86 insertions, 86 deletions
diff --git a/cpu/abstract_cpu.cpp b/cpu/abstract_cpu.cpp index b6a8a9c..3fb225f 100644 --- a/cpu/abstract_cpu.cpp +++ b/cpu/abstract_cpu.cpp @@ -7,9 +7,9 @@ void abstract_cpu::measurement_start(void) { unsigned int i; - for (i = 0; i < states.size(); i++) - delete states[i]; - states.resize(0); + for (i = 0; i < cstates.size(); i++) + delete cstates[i]; + cstates.resize(0); for (i = 0; i < children.size(); i++) if (children[i]) @@ -33,19 +33,19 @@ void abstract_cpu::measurement_end(void) for (i = 0; i < children.size(); i++) if (children[i]) - for (j = 0; j < children[i]->states.size(); j++) { + for (j = 0; j < children[i]->cstates.size(); j++) { struct power_state *state; - state = children[i]->states[j]; + state = children[i]->cstates[j]; if (!state) continue; - update_state( state->linux_name, state->human_name, state->usage_before, state->duration_before, state->before_count); - finalize_state(state->linux_name, state->usage_after, state->duration_after, state->after_count); + update_cstate( state->linux_name, state->human_name, state->usage_before, state->duration_before, state->before_count); + finalize_cstate(state->linux_name, state->usage_after, state->duration_after, state->after_count); } - for (i = 0; i < states.size(); i++) { - struct power_state *state = states[i]; + for (i = 0; i < cstates.size(); i++) { + struct power_state *state = cstates[i]; if (state->after_count == 0) { cout << "after count is 0 " << state->linux_name << "\n"; @@ -62,7 +62,7 @@ void abstract_cpu::measurement_end(void) } } -void abstract_cpu::insert_state(const char *linux_name, const char *human_name, uint64_t usage, uint64_t duration, int count) +void abstract_cpu::insert_cstate(const char *linux_name, const char *human_name, uint64_t usage, uint64_t duration, int count) { struct power_state *state; const char *c; @@ -74,7 +74,7 @@ void abstract_cpu::insert_state(const char *linux_name, const char *human_name, memset(state, 0, sizeof(*state)); - states.push_back(state); + cstates.push_back(state); strcpy(state->linux_name, linux_name); strcpy(state->human_name, human_name); @@ -97,14 +97,14 @@ void abstract_cpu::insert_state(const char *linux_name, const char *human_name, state->before_count = count; } -void abstract_cpu::finalize_state(const char *linux_name, uint64_t usage, uint64_t duration, int count) +void abstract_cpu::finalize_cstate(const char *linux_name, uint64_t usage, uint64_t duration, int count) { unsigned int i; struct power_state *state = NULL; - for (i = 0; i < states.size(); i++) { - if (strcmp(linux_name, states[i]->linux_name) == 0) { - state = states[i]; + for (i = 0; i < cstates.size(); i++) { + if (strcmp(linux_name, cstates[i]->linux_name) == 0) { + state = cstates[i]; break; } } @@ -119,20 +119,20 @@ void abstract_cpu::finalize_state(const char *linux_name, uint64_t usage, uint64 state->after_count += count; } -void abstract_cpu::update_state(const char *linux_name, const char *human_name, uint64_t usage, uint64_t duration, int count) +void abstract_cpu::update_cstate(const char *linux_name, const char *human_name, uint64_t usage, uint64_t duration, int count) { unsigned int i; struct power_state *state = NULL; - for (i = 0; i < states.size(); i++) { - if (strcmp(linux_name, states[i]->linux_name) == 0) { - state = states[i]; + for (i = 0; i < cstates.size(); i++) { + if (strcmp(linux_name, cstates[i]->linux_name) == 0) { + state = cstates[i]; break; } } if (!state) { - insert_state(linux_name, human_name, usage, duration, count); + insert_cstate(linux_name, human_name, usage, duration, count); return; } @@ -142,20 +142,20 @@ void abstract_cpu::update_state(const char *linux_name, const char *human_name, } -int abstract_cpu::has_state_level(int level) +int abstract_cpu::has_cstate_level(int level) { unsigned int i; if (level == LEVEL_HEADER) return 1; - for (i = 0; i < states.size(); i++) - if (states[i]->line_level == level) + for (i = 0; i < cstates.size(); i++) + if (cstates[i]->line_level == level) return 1; for (i = 0; i < children.size(); i++) if (children[i]) - if (children[i]->has_state_level(level)) + if (children[i]->has_cstate_level(level)) return 1; return 0; } diff --git a/cpu/cpu.cpp b/cpu/cpu.cpp index 0e09e91..d8d1526 100644 --- a/cpu/cpu.cpp +++ b/cpu/cpu.cpp @@ -210,14 +210,14 @@ void display_cpus2(void) ctr = 22; int first = 1; linebuf[0] = 0; - if (!_package->has_state_level(line)) + if (!_package->has_cstate_level(line)) continue; buffer[0] = 0; if (first_pkg == 0) { - strcat(linebuf, _package->fill_state_name(line, buffer)); + strcat(linebuf, _package->fill_cstate_name(line, buffer)); expand_string(linebuf, 10); - strcat(linebuf, _package->fill_line(line, buffer)); + strcat(linebuf, _package->fill_cstate_line(line, buffer)); } expand_string(linebuf, 20); @@ -225,9 +225,9 @@ void display_cpus2(void) buffer[0] = 0; - strcat(linebuf, _core->fill_state_name(line, buffer)); + strcat(linebuf, _core->fill_cstate_name(line, buffer)); expand_string(linebuf, ctr + 10); - strcat(linebuf, _core->fill_line(line, buffer)); + strcat(linebuf, _core->fill_cstate_line(line, buffer)); ctr += 20; expand_string(linebuf, ctr); @@ -240,13 +240,13 @@ void display_cpus2(void) continue; if (first == 1) { - strcat(linebuf, _cpu->fill_state_name(line, buffer)); + strcat(linebuf, _cpu->fill_cstate_name(line, buffer)); expand_string(linebuf, ctr + 10); first = 0; ctr += 12; } buffer[0] = 0; - strcat(linebuf, _cpu->fill_line(line, buffer)); + strcat(linebuf, _cpu->fill_cstate_line(line, buffer)); ctr += 18; expand_string(linebuf, ctr); @@ -38,21 +38,21 @@ protected: double time_factor; public: vector<class abstract_cpu *> children; - vector<struct power_state *> states; + vector<struct power_state *> cstates; void set_number(int number, int cpu) {this->number = number; this->first_cpu = cpu;}; - void insert_state(const char *linux_name, const char *human_name, uint64_t usage, uint64_t duration, int count); - void update_state(const char *linux_name, const char *human_name, uint64_t usage, uint64_t duration, int count); - void finalize_state(const char *linux_name, uint64_t usage, uint64_t duration, int count); + void insert_cstate(const char *linux_name, const char *human_name, uint64_t usage, uint64_t duration, int count); + void update_cstate(const char *linux_name, const char *human_name, uint64_t usage, uint64_t duration, int count); + void finalize_cstate(const char *linux_name, uint64_t usage, uint64_t duration, int count); - virtual int has_state_level(int level); + virtual int has_cstate_level(int level); virtual void measurement_start(void); virtual void measurement_end(void); - virtual char * fill_line(int line_nr, char *buffer) { return buffer;}; - virtual char * fill_state_name(int line_nr, char *buffer) { return buffer;}; + virtual char * fill_cstate_line(int line_nr, char *buffer) { return buffer;}; + virtual char * fill_cstate_name(int line_nr, char *buffer) { return buffer;}; }; class cpu_linux: public abstract_cpu @@ -61,23 +61,23 @@ public: virtual void measurement_start(void); virtual void measurement_end(void); - virtual char * fill_line(int line_nr, char *buffer); - virtual char * fill_state_name(int line_nr, char *buffer); + virtual char * fill_cstate_line(int line_nr, char *buffer); + virtual char * fill_cstate_name(int line_nr, char *buffer); }; class cpu_core: public abstract_cpu { public: - virtual char * fill_line(int line_nr, char *buffer); - virtual char * fill_state_name(int line_nr, char *buffer); + virtual char * fill_cstate_line(int line_nr, char *buffer); + virtual char * fill_cstate_name(int line_nr, char *buffer); }; class cpu_package: public abstract_cpu { public: - virtual char * fill_line(int line_nr, char *buffer); - virtual char * fill_state_name(int line_nr, char *buffer); + virtual char * fill_cstate_line(int line_nr, char *buffer); + virtual char * fill_cstate_name(int line_nr, char *buffer); }; #include "intel_cpus.h" diff --git a/cpu/cpu_core.cpp b/cpu/cpu_core.cpp index e258fda..ab6a777 100644 --- a/cpu/cpu_core.cpp +++ b/cpu/cpu_core.cpp @@ -2,7 +2,7 @@ #include "cpu.h" #include "../lib.h" -char * cpu_core::fill_line(int line_nr, char *buffer) +char * cpu_core::fill_cstate_line(int line_nr, char *buffer) { unsigned int i; buffer[0] = 0; @@ -12,26 +12,26 @@ char * cpu_core::fill_line(int line_nr, char *buffer) return buffer; } - for (i = 0; i < states.size(); i++) { - if (states[i]->line_level != line_nr) + for (i = 0; i < cstates.size(); i++) { + if (cstates[i]->line_level != line_nr) continue; - sprintf(buffer,"%5.1f%%", percentage(states[i]->duration_delta / time_factor)); + sprintf(buffer,"%5.1f%%", percentage(cstates[i]->duration_delta / time_factor)); } return buffer; } -char * cpu_core::fill_state_name(int line_nr, char *buffer) +char * cpu_core::fill_cstate_name(int line_nr, char *buffer) { unsigned int i; buffer[0] = 0; - for (i = 0; i < states.size(); i++) { - if (states[i]->line_level != line_nr) + for (i = 0; i < cstates.size(); i++) { + if (cstates[i]->line_level != line_nr) continue; - sprintf(buffer,"%s", states[i]->human_name); + sprintf(buffer,"%s", cstates[i]->human_name); } return buffer; diff --git a/cpu/cpu_linux.cpp b/cpu/cpu_linux.cpp index 3735af3..e4b4c5d 100644 --- a/cpu/cpu_linux.cpp +++ b/cpu/cpu_linux.cpp @@ -71,7 +71,7 @@ void cpu_linux::measurement_start(void) } - update_state(linux_name, human_name, usage, duration, 1); + update_cstate(linux_name, human_name, usage, duration, 1); } closedir(dir); @@ -125,7 +125,7 @@ void cpu_linux::measurement_end(void) } - finalize_state(linux_name, usage, duration, 1); + finalize_cstate(linux_name, usage, duration, 1); } closedir(dir); @@ -135,7 +135,7 @@ void cpu_linux::measurement_end(void) } -char * cpu_linux::fill_line(int line_nr, char *buffer) +char * cpu_linux::fill_cstate_line(int line_nr, char *buffer) { unsigned int i; buffer[0] = 0; @@ -145,26 +145,26 @@ char * cpu_linux::fill_line(int line_nr, char *buffer) return buffer; } - for (i = 0; i < states.size(); i++) { - if (states[i]->line_level != line_nr) + for (i = 0; i < cstates.size(); i++) { + if (cstates[i]->line_level != line_nr) continue; - sprintf(buffer,"%5.1f%% %6.1f ms", percentage(states[i]->duration_delta / time_factor), 1.0 * states[i]->duration_delta / (1+states[i]->usage_delta) / 1000); + sprintf(buffer,"%5.1f%% %6.1f ms", percentage(cstates[i]->duration_delta / time_factor), 1.0 * cstates[i]->duration_delta / (1+cstates[i]->usage_delta) / 1000); } return buffer; } -char * cpu_linux::fill_state_name(int line_nr, char *buffer) +char * cpu_linux::fill_cstate_name(int line_nr, char *buffer) { unsigned int i; buffer[0] = 0; - for (i = 0; i < states.size(); i++) { - if (states[i]->line_level != line_nr) + for (i = 0; i < cstates.size(); i++) { + if (cstates[i]->line_level != line_nr) continue; - sprintf(buffer,"%s", states[i]->human_name); + sprintf(buffer,"%s", cstates[i]->human_name); } return buffer; diff --git a/cpu/cpu_package.cpp b/cpu/cpu_package.cpp index a9668c5..8e827f5 100644 --- a/cpu/cpu_package.cpp +++ b/cpu/cpu_package.cpp @@ -2,7 +2,7 @@ #include "cpu.h" #include "../lib.h" -char * cpu_package::fill_line(int line_nr, char *buffer) +char * cpu_package::fill_cstate_line(int line_nr, char *buffer) { unsigned int i; buffer[0] = 0; @@ -12,27 +12,27 @@ char * cpu_package::fill_line(int line_nr, char *buffer) return buffer; } - for (i = 0; i < states.size(); i++) { - if (states[i]->line_level != line_nr) + for (i = 0; i < cstates.size(); i++) { + if (cstates[i]->line_level != line_nr) continue; - sprintf(buffer,"%5.1f%%", percentage(states[i]->duration_delta / time_factor)); + sprintf(buffer,"%5.1f%%", percentage(cstates[i]->duration_delta / time_factor)); } return buffer; } -char * cpu_package::fill_state_name(int line_nr, char *buffer) +char * cpu_package::fill_cstate_name(int line_nr, char *buffer) { unsigned int i; buffer[0] = 0; - for (i = 0; i < states.size(); i++) { - if (states[i]->line_level != line_nr) + for (i = 0; i < cstates.size(); i++) { + if (cstates[i]->line_level != line_nr) continue; - sprintf(buffer,"%s", states[i]->human_name); + sprintf(buffer,"%s", cstates[i]->human_name); } return buffer; diff --git a/cpu/intel_cpus.cpp b/cpu/intel_cpus.cpp index 141c646..62f5f9b 100644 --- a/cpu/intel_cpus.cpp +++ b/cpu/intel_cpus.cpp @@ -35,8 +35,8 @@ void nhm_core::measurement_start(void) c6_before = get_msr(first_cpu, MSR_CORE_C6_RESIDENCY); tsc_before = get_msr(first_cpu, MSR_TSC); - insert_state("core c3", "C3 (cc3)", 0, c3_before, 1); - insert_state("core c6", "C6 (cc6)", 0, c6_before, 1); + insert_cstate("core c3", "C3 (cc3)", 0, c3_before, 1); + insert_cstate("core c6", "C6 (cc6)", 0, c6_before, 1); } void nhm_core::measurement_end(void) @@ -51,8 +51,8 @@ void nhm_core::measurement_end(void) c6_after = get_msr(first_cpu, MSR_CORE_C6_RESIDENCY); tsc_after = get_msr(first_cpu, MSR_TSC); - finalize_state("core c3", 0, c3_after, 1); - finalize_state("core c6", 0, c6_after, 1); + finalize_cstate("core c3", 0, c3_after, 1); + finalize_cstate("core c6", 0, c6_after, 1); gettimeofday(&stamp_after, NULL); @@ -68,8 +68,8 @@ void nhm_core::measurement_end(void) ratio = 1.0 * time_delta / (tsc_after - tsc_before); - for (i = 0; i < states.size(); i++) { - struct power_state *state = states[i]; + for (i = 0; i < cstates.size(); i++) { + struct power_state *state = cstates[i]; if (state->after_count == 0) { cout << "after count is 0\n"; @@ -94,8 +94,8 @@ void nhm_package::measurement_start(void) c6_before = get_msr(number, MSR_PKG_C6_RESIDENCY); tsc_before = get_msr(first_cpu, MSR_TSC); - insert_state("pkg c3", "C3 (pc3)", 0, c3_before, 1); - insert_state("pkg c6", "C6 (pc6)", 0, c6_before, 1); + insert_cstate("pkg c3", "C3 (pc3)", 0, c3_before, 1); + insert_cstate("pkg c6", "C6 (pc6)", 0, c6_before, 1); } void nhm_package::measurement_end(void) @@ -114,8 +114,8 @@ void nhm_package::measurement_end(void) time_factor = 1000000.0 * (stamp_after.tv_sec - stamp_before.tv_sec) + stamp_after.tv_usec - stamp_before.tv_usec; - finalize_state("pkg c3", 0, c3_after, 1); - finalize_state("pkg c6", 0, c6_after, 1); + finalize_cstate("pkg c3", 0, c3_after, 1); + finalize_cstate("pkg c6", 0, c6_after, 1); for (i = 0; i < children.size(); i++) if (children[i]) @@ -126,8 +126,8 @@ void nhm_package::measurement_end(void) ratio = 1.0 * time_delta / (tsc_after - tsc_before); - for (i = 0; i < states.size(); i++) { - struct power_state *state = states[i]; + for (i = 0; i < cstates.size(); i++) { + struct power_state *state = cstates[i]; if (state->after_count == 0) { cout << "after count is 0\n"; @@ -152,7 +152,7 @@ void nhm_cpu::measurement_start(void) aperf_before = get_msr(number, MSR_APERF); tsc_before = get_msr(number, MSR_TSC); - insert_state("active", "C0 active", 0, aperf_before, 1); + insert_cstate("active", "C0 active", 0, aperf_before, 1); } void nhm_cpu::measurement_end(void) @@ -167,7 +167,7 @@ void nhm_cpu::measurement_end(void) - finalize_state("active", 0, aperf_after, 1); + finalize_cstate("active", 0, aperf_after, 1); cpu_linux::measurement_end(); @@ -177,8 +177,8 @@ void nhm_cpu::measurement_end(void) ratio = 1.0 * time_delta / (tsc_after - tsc_before); - for (i = 0; i < states.size(); i++) { - struct power_state *state = states[i]; + for (i = 0; i < cstates.size(); i++) { + struct power_state *state = cstates[i]; if (state->line_level != LEVEL_C0) continue; |