[ltt-dev] [PATCH 2/3] ltt: rework trace clock code for SH

Mathieu Desnoyers compudj at krystal.dyndns.org
Tue Apr 6 10:42:27 EDT 2010


* Giuseppe CAVALLARO (peppe.cavallaro at st.com) wrote:
> Trace clock definitions for SuperH are broken in the new Kernels.
> This patch reworks the code using the clocksource API to handle
> trace clock. For example, on ST Kernels the TMU channel 1 continues
> to be used as clocksource and all works fine for LTT.
> 
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro at st.com>
> ---
>  arch/sh/include/asm/trace-clock.h |   22 ++++++++++++++--------
>  1 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/sh/include/asm/trace-clock.h b/arch/sh/include/asm/trace-clock.h
> index 7dfa042..667530b 100644
> --- a/arch/sh/include/asm/trace-clock.h
> +++ b/arch/sh/include/asm/trace-clock.h
> @@ -8,8 +8,7 @@
>  #ifndef _ASM_SH_TRACE_CLOCK_H
>  #define _ASM_SH_TRACE_CLOCK_H
>  
> -#include <linux/timer.h>
> -#include <asm/clock.h>
> +#include <linux/clocksource.h>
>  
>  /*
>   * Number of hardware clock bits. The higher order bits are expected to be 0.
> @@ -23,11 +22,15 @@
>  /* Expected maximum interrupt latency in ms : 15ms, *2 for security */
>  #define TC_EXPECTED_INTERRUPT_LATENCY	30
>  
> +static struct clocksource *clock;
> +
>  extern u64 trace_clock_read_synthetic_tsc(void);
>  
>  static inline u32 trace_clock_read32(void)
>  {
> -	return get_cycles();
> +	if (likely(clock))
> +		return (u32) clock->read(clock);

Can you walk us through the code that is executed when clock->read() is
called ?  Is it possible that the clock source read() takes a xtime seq
read lock in some SH configurations ?

If it is the case, then we will run into deadlocks with tracing code
called from within the xtime seq write lock. Therefore, fixing this
without calling the clocksource read() would be adequate.

Thanks,

Mathieu

> +	return 0;
>  }
>  
>  static inline u64 trace_clock_read64(void)
> @@ -37,13 +40,16 @@ static inline u64 trace_clock_read64(void)
>  
>  static inline u64 trace_clock_frequency(void)
>  {
> -	u64 rate;
> -	struct clk *tmu1_clk;
> +	clock = clocksource_get_next();
>  
> -	tmu1_clk = clk_get(NULL, "tmu1_clk");
> -	rate = clk_get_rate(tmu1_clk);
> +	if (unlikely(!clock)) {
> +		pr_err("%s: clocksource not found\n", __func__);
> +		return 0;
> +	} else
> +		pr_debug("%s: %s clocksource found (rating: %d)\n",
> +			 __func__, clock->name,	clock->rating);
>  
> -	return rate;
> +	return (u64) (clock->rating * 1000000);
>  }
>  
>  static inline u32 trace_clock_freq_scale(void)
> -- 
> 1.6.0.4
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




More information about the lttng-dev mailing list