aboutsummaryrefslogtreecommitdiff
path: root/cpu
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2010-08-06 13:01:06 -0400
committerArjan van de Ven <arjan@linux.intel.com>2010-08-06 13:01:06 -0400
commit75daa32ada189d653656eb247a79c796b84f14b1 (patch)
tree2c18c5d954496ccad219dba6fa05b4c71ea2cb95 /cpu
parentcce4b061d3cbd6d6a42e89c051a720b5b3b0664a (diff)
downloadpowertop-75daa32ada189d653656eb247a79c796b84f14b1.tar.gz
more pstate work
Diffstat (limited to 'cpu')
-rw-r--r--cpu/abstract_cpu.cpp61
-rw-r--r--cpu/cpu.h22
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;
+}
diff --git a/cpu/cpu.h b/cpu/cpu.h
index 0f6a0cd..ae0c18f 100644
--- a/cpu/cpu.h
+++ b/cpu/cpu.h
@@ -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