aboutsummaryrefslogtreecommitdiff
path: root/src/cpu/abstract_cpu.cpp
diff options
context:
space:
mode:
authorIvan Shapovalov <intelfx100@gmail.com>2012-12-24 03:08:48 +0400
committerKristen Carlson Accardi <kristen@linux.intel.com>2013-01-31 13:59:33 -0800
commit06df65ce3c5a700acefe5f42cb458f145298ddba (patch)
tree288d08b204f0acf13b3f6227d93aea707925e872 /src/cpu/abstract_cpu.cpp
parent7a3dc6d64e8d220823a64a5cb0b86a3ea954b581 (diff)
Deduplication: merge cpu_{core, linux, package}::change_effective_frequency() into abstract_cpu::change_effective_frequency()
The mentioned overrides differ only in assigning 0 to effective_frequency prior to calling abstract_cpu::change_effective_frequency(), which reassigns real frequency to the same field. Moreover, the field value is never used between assignments. So it shall be safe to merge these overrides into the base definition as shown: * immediately assign real frequency to field effective_frequency; * remove post-assignment to the same field. Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
Diffstat (limited to 'src/cpu/abstract_cpu.cpp')
-rw-r--r--src/cpu/abstract_cpu.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/cpu/abstract_cpu.cpp b/src/cpu/abstract_cpu.cpp
index 5618761..ec52f55 100644
--- a/src/cpu/abstract_cpu.cpp
+++ b/src/cpu/abstract_cpu.cpp
@@ -393,14 +393,27 @@ void abstract_cpu::calculate_freq(uint64_t time)
void abstract_cpu::change_effective_frequency(uint64_t time, uint64_t frequency)
{
unsigned int i;
+ uint64_t time_delta, fr;
+
+ if (last_stamp)
+ time_delta = time - last_stamp;
+ else
+ time_delta = 1;
+
+ fr = effective_frequency;
+ if (old_idle)
+ fr = 0;
+
+ account_freq(fr, time_delta);
+
+ effective_frequency = frequency;
+ last_stamp = time;
/* propagate to all children */
for (i = 0; i < children.size(); i++)
if (children[i]) {
children[i]->change_effective_frequency(time, frequency);
}
-
- effective_frequency = frequency;
}