Intel hyperthreaded cores does not exactly behave like if it was 2 real cores.
-       Actual HW cstate is roughly minimal cstate of the 2 threads.
        As most of the resources are shared, HW resources are only really 
powered
        down when both threads are idle.
-       Interrupts always wakes up the 2 threads. i.e. terminate the 2 mwait.
So in case of an hyperthreaded core a wakeup event is affecting power only when
both the threads are asleep. A wakeup event that occurs when one of
the thread is active should not be considered as a wakeup event.
---
 cpu/cpu.cpp            |    5 ++++-
 process/do_process.cpp |   21 +++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/cpu/cpu.cpp b/cpu/cpu.cpp
old mode 100644
new mode 100755
index 39f00e7..ec9dd91
--- a/cpu/cpu.cpp
+++ b/cpu/cpu.cpp
@@ -44,7 +44,7 @@ vector<class abstract_cpu *> all_cpus;
 
 static class perf_bundle * perf_events;
 
-
+int hyper_threading;
 
 class perf_power_bundle: public perf_bundle
 {
@@ -263,6 +263,9 @@ void enumerate_cpus(void)
                        handle_one_cpu(number, vendor, family, model);
                        set_max_cpu(number);
                }
+               if (strstr(line, "ht")) {
+                       hyper_threading = 1;
+               }
        }
 
 
diff --git a/process/do_process.cpp b/process/do_process.cpp
old mode 100644
new mode 100755
index 2ca4b10..ead2cab
--- a/process/do_process.cpp
+++ b/process/do_process.cpp
@@ -66,6 +66,8 @@ static uint64_t first_stamp, last_stamp;
 
 double measurement_time;
 
+extern int hyper_threading;
+
 static void push_consumer(unsigned int cpu, class power_consumer *consumer)
 {
        if (cpu_stack.size() <= cpu)
@@ -149,6 +151,8 @@ static void change_blame(unsigned int cpu, class 
power_consumer *consumer, int l
 
 static void consume_blame(unsigned int cpu)
 {
+       int cpusleep = 0;
+
        if (!get_wakeup_pending(cpu))
                return;
        if (cpu_level.size() <= cpu)
@@ -158,6 +162,23 @@ static void consume_blame(unsigned int cpu)
        if (!cpu_blame[cpu])
                return;
 
+       if (hyper_threading) {
+               if (cpu & 1){
+                       if (get_wakeup_pending(cpu - 1)){
+                               cpusleep++;
+                       }
+
+               }
+               else {
+                       if (get_wakeup_pending(cpu + 1)){
+                               cpusleep++;
+                       }
+               }
+
+               if (!cpusleep)
+                       return;
+       }
+
        cpu_blame[cpu]->wake_ups++;
        cpu_blame[cpu] = NULL;
        cpu_level[cpu] = 0;
-- 
1.7.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Power mailing list
[email protected]
https://bughost.org/mailman/listinfo/power

Reply via email to