diff options
author | Arjan van de Ven <arjan@infradead.org> | 2008-11-23 19:49:58 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-26 02:29:32 -0500 |
commit | f3f47a6768a29448866da4422b6f6bee485c947f (patch) | |
tree | ba4bf1b79cbd13412871eec50250294d7140fd09 /arch | |
parent | 509dceef6470442d8c7b8a43ec34125205840b3c (diff) |
tracing: add "power-tracer": C/P state tracer to help power optimization
Impact: new "power-tracer" ftrace plugin
This patch adds a C/P-state ftrace plugin that will generate
detailed statistics about the C/P-states that are being used,
so that we can look at detailed decisions that the C/P-state
code is making, rather than the too high level "average"
that we have today.
An example way of using this is:
mount -t debugfs none /sys/kernel/debug
echo cstate > /sys/kernel/debug/tracing/current_tracer
echo 1 > /sys/kernel/debug/tracing/tracing_enabled
sleep 1
echo 0 > /sys/kernel/debug/tracing/tracing_enabled
cat /sys/kernel/debug/tracing/trace | perl scripts/trace/cstate.pl > out.svg
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/process.c | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c index 8e48c5d4467d..88ea02dcb622 100644 --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/cpufreq.h> | 33 | #include <linux/cpufreq.h> |
34 | #include <linux/compiler.h> | 34 | #include <linux/compiler.h> |
35 | #include <linux/dmi.h> | 35 | #include <linux/dmi.h> |
36 | #include <linux/ftrace.h> | ||
36 | 37 | ||
37 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
38 | #include <acpi/processor.h> | 39 | #include <acpi/processor.h> |
@@ -391,6 +392,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
391 | unsigned int next_perf_state = 0; /* Index into perf table */ | 392 | unsigned int next_perf_state = 0; /* Index into perf table */ |
392 | unsigned int i; | 393 | unsigned int i; |
393 | int result = 0; | 394 | int result = 0; |
395 | struct power_trace it; | ||
394 | 396 | ||
395 | dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu); | 397 | dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu); |
396 | 398 | ||
@@ -427,6 +429,8 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
427 | } | 429 | } |
428 | } | 430 | } |
429 | 431 | ||
432 | trace_power_mark(&it, POWER_PSTATE, next_perf_state); | ||
433 | |||
430 | switch (data->cpu_feature) { | 434 | switch (data->cpu_feature) { |
431 | case SYSTEM_INTEL_MSR_CAPABLE: | 435 | case SYSTEM_INTEL_MSR_CAPABLE: |
432 | cmd.type = SYSTEM_INTEL_MSR_CAPABLE; | 436 | cmd.type = SYSTEM_INTEL_MSR_CAPABLE; |
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index c622772744d8..c27af49a4ede 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/pm.h> | 8 | #include <linux/pm.h> |
9 | #include <linux/clockchips.h> | 9 | #include <linux/clockchips.h> |
10 | #include <linux/ftrace.h> | ||
10 | #include <asm/system.h> | 11 | #include <asm/system.h> |
11 | 12 | ||
12 | unsigned long idle_halt; | 13 | unsigned long idle_halt; |
@@ -100,6 +101,9 @@ static inline int hlt_use_halt(void) | |||
100 | void default_idle(void) | 101 | void default_idle(void) |
101 | { | 102 | { |
102 | if (hlt_use_halt()) { | 103 | if (hlt_use_halt()) { |
104 | struct power_trace it; | ||
105 | |||
106 | trace_power_start(&it, POWER_CSTATE, 1); | ||
103 | current_thread_info()->status &= ~TS_POLLING; | 107 | current_thread_info()->status &= ~TS_POLLING; |
104 | /* | 108 | /* |
105 | * TS_POLLING-cleared state must be visible before we | 109 | * TS_POLLING-cleared state must be visible before we |
@@ -112,6 +116,7 @@ void default_idle(void) | |||
112 | else | 116 | else |
113 | local_irq_enable(); | 117 | local_irq_enable(); |
114 | current_thread_info()->status |= TS_POLLING; | 118 | current_thread_info()->status |= TS_POLLING; |
119 | trace_power_end(&it); | ||
115 | } else { | 120 | } else { |
116 | local_irq_enable(); | 121 | local_irq_enable(); |
117 | /* loop is done by the caller */ | 122 | /* loop is done by the caller */ |
@@ -154,24 +159,31 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait); | |||
154 | */ | 159 | */ |
155 | void mwait_idle_with_hints(unsigned long ax, unsigned long cx) | 160 | void mwait_idle_with_hints(unsigned long ax, unsigned long cx) |
156 | { | 161 | { |
162 | struct power_trace it; | ||
163 | |||
164 | trace_power_start(&it, POWER_CSTATE, (ax>>4)+1); | ||
157 | if (!need_resched()) { | 165 | if (!need_resched()) { |
158 | __monitor((void *)¤t_thread_info()->flags, 0, 0); | 166 | __monitor((void *)¤t_thread_info()->flags, 0, 0); |
159 | smp_mb(); | 167 | smp_mb(); |
160 | if (!need_resched()) | 168 | if (!need_resched()) |
161 | __mwait(ax, cx); | 169 | __mwait(ax, cx); |
162 | } | 170 | } |
171 | trace_power_end(&it); | ||
163 | } | 172 | } |
164 | 173 | ||
165 | /* Default MONITOR/MWAIT with no hints, used for default C1 state */ | 174 | /* Default MONITOR/MWAIT with no hints, used for default C1 state */ |
166 | static void mwait_idle(void) | 175 | static void mwait_idle(void) |
167 | { | 176 | { |
177 | struct power_trace it; | ||
168 | if (!need_resched()) { | 178 | if (!need_resched()) { |
179 | trace_power_start(&it, POWER_CSTATE, 1); | ||
169 | __monitor((void *)¤t_thread_info()->flags, 0, 0); | 180 | __monitor((void *)¤t_thread_info()->flags, 0, 0); |
170 | smp_mb(); | 181 | smp_mb(); |
171 | if (!need_resched()) | 182 | if (!need_resched()) |
172 | __sti_mwait(0, 0); | 183 | __sti_mwait(0, 0); |
173 | else | 184 | else |
174 | local_irq_enable(); | 185 | local_irq_enable(); |
186 | trace_power_end(&it); | ||
175 | } else | 187 | } else |
176 | local_irq_enable(); | 188 | local_irq_enable(); |
177 | } | 189 | } |
@@ -183,9 +195,13 @@ static void mwait_idle(void) | |||
183 | */ | 195 | */ |
184 | static void poll_idle(void) | 196 | static void poll_idle(void) |
185 | { | 197 | { |
198 | struct power_trace it; | ||
199 | |||
200 | trace_power_start(&it, POWER_CSTATE, 0); | ||
186 | local_irq_enable(); | 201 | local_irq_enable(); |
187 | while (!need_resched()) | 202 | while (!need_resched()) |
188 | cpu_relax(); | 203 | cpu_relax(); |
204 | trace_power_end(&it); | ||
189 | } | 205 | } |
190 | 206 | ||
191 | /* | 207 | /* |