Skip to contentSkip to conversation

arm64: add cpu_idle tracepoints to arch_cpu_idle

PATCH Applied Jisheng Zhang 3 participants 7 messages Sep 16, 2015 – Oct 19, 2015 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: add cpu_idle tracepoints to arch_cpu_idle

Currently, if cpuidle is disabled or not supported, powertop reports zero wakeups and zero events. This is due to the cpu_idle tracepoints are missing.

This patch is to make cpu_idle tracepoints always available even if cpuidle is disabled or not supported.

---
 arch/arm64/kernel/process.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/kernel/process.c +3 -0
index 223b093..f75b540 100644
@@ -44,6 +44,7 @@
 #include <linux/hw_breakpoint.h>
 #include <linux/personality.h>
 #include <linux/notifier.h>
+#include <trace/events/power.h>
 
 #include <asm/compat.h>
 #include <asm/cacheflush.h>
@@ -75,8 +76,10 @@ void arch_cpu_idle(void)
 	 * This should do all the clock switching and wait for interrupt
 	 * tricks
 	 */
+	trace_cpu_idle_rcuidle(1, smp_processor_id());
 	cpu_do_idle();
 	local_irq_enable();
+	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
Signature · 1 line
2.5.1
#1 lore raw
Quoted 8 lines · Jisheng Zhang

Currently, if cpuidle is disabled or not supported, powertop reports zero wakeups and zero events. This is due to the cpu_idle tracepoints are missing.

This patch is to make cpu_idle tracepoints always available even if cpuidle is disabled or not supported.

Is there a reason why this code cannot be moved to the generic idle loop ?

Thanks,
Lorenzo

Quoted 36 lines
---
 arch/arm64/kernel/process.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/kernel/process.c +3 -0
index 223b093..f75b540 100644
@@ -44,6 +44,7 @@
 #include <linux/hw_breakpoint.h>
 #include <linux/personality.h>
 #include <linux/notifier.h>
+#include <trace/events/power.h>
 
 #include <asm/compat.h>
 #include <asm/cacheflush.h>
@@ -75,8 +76,10 @@ void arch_cpu_idle(void)
 	 * This should do all the clock switching and wait for interrupt
 	 * tricks
 	 */
+	trace_cpu_idle_rcuidle(1, smp_processor_id());
 	cpu_do_idle();
 	local_irq_enable();
+	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
Signature · 7 lines
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#2 lore raw

Dear Lorenzo,

Quoted 11 lines · On Wed, 16 Sep 2015 15:47:38 +0100 Lorenzo Pieralisi…
Quoted 8 lines · Jisheng Zhang

Currently, if cpuidle is disabled or not supported, powertop reports zero wakeups and zero events. This is due to the cpu_idle tracepoints are missing.

This patch is to make cpu_idle tracepoints always available even if cpuidle is disabled or not supported.

Is there a reason why this code cannot be moved to the generic idle loop ?

Do you mean the cpu_idle_loop() in kernel/sched/idle.c? To be honest, I dunno. Maybe kernel experts can give some hints.

Thanks,
Jisheng

Quoted 40 lines

Thanks,
Lorenzo

Quoted 36 lines
---
 arch/arm64/kernel/process.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/kernel/process.c +3 -0
index 223b093..f75b540 100644
@@ -44,6 +44,7 @@
 #include <linux/hw_breakpoint.h>
 #include <linux/personality.h>
 #include <linux/notifier.h>
+#include <trace/events/power.h>
 
 #include <asm/compat.h>
 #include <asm/cacheflush.h>
@@ -75,8 +76,10 @@ void arch_cpu_idle(void)
 	 * This should do all the clock switching and wait for interrupt
 	 * tricks
 	 */
+	trace_cpu_idle_rcuidle(1, smp_processor_id());
 	cpu_do_idle();
 	local_irq_enable();
+	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
Signature · 7 lines
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#3 lore raw

Dear Lorenzo,

Quoted 10 lines · On Wed, 16 Sep 2015 22:53:12 +0800 Jisheng Zhang <[email protected]> wrote:

Dear Lorenzo,

Quoted 5 lines · On Wed, 16 Sep 2015 15:47:38 +0100 Lorenzo Pieralisi…
Quoted 4 lines · Jisheng Zhang

Currently, if cpuidle is disabled or not supported, powertop reports zero wakeups and zero events. This is due to the cpu_idle tracepoints are missing.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

This patch is to make cpu_idle tracepoints always available even if cpuidle is disabled or not supported.

Is there a reason why this code cannot be moved to the generic idle loop ?

Do you mean the cpu_idle_loop() in kernel/sched/idle.c? To be honest, I

Maybe I know now. we need to trace different idle level, for example:

WFI idle: trace_cpu_idle_rcuidle(1, ...);

deeper idle: trace_cpu_idle_rcuidle(2, ...);

Usually, the first argument of trace_cpu_idle_rcuidle() equals to the index of the idle level.

so generic idle loop is not a good candidate.

Quoted 51 lines

dunno. Maybe kernel experts can give some hints.

Thanks,
Jisheng

Quoted 34 lines

Thanks,
Lorenzo

Quoted 30 lines
---
 arch/arm64/kernel/process.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/kernel/process.c +3 -0
index 223b093..f75b540 100644
@@ -44,6 +44,7 @@
 #include <linux/hw_breakpoint.h>
 #include <linux/personality.h>
 #include <linux/notifier.h>
+#include <trace/events/power.h>
 
 #include <asm/compat.h>
 #include <asm/cacheflush.h>
@@ -75,8 +76,10 @@ void arch_cpu_idle(void)
 	 * This should do all the clock switching and wait for interrupt
 	 * tricks
 	 */
+	trace_cpu_idle_rcuidle(1, smp_processor_id());
 	cpu_do_idle();
 	local_irq_enable();
+	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
Signature · 1 line
2.5.1
Quoted 6 lines
Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#4 lore raw
Quoted 26 lines · Jisheng Zhang

Dear Lorenzo,

Quoted 10 lines · On Wed, 16 Sep 2015 22:53:12 +0800 Jisheng Zhang <[email protected]> wrote:

Dear Lorenzo,

Quoted 5 lines · On Wed, 16 Sep 2015 15:47:38 +0100 Lorenzo Pieralisi…
Quoted 4 lines · Jisheng Zhang

Currently, if cpuidle is disabled or not supported, powertop reports zero wakeups and zero events. This is due to the cpu_idle tracepoints are missing.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

This patch is to make cpu_idle tracepoints always available even if cpuidle is disabled or not supported.

Is there a reason why this code cannot be moved to the generic idle loop ?

Do you mean the cpu_idle_loop() in kernel/sched/idle.c? To be honest, I

Maybe I know now. we need to trace different idle level, for example:

Quoted 8 lines

WFI idle: trace_cpu_idle_rcuidle(1, ...);

deeper idle: trace_cpu_idle_rcuidle(2, ...);

Usually, the first argument of trace_cpu_idle_rcuidle() equals to the index of the idle level.

so generic idle loop is not a good candidate.

You are adding a trace for tracing state 1 (ie default idle state), called from arch_cpu_idle(), which is the default idle call when the CPUidle framework is not available, so I suggested moving the traces you add to arm/arm64 arch_cpu_idle() calls to kernel/sched/idle.c (see default_idle_call()) instead of patching architecture code.

I think you can't do that because on x86 calling arch_cpu_idle() does not always mean entering idle state index 1 if I read the code correctly (in particular the mwait based implementation - mwait_idle()).

So never mind, patch is fine (on arm64, on arm you should be careful because some arm_pm_idle implementations trace state 1 already - see omap3_pm_idle and if you add traces to arch_cpu_idle you should remove the traces from mach implementations).

#5 lore raw
Quoted 42 lines · On Wed, 16 Sep 2015 17:16:05 +0100 Lorenzo Pieralisi…
Quoted 26 lines · Jisheng Zhang

Dear Lorenzo,

Quoted 10 lines · On Wed, 16 Sep 2015 22:53:12 +0800 Jisheng Zhang <[email protected]> wrote:

Dear Lorenzo,

Quoted 5 lines · On Wed, 16 Sep 2015 15:47:38 +0100 Lorenzo Pieralisi…
Quoted 4 lines · Jisheng Zhang

Currently, if cpuidle is disabled or not supported, powertop reports zero wakeups and zero events. This is due to the cpu_idle tracepoints are missing.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

This patch is to make cpu_idle tracepoints always available even if cpuidle is disabled or not supported.

Is there a reason why this code cannot be moved to the generic idle loop ?

Do you mean the cpu_idle_loop() in kernel/sched/idle.c? To be honest, I

Maybe I know now. we need to trace different idle level, for example:

Quoted 8 lines

WFI idle: trace_cpu_idle_rcuidle(1, ...);

deeper idle: trace_cpu_idle_rcuidle(2, ...);

Usually, the first argument of trace_cpu_idle_rcuidle() equals to the index of the idle level.

so generic idle loop is not a good candidate.

You are adding a trace for tracing state 1 (ie default idle state), called from arch_cpu_idle(), which is the default idle call when the CPUidle framework is not available, so I suggested moving the traces you add to arm/arm64 arch_cpu_idle() calls to kernel/sched/idle.c (see default_idle_call()) instead of patching architecture code.

Quoted 8 lines

I think you can't do that because on x86 calling arch_cpu_idle() does not always mean entering idle state index 1 if I read the code correctly (in particular the mwait based implementation - mwait_idle()).

So never mind, patch is fine (on arm64, on arm you should be careful because some arm_pm_idle implementations trace state 1 already - see omap3_pm_idle and if you add traces to arch_cpu_idle you should remove the traces from mach implementations).

OOPs, I was debugging the cascaded irq issues on Marvell BG4CT SoC. Yes, this arm_pm_idle should be taken care on arm, I should ignore arm_pm_idle, I'll cook v2 for arm platform.

Thanks a lot,
Jisheng

Quoted 2 lines
maintainer Applied
#6 lore raw
In reply to Jisheng Zhang
Quoted 8 lines · Jisheng Zhang

Currently, if cpuidle is disabled or not supported, powertop reports zero wakeups and zero events. This is due to the cpu_idle tracepoints are missing.

This patch is to make cpu_idle tracepoints always available even if cpuidle is disabled or not supported.

Queued for 4.4. Thanks.

Signature · 1 line
Catalin