diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2010-08-09 08:59:30 -0400 |
---|---|---|
committer | Arjan van de Ven <arjan@linux.intel.com> | 2010-08-09 08:59:30 -0400 |
commit | 64c1f9d7469474cc5eff2168fe1193f670c278f9 (patch) | |
tree | 26e6ef88867742e2342a9b466d0045a3f798a2ef /cpu | |
parent | 286896523edfda22cad302e62023381a860f3768 (diff) | |
download | powertop-64c1f9d7469474cc5eff2168fe1193f670c278f9.tar.gz |
add the "has_pstate_level" logic to dynamically scale output size
Diffstat (limited to 'cpu')
-rw-r--r-- | cpu/abstract_cpu.cpp | 17 | ||||
-rw-r--r-- | cpu/cpu.cpp | 5 | ||||
-rw-r--r-- | cpu/cpu.h | 1 | ||||
-rw-r--r-- | cpu/intel_cpus.cpp | 8 | ||||
-rw-r--r-- | cpu/intel_cpus.h | 1 |
5 files changed, 30 insertions, 2 deletions
diff --git a/cpu/abstract_cpu.cpp b/cpu/abstract_cpu.cpp index b084327..8eb6d88 100644 --- a/cpu/abstract_cpu.cpp +++ b/cpu/abstract_cpu.cpp @@ -188,6 +188,23 @@ int abstract_cpu::has_cstate_level(int level) return 0; } +int abstract_cpu::has_pstate_level(int level) +{ + unsigned int i; + + if (level == LEVEL_HEADER) + return 1; + + if (level >= 0 && level < (int)pstates.size()) + return 1; + + for (i = 0; i < children.size(); i++) + if (children[i]) + if (children[i]->has_pstate_level(level)) + return 1; + return 0; +} + void abstract_cpu::insert_pstate(uint64_t freq, const char *human_name, uint64_t duration, int count) diff --git a/cpu/cpu.cpp b/cpu/cpu.cpp index 294b5f6..b375619 100644 --- a/cpu/cpu.cpp +++ b/cpu/cpu.cpp @@ -309,8 +309,9 @@ void display_cpu_pstates(const char *start, const char *end, const char *linesta int first = 1; ctr = 0; linebuf[0] = 0; -// if (!_package->has_pstate_level(line)) -// continue; + + if (!_package->has_pstate_level(line)) + continue; printf("%s", linestart); @@ -87,6 +87,7 @@ public: virtual char * fill_pstate_line(int line_nr, char *buffer) { return buffer;}; virtual char * fill_pstate_name(int line_nr, char *buffer) { return buffer;}; + virtual int has_pstate_level(int level); }; diff --git a/cpu/intel_cpus.cpp b/cpu/intel_cpus.cpp index 7c99ee3..babf204 100644 --- a/cpu/intel_cpus.cpp +++ b/cpu/intel_cpus.cpp @@ -236,3 +236,11 @@ char * nhm_cpu::fill_pstate_line(int line_nr, char *buffer) } return cpu_linux::fill_pstate_line(line_nr, buffer); } + + +int nhm_cpu::has_pstate_level(int level) +{ + if (level == LEVEL_C0) + return 1; + return cpu_linux::has_pstate_level(level); +}
\ No newline at end of file diff --git a/cpu/intel_cpus.h b/cpu/intel_cpus.h index 267212d..529707e 100644 --- a/cpu/intel_cpus.h +++ b/cpu/intel_cpus.h @@ -54,6 +54,7 @@ public: virtual char * fill_pstate_name(int line_nr, char *buffer); virtual char * fill_pstate_line(int line_nr, char *buffer); + virtual int has_pstate_level(int level); }; |