Skip to contentSkip to conversation

tracing: add event power_frequency to powernow-k8 driver

PATCH In review Robert Schöne 3 participants 3 messages Feb 25, 2010 – Feb 26, 2010 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: add event power_frequency to powernow-k8 driver

This patch adds frequency tracing to the powernow-k8 cpufreq driver

(quoted diff) +0 -0

b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 6e44519..99034e7 100644

arch/x86/kernel/cpu/cpufreq/powernow-k8.c +4 -0
@@ -37,6 +37,10 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 
+#ifdef CONFIG_POWER_TRACER
+#include <trace/events/power.h> /* tracing power events */
+# endif /* CONFIG_POWER_TRACER */
+
 #include <asm/msr.h>
 
 #include <linux/acpi.h>
@@ -54,6 +58,25 @@ static DEFINE_PER_CPU(struct powernow_k8_data *,

powernow_data);

static int cpu_family = CPU_OPTERON;

+
+/* only trace power if it is selected */
+#ifdef CONFIG_POWER_TRACER
+ /* trace power event on a specific cpu/core */
+ static void trace_power_event(unsigned int *freq){
+ trace_power_frequency(POWER_PSTATE, *freq);
+ }
+
+ #define TRACE_POWER_FREQUENCY_EVENT(i,avail_cores, frequency)
\
+ for_each_cpu(i,avail_cores)
\
+ smp_call_function_single(i, trace_power_event,
&frequency, 1);
+
+#else /* !CONFIG_POWER_TRACER */
+
+ #define TRACE_POWER_FREQUENCY_EVENT(i,avail_cores, frequency) ;
+
+# endif /* end CONFIG_POWER_TRACER */
+
+
#ifndef CONFIG_SMP
static inline const struct cpumask *cpu_core_mask(int cpu) {
@@ -1074,6 +1097,8 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data,

        res = transition_fid_vid(data, fid, vid);
        freqs.new = find_khz_freq_from_fid(data->currfid);

+ TRACE_POWER_FREQUENCY_EVENT(i,data->available_cores, freqs.new);
+

        for_each_cpu(i, data->available_cores) {
                freqs.cpu = i;
                cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
@@ -1107,6 +1132,8 @@ static int transition_frequency_pstate(struct
powernow_k8_data *data,
        res = transition_pstate(data, pstate);
        freqs.new = find_khz_freq_from_pstate(data->powernow_table,

pstate);

+ TRACE_POWER_FREQUENCY_EVENT(i,data->available_cores, freqs.new);
+

        for_each_cpu(i, data->available_cores) {
                freqs.cpu = i;
                cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
Signature · 7 lines
Robert Schoene
Technische Universitaet Dresden
Zentrum fuer Informationsdienste und Hochleistungsrechnen
01062 Dresden

Tel.: (0351) 463-42483, Fax: (0351) 463-37773
E-Mail: [email protected]
Acked-by on v1 1/1
#1 lore raw
Quoted 95 lines

-----Original Message-----
From: Robert Schöne [mailto:[email protected]]
Sent: Thursday, February 25, 2010 4:18 AM
To: Langsdorf, Mark
Cc: [email protected]; [email protected]
Subject: [PATCH] tracing: add event power_frequency to powernow-k8 driver

This patch adds frequency tracing to the powernow-k8 cpufreq driver

arch/x86/kernel/cpu/cpufreq/powernow-k8.c +15 -0
index 6e44519..99034e7 100644
@@ -37,6 +37,10 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 
+#ifdef CONFIG_POWER_TRACER
+#include <trace/events/power.h> /* tracing power events */
+# endif /* CONFIG_POWER_TRACER */
+
 #include <asm/msr.h>
 
 #include <linux/acpi.h>
@@ -54,6 +58,25 @@ static DEFINE_PER_CPU(struct powernow_k8_data *,
 powernow_data);
 
 static int cpu_family = CPU_OPTERON;
 
+
+/* only trace power if it is selected */
+#ifdef CONFIG_POWER_TRACER
+       /* trace power event on a specific cpu/core */
+       static void trace_power_event(unsigned int *freq){
+               trace_power_frequency(POWER_PSTATE, *freq);
+       }
+
+       #define TRACE_POWER_FREQUENCY_EVENT(i,avail_cores, frequency)
 \
+        for_each_cpu(i,avail_cores)
 \
+               smp_call_function_single(i, trace_power_event,

&frequency, 1);

arch/x86/kernel/cpu/cpufreq/powernow-k8.c +4 -0
+
+#else /* !CONFIG_POWER_TRACER */
+
+       #define TRACE_POWER_FREQUENCY_EVENT(i,avail_cores, 

frequency) ;

arch/x86/kernel/cpu/cpufreq/powernow-k8.c +6 -0
+
+# endif /* end CONFIG_POWER_TRACER */
+
+
 #ifndef CONFIG_SMP
 static inline const struct cpumask *cpu_core_mask(int cpu)
 {
@@ -1074,6 +1097,8 @@ static int transition_frequency_fidvid(struct
 powernow_k8_data *data,
        res = transition_fid_vid(data, fid, vid);
        freqs.new = find_khz_freq_from_fid(data->currfid);
 
+       TRACE_POWER_FREQUENCY_EVENT(i,data->available_cores, 
 freqs.new);
+
        for_each_cpu(i, data->available_cores) {
                freqs.cpu = i;
                cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
arch/x86/kernel/cpu/cpufreq/powernow-k8.c +2 -0
@@ -1107,6 +1132,8 @@ static int transition_frequency_pstate(struct
 powernow_k8_data *data,
        res = transition_pstate(data, pstate);
        freqs.new = find_khz_freq_from_pstate(data->powernow_table,
 pstate);
 
+       TRACE_POWER_FREQUENCY_EVENT(i,data->available_cores, 
 freqs.new);
+
        for_each_cpu(i, data->available_cores) {
                freqs.cpu = i;
                cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
Signature · 7 lines
Robert Schoene
Technische Universitaet Dresden
Zentrum fuer Informationsdienste und Hochleistungsrechnen
01062 Dresden

Tel.: (0351) 463-42483, Fax: (0351) 463-37773
E-Mail: [email protected]
#2 lore raw
In reply to Robert Schöne
Quoted 22 lines · Robert Schöne

This patch adds frequency tracing to the powernow-k8 cpufreq driver

arch/x86/kernel/cpu/cpufreq/powernow-k8.c +4 -0
index 6e44519..99034e7 100644
@@ -37,6 +37,10 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 
+#ifdef CONFIG_POWER_TRACER
+#include <trace/events/power.h> /* tracing power events */
+# endif /* CONFIG_POWER_TRACER */
+
 #include <asm/msr.h>
 
 #include <linux/acpi.h>
@@ -54,6 +58,25 @@ static DEFINE_PER_CPU(struct powernow_k8_data *,
 powernow_data);
 
 static int cpu_family = CPU_OPTERON;

arch/x86/kernel/cpu/cpufreq/powernow-k8.c static DEFINE_PER_CPU(struct powernow_k8_data *, · line 70

Quoted 10 lines
arch/x86/kernel/cpu/cpufreq/powernow-k8.c +9 -0
 
+
+/* only trace power if it is selected */
+#ifdef CONFIG_POWER_TRACER
+       /* trace power event on a specific cpu/core */
+       static void trace_power_event(unsigned int *freq){
+               trace_power_frequency(POWER_PSTATE, *freq);
+       }
+
+       #define TRACE_POWER_FREQUENCY_EVENT(i,avail_cores, frequency)

ERROR: space required after that ','

Quoted 5 lines
arch/x86/kernel/cpu/cpufreq/powernow-k8.c +2 -0
 \
+        for_each_cpu(i,avail_cores)
 \
+               smp_call_function_single(i, trace_power_event,

&frequency, 1);

CONFIG_POWER_TRACER has gone. I don't know if smp_call_function_single() is necessary, if not necessary, those #ifs are not needed, otherwise you can use CONFIG_TRACING instead of CONFIG_POWER_TRACER.

Quoted 36 lines
arch/x86/kernel/cpu/cpufreq/powernow-k8.c +10 -0
+
+#else /* !CONFIG_POWER_TRACER */
+
+       #define TRACE_POWER_FREQUENCY_EVENT(i,avail_cores, frequency) ;
+
+# endif /* end CONFIG_POWER_TRACER */
+
+
 #ifndef CONFIG_SMP
 static inline const struct cpumask *cpu_core_mask(int cpu)
 {
@@ -1074,6 +1097,8 @@ static int transition_frequency_fidvid(struct
 powernow_k8_data *data,
        res = transition_fid_vid(data, fid, vid);
        freqs.new = find_khz_freq_from_fid(data->currfid);
 
+       TRACE_POWER_FREQUENCY_EVENT(i,data->available_cores, freqs.new);
+
        for_each_cpu(i, data->available_cores) {
                freqs.cpu = i;
                cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
arch/x86/kernel/cpu/cpufreq/powernow-k8.c +2 -0
@@ -1107,6 +1132,8 @@ static int transition_frequency_pstate(struct
 powernow_k8_data *data,
        res = transition_pstate(data, pstate);
        freqs.new = find_khz_freq_from_pstate(data->powernow_table,
 pstate);
 
+       TRACE_POWER_FREQUENCY_EVENT(i,data->available_cores, freqs.new);
+
        for_each_cpu(i, data->available_cores) {
                freqs.cpu = i;
                cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);