Skip to contentSkip to conversation

ftrace: add notrace to ARM sched_clock routines

PATCH In review Tim Bird 3 participants 5 messages May 1, 2009

Subsystems (6)
lore
Share & tools
lore

Tim Bird

author
#0 lore raw

PATCH 1/2 ftrace: add notrace to ARM sched_clock routines

Add notrace attribute to sched_clock, to avoid
recursion with ftrace function_graph tracing.

---
 arch/arm/mach-mmp/time.c       |    2 +-
 arch/arm/mach-pxa/time.c       |    2 +-
 arch/arm/mach-realview/core.c  |    2 +-
 arch/arm/mach-sa1100/generic.c |    2 +-
 arch/arm/mach-versatile/core.c |    2 +-
 arch/arm/plat-omap/common.c    |    4 ++--
 6 files changed, 7 insertions(+), 7 deletions(-)
arch/arm/mach-mmp/time.c +1 -1
@@ -72,7 +72,7 @@ static inline uint32_t timer_read(void)
 	return __raw_readl(TIMERS_VIRT_BASE + TMR_CVWR(0));
 }
 
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(timer_read());
 	return (v * tcr2ns_scale) >> TCR2NS_SCALE_FACTOR;
arch/arm/mach-pxa/time.c +1 -1
@@ -51,7 +51,7 @@ static void __init set_oscr2ns_scale(uns
 		oscr2ns_scale++;
 }
 
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(OSCR);
 	return (v * oscr2ns_scale) >> OSCR2NS_SCALE_FACTOR;
arch/arm/mach-realview/core.c +1 -1
@@ -60,7 +60,7 @@ void __iomem *gic_cpu_base_addr;
  * This is the RealView sched_clock implementation.  This has
  * a resolution of 41.7ns, and a maximum value of about 179s.
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v;
 
arch/arm/mach-sa1100/generic.c +1 -1
@@ -131,7 +131,7 @@ EXPORT_SYMBOL(cpufreq_get);
  *
  *  ( * 1E9 / 3686400 => * 78125 / 288)
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(OSCR);
 
arch/arm/mach-versatile/core.c +1 -1
@@ -237,7 +237,7 @@ void __init versatile_map_io(void)
  * long as there is always less than 89 seconds between successive
  * calls to this function.
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(readl(VERSATILE_REFCOUNTER));
 
arch/arm/plat-omap/common.c +2 -2
@@ -185,7 +185,7 @@ console_initcall(omap_add_serial_console
 
 #include <linux/clocksource.h>
 
-static cycle_t omap_32k_read(struct clocksource *cs)
+static cycle_t notrace omap_32k_read(struct clocksource *cs)
 {
 	return omap_readl(TIMER_32K_SYNCHRONIZED);
 }
@@ -203,7 +203,7 @@ static struct clocksource clocksource_32
  * Returns current time from boot in nsecs. It's OK for this to wrap
  * around for now, as it's just a relative time stamp.
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long ret;
 
#1 lore raw
Quoted 2 lines · Tim Bird

Add notrace attribute to sched_clock, to avoid
recursion with ftrace function_graph tracing.

If there's nothing in those files that you don't really want to trace anyway, you could just disable the tracing from those files:

For example, in the Makefile add:

CFLAGS_REMOVE_time.o := -pg

-- Steve

Quoted 88 lines
---
 arch/arm/mach-mmp/time.c       |    2 +-
 arch/arm/mach-pxa/time.c       |    2 +-
 arch/arm/mach-realview/core.c  |    2 +-
 arch/arm/mach-sa1100/generic.c |    2 +-
 arch/arm/mach-versatile/core.c |    2 +-
 arch/arm/plat-omap/common.c    |    4 ++--
 6 files changed, 7 insertions(+), 7 deletions(-)
arch/arm/mach-mmp/time.c +1 -1
@@ -72,7 +72,7 @@ static inline uint32_t timer_read(void)
 	return __raw_readl(TIMERS_VIRT_BASE + TMR_CVWR(0));
 }
 
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(timer_read());
 	return (v * tcr2ns_scale) >> TCR2NS_SCALE_FACTOR;
arch/arm/mach-pxa/time.c +1 -1
@@ -51,7 +51,7 @@ static void __init set_oscr2ns_scale(uns
 		oscr2ns_scale++;
 }
 
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(OSCR);
 	return (v * oscr2ns_scale) >> OSCR2NS_SCALE_FACTOR;
arch/arm/mach-realview/core.c +1 -1
@@ -60,7 +60,7 @@ void __iomem *gic_cpu_base_addr;
  * This is the RealView sched_clock implementation.  This has
  * a resolution of 41.7ns, and a maximum value of about 179s.
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v;
 
arch/arm/mach-sa1100/generic.c +1 -1
@@ -131,7 +131,7 @@ EXPORT_SYMBOL(cpufreq_get);
  *
  *  ( * 1E9 / 3686400 => * 78125 / 288)
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(OSCR);
 
arch/arm/mach-versatile/core.c +1 -1
@@ -237,7 +237,7 @@ void __init versatile_map_io(void)
  * long as there is always less than 89 seconds between successive
  * calls to this function.
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(readl(VERSATILE_REFCOUNTER));
 
arch/arm/plat-omap/common.c +2 -2
@@ -185,7 +185,7 @@ console_initcall(omap_add_serial_console
 
 #include <linux/clocksource.h>
 
-static cycle_t omap_32k_read(struct clocksource *cs)
+static cycle_t notrace omap_32k_read(struct clocksource *cs)
 {
 	return omap_readl(TIMER_32K_SYNCHRONIZED);
 }
@@ -203,7 +203,7 @@ static struct clocksource clocksource_32
  * Returns current time from boot in nsecs. It's OK for this to wrap
  * around for now, as it's just a relative time stamp.
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long ret;
 
Acked-by on v1 1/2
#2 lore raw
In reply to Tim Bird
Quoted 80 lines · Tim Bird

Add notrace attribute to sched_clock, to avoid
recursion with ftrace function_graph tracing.

---
 arch/arm/mach-mmp/time.c       |    2 +-
 arch/arm/mach-pxa/time.c       |    2 +-
 arch/arm/mach-realview/core.c  |    2 +-
 arch/arm/mach-sa1100/generic.c |    2 +-
 arch/arm/mach-versatile/core.c |    2 +-
 arch/arm/plat-omap/common.c    |    4 ++--
 6 files changed, 7 insertions(+), 7 deletions(-)
arch/arm/mach-mmp/time.c +1 -1
@@ -72,7 +72,7 @@ static inline uint32_t timer_read(void)
 	return __raw_readl(TIMERS_VIRT_BASE + TMR_CVWR(0));
 }
 
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(timer_read());
 	return (v * tcr2ns_scale) >> TCR2NS_SCALE_FACTOR;
arch/arm/mach-pxa/time.c +1 -1
@@ -51,7 +51,7 @@ static void __init set_oscr2ns_scale(uns
 		oscr2ns_scale++;
 }
 
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(OSCR);
 	return (v * oscr2ns_scale) >> OSCR2NS_SCALE_FACTOR;
arch/arm/mach-realview/core.c +1 -1
@@ -60,7 +60,7 @@ void __iomem *gic_cpu_base_addr;
  * This is the RealView sched_clock implementation.  This has
  * a resolution of 41.7ns, and a maximum value of about 179s.
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v;
 
arch/arm/mach-sa1100/generic.c +1 -1
@@ -131,7 +131,7 @@ EXPORT_SYMBOL(cpufreq_get);
  *
  *  ( * 1E9 / 3686400 => * 78125 / 288)
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(OSCR);
 
arch/arm/mach-versatile/core.c +1 -1
@@ -237,7 +237,7 @@ void __init versatile_map_io(void)
  * long as there is always less than 89 seconds between successive
  * calls to this function.
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long v = cnt32_to_63(readl(VERSATILE_REFCOUNTER));
 
arch/arm/plat-omap/common.c +1 -1
@@ -185,7 +185,7 @@ console_initcall(omap_add_serial_console
 
 #include <linux/clocksource.h>
 
-static cycle_t omap_32k_read(struct clocksource *cs)
+static cycle_t notrace omap_32k_read(struct clocksource *cs)
 {
 	return omap_readl(TIMER_32K_SYNCHRONIZED);
 }

arch/arm/plat-omap/common.c static struct clocksource clocksource_32 · line 208

Quoted 7 lines
arch/arm/plat-omap/common.c +1 -1
@@ -203,7 +203,7 @@ static struct clocksource clocksource_32
  * Returns current time from boot in nsecs. It's OK for this to wrap
  * around for now, as it's just a relative time stamp.
  */
-unsigned long long sched_clock(void)
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long ret;

I've looked into all of these functions and they don't seem to call anything that could be traced. I could have missed something though but it looks good.

#3 lore raw
Quoted 6 lines · Frederic Weisbecker
Quoted 6 lines

}

arch/arm/plat-omap/common.c +0 -1
@@ -203,7 +203,7 @@ static struct clocksource clocksource_32
  * Returns current time from boot in nsecs. It's OK for this to wrap
  * around for now, as it's just a relative time stamp.
  */
-unsigned long long sched_clock(void)
Quoted 8 lines

arch/arm/plat-omap/common.c static struct clocksource clocksource_32 · line 208

Quoted 3 lines
arch/arm/plat-omap/common.c +1 -0
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long ret;

I've looked into all of these functions and they don't seem to call anything that could be traced. I could have missed something though but it looks good.

I think the issue is that the tracing clock will call these functions, and we will waste time recursing into them.

Quoted 2 lines

Heck I'll add mine too ;-)

-- Steve

#4 lore raw
Quoted 17 lines · Steven Rostedt
Quoted 6 lines · Frederic Weisbecker
Quoted 6 lines

}

arch/arm/plat-omap/common.c +0 -1
@@ -203,7 +203,7 @@ static struct clocksource clocksource_32
  * Returns current time from boot in nsecs. It's OK for this to wrap
  * around for now, as it's just a relative time stamp.
  */
-unsigned long long sched_clock(void)
Quoted 8 lines

arch/arm/plat-omap/common.c static struct clocksource clocksource_32 · line 208

Quoted 3 lines
arch/arm/plat-omap/common.c +1 -0
+unsigned long long notrace sched_clock(void)
 {
 	unsigned long long ret;

I've looked into all of these functions and they don't seem to call anything that could be traced. I could have missed something though but it looks good.

Quoted 2 lines

I think the issue is that the tracing clock will call these functions, and we will waste time recursing into them.

Indeed, but I wanted to ensure that none of these sched_clock() were calling any traceable function, or it would recurse inside the function graph low level helpers which are not protected. Hence an endless stack overrun which ends up on an immediate reboot :)

But it looks good.

Quoted 9 lines
Quoted 2 lines

Heck I'll add mine too ;-)

-- Steve