diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2010-08-06 13:01:06 -0400 |
---|---|---|
committer | Arjan van de Ven <arjan@linux.intel.com> | 2010-08-06 13:01:06 -0400 |
commit | 75daa32ada189d653656eb247a79c796b84f14b1 (patch) | |
tree | 2c18c5d954496ccad219dba6fa05b4c71ea2cb95 /cpu | |
parent | cce4b061d3cbd6d6a42e89c051a720b5b3b0664a (diff) | |
download | powertop-75daa32ada189d653656eb247a79c796b84f14b1.tar.gz |
more pstate work
Diffstat (limited to 'cpu')
-rw-r--r-- | cpu/abstract_cpu.cpp | 61 | ||||
-rw-r--r-- | cpu/cpu.h | 22 |
2 files changed, 83 insertions, 0 deletions
diff --git a/cpu/abstract_cpu.cpp b/cpu/abstract_cpu.cpp index 2cf65dd..789b558 100644 --- a/cpu/abstract_cpu.cpp +++ b/cpu/abstract_cpu.cpp @@ -160,3 +160,64 @@ int abstract_cpu::has_cstate_level(int level) return 0; } + + +void abstract_cpu::insert_pstate(uint64_t freq, const char *human_name, uint64_t duration, int count) +{ + struct frequency *state; + + state = new struct frequency; + + if (!state) + return; + + memset(state, 0, sizeof(*state)); + + pstates.push_back(state); + + state->freq = freq; + strcpy(state->human_name, human_name); + + + state->time_before = duration; +} + +void abstract_cpu::finalize_pstate(uint64_t freq, uint64_t duration, int count) +{ + unsigned int i; + struct frequency *state = NULL; + + for (i = 0; i < pstates.size(); i++) { + if (freq == pstates[i]->freq) { + state = pstates[i]; + break; + } + } + + if (!state) { + cout << "Invalid P state finalize " << freq << " \n"; + return; + } + state->time_before = duration; + +} + +void abstract_cpu::update_pstate(uint64_t freq, const char *human_name, uint64_t duration, int count) +{ + unsigned int i; + struct frequency *state = NULL; + + for (i = 0; i < pstates.size(); i++) { + if (freq == pstates[i]->freq) { + state = pstates[i]; + break; + } + } + + if (!state) { + insert_pstate(freq, human_name, duration, count); + return; + } + + state->time_before = duration; +} @@ -29,6 +29,18 @@ struct idle_state { int line_level; }; +struct frequency { + char human_name[32]; + int line_level; + + uint64_t freq; + + uint64_t time_before; + uint64_t time_after; + + double display_value; +}; + class abstract_cpu { protected: @@ -39,6 +51,7 @@ protected: public: vector<class abstract_cpu *> children; vector<struct idle_state *> cstates; + vector<struct frequency *> pstates; void set_number(int number, int cpu) {this->number = number; this->first_cpu = cpu;}; @@ -57,7 +70,16 @@ public: virtual char * fill_cstate_line(int line_nr, char *buffer) { return buffer;}; virtual char * fill_cstate_name(int line_nr, char *buffer) { return buffer;}; + /* P state related methods */ + void insert_pstate(uint64_t freq, const char *human_name, uint64_t duration, int count); + void update_pstate(uint64_t freq, const char *human_name, uint64_t duration, int count); + void finalize_pstate(uint64_t freq, uint64_t duration, int count); + + + virtual char * fill_pstate_line(int line_nr, char *buffer) { return buffer;}; + virtual char * fill_pstate_name(int line_nr, char *buffer) { return buffer;}; + }; class cpu_linux: public abstract_cpu |