[ltt-dev] multiple definition of `trace_clock' problem on linux-2.6.30-rc5

Mathieu Desnoyers compudj at krystal.dyndns.org
Thu May 28 10:52:02 EDT 2009


* Steve Langstaff (steve.langstaff at pebblebay.com) wrote:
> Hi All.
> 
> I am having the following trouble compiling kernel linux-2.6.30-rc5 when
> patched with patch-2.6.30-rc5-lttng-0.136 and wondered if this is a known
> problem...
> 
> ...
>   LD      kernel/time/built-in.o
>   CC      kernel/trace/ring_buffer.o
>   CC      kernel/trace/trace.o
>   CC      kernel/trace/trace_clock.o
>   CC      kernel/trace/trace_output.o
>   CC      kernel/trace/trace_stat.o
>   CC      kernel/trace/trace_printk.o
>   CC      kernel/trace/trace_nop.o
>   CC      kernel/trace/trace-clock-32-to-64.o
>   CC      kernel/trace/trace-clock.o
>   LD      kernel/trace/built-in.o
> kernel/trace/trace-clock.o:(.bss+0x0): multiple definition of `trace_clock'
> kernel/trace/trace_clock.o:trace_clock.c:(.text+0x0): first defined here
> arm-linux-ld: Warning: size of symbol `trace_clock' changed from 8 in
> kernel/trace/trace_clock.o to 4 in kernel/trace/trace-clock.o
> arm-linux-ld: Warning: type of symbol `trace_clock' changed from 2 to 1 in
> kernel/trace/trace-clock.o
> make[2]: *** [kernel/trace/built-in.o] Error 1
> make[1]: *** [kernel/trace] Error 2
> make: *** [kernel] Error 2
> 
> I *think* that this is because the symbol trace_clock appears as both a
> variable and a function.
> 
> FILE: include/asm-generic/trace-clock.h:
> 
> extern atomic_long_t trace_clock;
> 
> and
> 
> FILE: kernel/trace/trace_clock.c:
> 
> u64 notrace trace_clock(void)
> {
> 	return cpu_clock(raw_smp_processor_id());
> }
> 

Hrm, yes. This is caused by ftrace. But given they are in mainline and
LTTng isn't, the LTTng trace clock identifier will have to move.

Can you try the following patch ?


Trace clock: rename generic identifier

> I am having the following trouble compiling kernel linux-2.6.30-rc5 when
> patched with patch-2.6.30-rc5-lttng-0.136 and wondered if this is a known
> problem...
> 
> ...
>   LD      kernel/time/built-in.o
>   CC      kernel/trace/ring_buffer.o
>   CC      kernel/trace/trace.o
>   CC      kernel/trace/trace_clock.o
>   CC      kernel/trace/trace_output.o
>   CC      kernel/trace/trace_stat.o
>   CC      kernel/trace/trace_printk.o
>   CC      kernel/trace/trace_nop.o
>   CC      kernel/trace/trace-clock-32-to-64.o
>   CC      kernel/trace/trace-clock.o
>   LD      kernel/trace/built-in.o
> kernel/trace/trace-clock.o:(.bss+0x0): multiple definition of `trace_clock'
> kernel/trace/trace_clock.o:trace_clock.c:(.text+0x0): first defined here
> arm-linux-ld: Warning: size of symbol `trace_clock' changed from 8 in
> kernel/trace/trace_clock.o to 4 in kernel/trace/trace-clock.o
> arm-linux-ld: Warning: type of symbol `trace_clock' changed from 2 to 1 in
> kernel/trace/trace-clock.o
> make[2]: *** [kernel/trace/built-in.o] Error 1
> make[1]: *** [kernel/trace] Error 2
> make: *** [kernel] Error 2
> 
> I *think* that this is because the symbol trace_clock appears as both a
> variable and a function.
> 
> FILE: include/asm-generic/trace-clock.h:
> 
> extern atomic_long_t trace_clock;
> 
> and
> 
> FILE: kernel/trace/trace_clock.c:
> 
> u64 notrace trace_clock(void)
> {
>       return cpu_clock(raw_smp_processor_id());
> }
> 

Hrm, yes. This is caused by ftrace. But given they are in mainline and 
LTTng isn't, the LTTng trace clock identifier will have to move.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at polymtl.ca>
---
 include/asm-generic/trace-clock.h |    6 +++---
 kernel/trace/trace-clock.c        |    8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

Index: linux-2.6-lttng/include/asm-generic/trace-clock.h
===================================================================
--- linux-2.6-lttng.orig/include/asm-generic/trace-clock.h	2009-05-28 10:23:03.000000000 -0400
+++ linux-2.6-lttng/include/asm-generic/trace-clock.h	2009-05-28 10:23:45.000000000 -0400
@@ -26,11 +26,11 @@
 /* Expected maximum interrupt latency in ms : 15ms, *2 for security */
 #define TC_EXPECTED_INTERRUPT_LATENCY	30
 
-extern atomic_long_t trace_clock;
+extern atomic_long_t trace_clock_var;
 
 static inline u32 trace_clock_read32(void)
 {
-	return (u32)atomic_long_add_return(1, &trace_clock);
+	return (u32)atomic_long_add_return(1, &trace_clock_var);
 }
 
 #ifdef CONFIG_HAVE_TRACE_CLOCK_32_TO_64
@@ -53,7 +53,7 @@ static inline void put_synthetic_tsc(voi
 
 static inline u64 trace_clock_read64(void)
 {
-	return atomic_long_add_return(1, &trace_clock);
+	return atomic_long_add_return(1, &trace_clock_var);
 }
 #endif
 
Index: linux-2.6-lttng/kernel/trace/trace-clock.c
===================================================================
--- linux-2.6-lttng.orig/kernel/trace/trace-clock.c	2009-05-28 10:24:34.000000000 -0400
+++ linux-2.6-lttng/kernel/trace/trace-clock.c	2009-05-28 10:25:04.000000000 -0400
@@ -25,8 +25,8 @@ static struct timer_list trace_clock_tim
  * bits 0..12 : counter, atomically incremented
  * bits 13..{32,64} : time counter, incremented each jiffy.
  */
-atomic_long_t trace_clock;
-EXPORT_SYMBOL(trace_clock);
+atomic_long_t trace_clock_var;
+EXPORT_SYMBOL(trace_clock_var);
 
 static void trace_clock_update(void)
 {
@@ -41,10 +41,10 @@ static void trace_clock_update(void)
 	if (unlikely(!ticks))
 		return;
 	do {
-		old_clock = atomic_long_read(&trace_clock);
+		old_clock = atomic_long_read(&trace_clock_var);
 		new_clock = (old_clock + (ticks << TRACE_CLOCK_SHIFT))
 			& (~((1 << TRACE_CLOCK_SHIFT) - 1));
-	} while (atomic_long_cmpxchg(&trace_clock, old_clock, new_clock)
+	} while (atomic_long_cmpxchg(&trace_clock_var, old_clock, new_clock)
 			!= old_clock);
 }
 


-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68




More information about the lttng-dev mailing list