public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* (forw) [RFC patch 08/15] LTTng - Timestamping
@ 2008-10-17 16:58 Mathieu Desnoyers
  2008-10-18 22:14 ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Mathieu Desnoyers @ 2008-10-17 16:58 UTC (permalink / raw)
  To: ltt-dev, mbligh, systemtap

Hello,

Too many CCs on this last post. I should probably have added some, but
here is a link to the thread :

http://lkml.org/lkml/2008/10/16/511

Comments are welcome.

Mathieu

----- Forwarded message from Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> -----

Date: Thu, 16 Oct 2008 19:27:37 -0400
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: David Miller <davem@davemloft.net>,
	Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
	Ralf Baechle <ralf@linux-mips.org>, benh@kernel.crashing.org,
	paulus@samba.org, Ingo Molnar <mingo@redhat.com>
User-Agent: quilt/0.46-1
From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Subject: [RFC patch 08/15] LTTng - Timestamping

Wrapper to use the lower level clock sources available on the systems. Fall-back
on jiffies or'd with a logical clock for architectures lacking CPU timestamp
counters. Fall-back on a mixed TSC-logical clock on architectures lacking
synchronized TSC on SMP.

A generic fallback based on a logical clock and the timer interrupt is
available.

generic - Uses jiffies or'd with a logical clock extended to 64 bits by
          ltt-timestamp.c.
i386 - Uses TSC. If detects non synchronized TSC, uses mixed TSC-logical clock.
mips - Uses TSC extended atomically from 32 to 64 bits by ltt-heartbeat.c.
powerpc - Uses TSC or generic ltt clock.
x86_64 - Uses TSC. If detects non synchronized TSC, uses mixed TSC-logical clock

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: benh@kernel.crashing.org
CC: paulus@samba.org
CC: David Miller <davem@davemloft.net>
CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Ingo Molnar <mingo@redhat.com>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: linux-arch@vger.kernel.org
---
 include/asm-generic/ltt.h |   53 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/ltt.h       |   27 +++++++++++++++++++++++
 kernel/timer.c            |    2 +
 3 files changed, 82 insertions(+)

Index: linux-2.6-lttng/kernel/timer.c
===================================================================
--- linux-2.6-lttng.orig/kernel/timer.c	2008-09-16 14:50:15.000000000 -0400
+++ linux-2.6-lttng/kernel/timer.c	2008-09-16 14:59:17.000000000 -0400
@@ -37,6 +37,7 @@
 #include <linux/delay.h>
 #include <linux/tick.h>
 #include <linux/kallsyms.h>
+#include <linux/ltt.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -1066,6 +1067,7 @@ void do_timer(unsigned long ticks)
 {
 	jiffies_64 += ticks;
 	update_times(ticks);
+	ltt_add_timestamp(ticks);
 }
 
 #ifdef __ARCH_WANT_SYS_ALARM
Index: linux-2.6-lttng/include/linux/ltt.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/include/linux/ltt.h	2008-09-16 14:58:47.000000000 -0400
@@ -0,0 +1,27 @@
+#ifndef _LINUX_LTT_H
+#define _LINUX_LTT_H
+
+/*
+ * Generic LTT clock.
+ *
+ * Chooses between an architecture specific clock or an atomic logical clock.
+ *
+ * Copyright (C) 2007 Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
+ */
+
+#ifdef CONFIG_LTT_TIMESTAMP
+#ifdef CONFIG_HAVE_LTT_CLOCK
+#include <asm/ltt.h>
+#else
+#include <asm-generic/ltt.h>
+
+#define ltt_get_timestamp32	ltt_get_timestamp32_generic
+#define ltt_get_timestamp64	ltt_get_timestamp64_generic
+#define ltt_add_timestamp	ltt_add_timestamp_generic
+#define ltt_frequency		ltt_frequency_generic
+#define ltt_freq_scale		ltt_freq_scale_generic
+#endif /* CONFIG_HAVE_LTT_CLOCK */
+#else
+#define ltt_add_timestamp(ticks)
+#endif /* CONFIG_LTT_TIMESTAMP */
+#endif /* _LINUX_LTT_H */
Index: linux-2.6-lttng/include/asm-generic/ltt.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/include/asm-generic/ltt.h	2008-09-16 14:58:47.000000000 -0400
@@ -0,0 +1,53 @@
+#ifndef _ASM_GENERIC_LTT_H
+#define _ASM_GENERIC_LTT_H
+
+/*
+ * linux/include/asm-generic/ltt.h
+ *
+ * Copyright (C) 2007 - Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
+ *
+ * Generic definitions for LTT
+ * Architectures without TSC
+ */
+
+#include <linux/param.h>	/* For HZ */
+#include <asm/atomic.h>
+
+#define LTT_GENERIC_CLOCK_SHIFT 13
+
+u64 ltt_read_synthetic_tsc(void);
+
+extern atomic_t lttng_generic_clock;
+
+static inline u32 ltt_get_timestamp32_generic(void)
+{
+	return atomic_add_return(1, &lttng_generic_clock);
+}
+
+static inline u64 ltt_get_timestamp64_generic(void)
+{
+	return ltt_read_synthetic_tsc();
+}
+
+static inline void ltt_add_timestamp_generic(unsigned long ticks)
+{
+	int old_clock, new_clock;
+
+	do {
+		old_clock = atomic_read(&lttng_generic_clock);
+		new_clock = (old_clock + (ticks << LTT_GENERIC_CLOCK_SHIFT))
+			& (~((1 << LTT_GENERIC_CLOCK_SHIFT) - 1));
+	} while (atomic_cmpxchg(&lttng_generic_clock, old_clock, new_clock)
+			!= old_clock);
+}
+
+static inline unsigned int ltt_frequency_generic(void)
+{
+	return HZ << LTT_GENERIC_CLOCK_SHIFT;
+}
+
+static inline u32 ltt_freq_scale_generic(void)
+{
+	return 1;
+}
+#endif /* _ASM_GENERIC_LTT_H */

-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

----- End forwarded message -----

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: (forw) [RFC patch 08/15] LTTng - Timestamping
  2008-10-17 16:58 (forw) [RFC patch 08/15] LTTng - Timestamping Mathieu Desnoyers
@ 2008-10-18 22:14 ` Masami Hiramatsu
  2008-10-20 15:50   ` [ltt-dev] " Mathieu Desnoyers
  2008-10-22 16:27   ` Mathieu Desnoyers
  0 siblings, 2 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2008-10-18 22:14 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: ltt-dev, mbligh, systemtap

Hi Mathieu,

These patches seems generally good. However, I wonder why you added
"ltt_" prefix. if it was useful for other parts of the kernel
(I think so), more general name(generic_timestamp?) would be preferable :)

Thank you,

Mathieu Desnoyers wrote:
> Hello,
> 
> Too many CCs on this last post. I should probably have added some, but
> here is a link to the thread :
> 
> http://lkml.org/lkml/2008/10/16/511
> 
> Comments are welcome.
> 
> Mathieu
> 
> ----- Forwarded message from Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> -----
> 
> Date: Thu, 16 Oct 2008 19:27:37 -0400
> To: Linus Torvalds <torvalds@linux-foundation.org>,
> 	Andrew Morton <akpm@linux-foundation.org>,
> 	Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org,
> 	linux-arch@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>,
> 	Peter Zijlstra <a.p.zijlstra@chello.nl>,
> 	Thomas Gleixner <tglx@linutronix.de>
> Cc: David Miller <davem@davemloft.net>,
> 	Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
> 	Ralf Baechle <ralf@linux-mips.org>, benh@kernel.crashing.org,
> 	paulus@samba.org, Ingo Molnar <mingo@redhat.com>
> User-Agent: quilt/0.46-1
> From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> Subject: [RFC patch 08/15] LTTng - Timestamping
> 
> Wrapper to use the lower level clock sources available on the systems. Fall-back
> on jiffies or'd with a logical clock for architectures lacking CPU timestamp
> counters. Fall-back on a mixed TSC-logical clock on architectures lacking
> synchronized TSC on SMP.
> 
> A generic fallback based on a logical clock and the timer interrupt is
> available.
> 
> generic - Uses jiffies or'd with a logical clock extended to 64 bits by
>           ltt-timestamp.c.
> i386 - Uses TSC. If detects non synchronized TSC, uses mixed TSC-logical clock.
> mips - Uses TSC extended atomically from 32 to 64 bits by ltt-heartbeat.c.
> powerpc - Uses TSC or generic ltt clock.
> x86_64 - Uses TSC. If detects non synchronized TSC, uses mixed TSC-logical clock
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> CC: Ralf Baechle <ralf@linux-mips.org>
> CC: benh@kernel.crashing.org
> CC: paulus@samba.org
> CC: David Miller <davem@davemloft.net>
> CC: Linus Torvalds <torvalds@linux-foundation.org>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Steven Rostedt <rostedt@goodmis.org>
> CC: linux-arch@vger.kernel.org
> ---
>  include/asm-generic/ltt.h |   53 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/ltt.h       |   27 +++++++++++++++++++++++
>  kernel/timer.c            |    2 +
>  3 files changed, 82 insertions(+)
> 
> Index: linux-2.6-lttng/kernel/timer.c
> ===================================================================
> --- linux-2.6-lttng.orig/kernel/timer.c	2008-09-16 14:50:15.000000000 -0400
> +++ linux-2.6-lttng/kernel/timer.c	2008-09-16 14:59:17.000000000 -0400
> @@ -37,6 +37,7 @@
>  #include <linux/delay.h>
>  #include <linux/tick.h>
>  #include <linux/kallsyms.h>
> +#include <linux/ltt.h>
>  
>  #include <asm/uaccess.h>
>  #include <asm/unistd.h>
> @@ -1066,6 +1067,7 @@ void do_timer(unsigned long ticks)
>  {
>  	jiffies_64 += ticks;
>  	update_times(ticks);
> +	ltt_add_timestamp(ticks);
>  }
>  
>  #ifdef __ARCH_WANT_SYS_ALARM
> Index: linux-2.6-lttng/include/linux/ltt.h
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ linux-2.6-lttng/include/linux/ltt.h	2008-09-16 14:58:47.000000000 -0400
> @@ -0,0 +1,27 @@
> +#ifndef _LINUX_LTT_H
> +#define _LINUX_LTT_H
> +
> +/*
> + * Generic LTT clock.
> + *
> + * Chooses between an architecture specific clock or an atomic logical clock.
> + *
> + * Copyright (C) 2007 Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
> + */
> +
> +#ifdef CONFIG_LTT_TIMESTAMP
> +#ifdef CONFIG_HAVE_LTT_CLOCK
> +#include <asm/ltt.h>
> +#else
> +#include <asm-generic/ltt.h>
> +
> +#define ltt_get_timestamp32	ltt_get_timestamp32_generic
> +#define ltt_get_timestamp64	ltt_get_timestamp64_generic
> +#define ltt_add_timestamp	ltt_add_timestamp_generic
> +#define ltt_frequency		ltt_frequency_generic
> +#define ltt_freq_scale		ltt_freq_scale_generic
> +#endif /* CONFIG_HAVE_LTT_CLOCK */
> +#else
> +#define ltt_add_timestamp(ticks)
> +#endif /* CONFIG_LTT_TIMESTAMP */
> +#endif /* _LINUX_LTT_H */
> Index: linux-2.6-lttng/include/asm-generic/ltt.h
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ linux-2.6-lttng/include/asm-generic/ltt.h	2008-09-16 14:58:47.000000000 -0400
> @@ -0,0 +1,53 @@
> +#ifndef _ASM_GENERIC_LTT_H
> +#define _ASM_GENERIC_LTT_H
> +
> +/*
> + * linux/include/asm-generic/ltt.h
> + *
> + * Copyright (C) 2007 - Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
> + *
> + * Generic definitions for LTT
> + * Architectures without TSC
> + */
> +
> +#include <linux/param.h>	/* For HZ */
> +#include <asm/atomic.h>
> +
> +#define LTT_GENERIC_CLOCK_SHIFT 13
> +
> +u64 ltt_read_synthetic_tsc(void);
> +
> +extern atomic_t lttng_generic_clock;
> +
> +static inline u32 ltt_get_timestamp32_generic(void)
> +{
> +	return atomic_add_return(1, &lttng_generic_clock);
> +}
> +
> +static inline u64 ltt_get_timestamp64_generic(void)
> +{
> +	return ltt_read_synthetic_tsc();
> +}
> +
> +static inline void ltt_add_timestamp_generic(unsigned long ticks)
> +{
> +	int old_clock, new_clock;
> +
> +	do {
> +		old_clock = atomic_read(&lttng_generic_clock);
> +		new_clock = (old_clock + (ticks << LTT_GENERIC_CLOCK_SHIFT))
> +			& (~((1 << LTT_GENERIC_CLOCK_SHIFT) - 1));
> +	} while (atomic_cmpxchg(&lttng_generic_clock, old_clock, new_clock)
> +			!= old_clock);
> +}
> +
> +static inline unsigned int ltt_frequency_generic(void)
> +{
> +	return HZ << LTT_GENERIC_CLOCK_SHIFT;
> +}
> +
> +static inline u32 ltt_freq_scale_generic(void)
> +{
> +	return 1;
> +}
> +#endif /* _ASM_GENERIC_LTT_H */
> 

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ltt-dev] (forw) [RFC patch 08/15] LTTng - Timestamping
  2008-10-18 22:14 ` Masami Hiramatsu
@ 2008-10-20 15:50   ` Mathieu Desnoyers
  2008-10-22 16:27   ` Mathieu Desnoyers
  1 sibling, 0 replies; 5+ messages in thread
From: Mathieu Desnoyers @ 2008-10-20 15:50 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: ltt-dev, mbligh, systemtap

Yeah, well I had this stuff in the LTTng tree for about 3 years, so I
kept everything under my own namespace. I like Ingo's idea of
"trace_clock()". I'll probably change the namespace to this, and move
the files from /ltt/* to /kernel/trace/*.

Mathieu

* Masami Hiramatsu (mhiramat@redhat.com) wrote:
> Hi Mathieu,
>
> These patches seems generally good. However, I wonder why you added
> "ltt_" prefix. if it was useful for other parts of the kernel
> (I think so), more general name(generic_timestamp?) would be preferable :)
>
> Thank you,
>
> Mathieu Desnoyers wrote:
>> Hello,
>> Too many CCs on this last post. I should probably have added some, but
>> here is a link to the thread :
>> http://lkml.org/lkml/2008/10/16/511
>> Comments are welcome.
>> Mathieu
>> ----- Forwarded message from Mathieu Desnoyers 
>> <mathieu.desnoyers@polymtl.ca> -----
>> Date: Thu, 16 Oct 2008 19:27:37 -0400
>> To: Linus Torvalds <torvalds@linux-foundation.org>,
>> 	Andrew Morton <akpm@linux-foundation.org>,
>> 	Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org,
>> 	linux-arch@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>,
>> 	Peter Zijlstra <a.p.zijlstra@chello.nl>,
>> 	Thomas Gleixner <tglx@linutronix.de>
>> Cc: David Miller <davem@davemloft.net>,
>> 	Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
>> 	Ralf Baechle <ralf@linux-mips.org>, benh@kernel.crashing.org,
>> 	paulus@samba.org, Ingo Molnar <mingo@redhat.com>
>> User-Agent: quilt/0.46-1
>> From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
>> Subject: [RFC patch 08/15] LTTng - Timestamping
>> Wrapper to use the lower level clock sources available on the systems. 
>> Fall-back
>> on jiffies or'd with a logical clock for architectures lacking CPU 
>> timestamp
>> counters. Fall-back on a mixed TSC-logical clock on architectures lacking
>> synchronized TSC on SMP.
>> A generic fallback based on a logical clock and the timer interrupt is
>> available.
>> generic - Uses jiffies or'd with a logical clock extended to 64 bits by
>>           ltt-timestamp.c.
>> i386 - Uses TSC. If detects non synchronized TSC, uses mixed TSC-logical 
>> clock.
>> mips - Uses TSC extended atomically from 32 to 64 bits by ltt-heartbeat.c.
>> powerpc - Uses TSC or generic ltt clock.
>> x86_64 - Uses TSC. If detects non synchronized TSC, uses mixed TSC-logical 
>> clock
>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: benh@kernel.crashing.org
>> CC: paulus@samba.org
>> CC: David Miller <davem@davemloft.net>
>> CC: Linus Torvalds <torvalds@linux-foundation.org>
>> CC: Andrew Morton <akpm@linux-foundation.org>
>> CC: Ingo Molnar <mingo@redhat.com>
>> CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Steven Rostedt <rostedt@goodmis.org>
>> CC: linux-arch@vger.kernel.org
>> ---
>>  include/asm-generic/ltt.h |   53 
>> ++++++++++++++++++++++++++++++++++++++++++++++
>>  include/linux/ltt.h       |   27 +++++++++++++++++++++++
>>  kernel/timer.c            |    2 +
>>  3 files changed, 82 insertions(+)
>> Index: linux-2.6-lttng/kernel/timer.c
>> ===================================================================
>> --- linux-2.6-lttng.orig/kernel/timer.c	2008-09-16 14:50:15.000000000 
>> -0400
>> +++ linux-2.6-lttng/kernel/timer.c	2008-09-16 14:59:17.000000000 -0400
>> @@ -37,6 +37,7 @@
>>  #include <linux/delay.h>
>>  #include <linux/tick.h>
>>  #include <linux/kallsyms.h>
>> +#include <linux/ltt.h>
>>   #include <asm/uaccess.h>
>>  #include <asm/unistd.h>
>> @@ -1066,6 +1067,7 @@ void do_timer(unsigned long ticks)
>>  {
>>  	jiffies_64 += ticks;
>>  	update_times(ticks);
>> +	ltt_add_timestamp(ticks);
>>  }
>>   #ifdef __ARCH_WANT_SYS_ALARM
>> Index: linux-2.6-lttng/include/linux/ltt.h
>> ===================================================================
>> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
>> +++ linux-2.6-lttng/include/linux/ltt.h	2008-09-16 14:58:47.000000000 
>> -0400
>> @@ -0,0 +1,27 @@
>> +#ifndef _LINUX_LTT_H
>> +#define _LINUX_LTT_H
>> +
>> +/*
>> + * Generic LTT clock.
>> + *
>> + * Chooses between an architecture specific clock or an atomic logical 
>> clock.
>> + *
>> + * Copyright (C) 2007 Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
>> + */
>> +
>> +#ifdef CONFIG_LTT_TIMESTAMP
>> +#ifdef CONFIG_HAVE_LTT_CLOCK
>> +#include <asm/ltt.h>
>> +#else
>> +#include <asm-generic/ltt.h>
>> +
>> +#define ltt_get_timestamp32	ltt_get_timestamp32_generic
>> +#define ltt_get_timestamp64	ltt_get_timestamp64_generic
>> +#define ltt_add_timestamp	ltt_add_timestamp_generic
>> +#define ltt_frequency		ltt_frequency_generic
>> +#define ltt_freq_scale		ltt_freq_scale_generic
>> +#endif /* CONFIG_HAVE_LTT_CLOCK */
>> +#else
>> +#define ltt_add_timestamp(ticks)
>> +#endif /* CONFIG_LTT_TIMESTAMP */
>> +#endif /* _LINUX_LTT_H */
>> Index: linux-2.6-lttng/include/asm-generic/ltt.h
>> ===================================================================
>> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
>> +++ linux-2.6-lttng/include/asm-generic/ltt.h	2008-09-16 
>> 14:58:47.000000000 -0400
>> @@ -0,0 +1,53 @@
>> +#ifndef _ASM_GENERIC_LTT_H
>> +#define _ASM_GENERIC_LTT_H
>> +
>> +/*
>> + * linux/include/asm-generic/ltt.h
>> + *
>> + * Copyright (C) 2007 - Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
>> + *
>> + * Generic definitions for LTT
>> + * Architectures without TSC
>> + */
>> +
>> +#include <linux/param.h>	/* For HZ */
>> +#include <asm/atomic.h>
>> +
>> +#define LTT_GENERIC_CLOCK_SHIFT 13
>> +
>> +u64 ltt_read_synthetic_tsc(void);
>> +
>> +extern atomic_t lttng_generic_clock;
>> +
>> +static inline u32 ltt_get_timestamp32_generic(void)
>> +{
>> +	return atomic_add_return(1, &lttng_generic_clock);
>> +}
>> +
>> +static inline u64 ltt_get_timestamp64_generic(void)
>> +{
>> +	return ltt_read_synthetic_tsc();
>> +}
>> +
>> +static inline void ltt_add_timestamp_generic(unsigned long ticks)
>> +{
>> +	int old_clock, new_clock;
>> +
>> +	do {
>> +		old_clock = atomic_read(&lttng_generic_clock);
>> +		new_clock = (old_clock + (ticks << LTT_GENERIC_CLOCK_SHIFT))
>> +			& (~((1 << LTT_GENERIC_CLOCK_SHIFT) - 1));
>> +	} while (atomic_cmpxchg(&lttng_generic_clock, old_clock, new_clock)
>> +			!= old_clock);
>> +}
>> +
>> +static inline unsigned int ltt_frequency_generic(void)
>> +{
>> +	return HZ << LTT_GENERIC_CLOCK_SHIFT;
>> +}
>> +
>> +static inline u32 ltt_freq_scale_generic(void)
>> +{
>> +	return 1;
>> +}
>> +#endif /* _ASM_GENERIC_LTT_H */
>
> -- 
> Masami Hiramatsu
>
> Software Engineer
> Hitachi Computer Products (America) Inc.
> Software Solutions Division
>
> e-mail: mhiramat@redhat.com
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev@lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: (forw) [RFC patch 08/15] LTTng - Timestamping
  2008-10-18 22:14 ` Masami Hiramatsu
  2008-10-20 15:50   ` [ltt-dev] " Mathieu Desnoyers
@ 2008-10-22 16:27   ` Mathieu Desnoyers
  2008-10-23 21:12     ` Masami Hiramatsu
  1 sibling, 1 reply; 5+ messages in thread
From: Mathieu Desnoyers @ 2008-10-22 16:27 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: ltt-dev, mbligh, systemtap

Hi Masami,

I'll change to trace_clock (idea from Ingo). I originally created these
time sources as part of LTTng, it's the only reason why they have a ltt_
prefix. :)

Thanks for the review,

Mathieu

* Masami Hiramatsu (mhiramat@redhat.com) wrote:
> Hi Mathieu,
>
> These patches seems generally good. However, I wonder why you added
> "ltt_" prefix. if it was useful for other parts of the kernel
> (I think so), more general name(generic_timestamp?) would be preferable :)
>
> Thank you,
>
> Mathieu Desnoyers wrote:
>> Hello,
>> Too many CCs on this last post. I should probably have added some, but
>> here is a link to the thread :
>> http://lkml.org/lkml/2008/10/16/511
>> Comments are welcome.
>> Mathieu
>> ----- Forwarded message from Mathieu Desnoyers 
>> <mathieu.desnoyers@polymtl.ca> -----
>> Date: Thu, 16 Oct 2008 19:27:37 -0400
>> To: Linus Torvalds <torvalds@linux-foundation.org>,
>> 	Andrew Morton <akpm@linux-foundation.org>,
>> 	Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org,
>> 	linux-arch@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>,
>> 	Peter Zijlstra <a.p.zijlstra@chello.nl>,
>> 	Thomas Gleixner <tglx@linutronix.de>
>> Cc: David Miller <davem@davemloft.net>,
>> 	Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
>> 	Ralf Baechle <ralf@linux-mips.org>, benh@kernel.crashing.org,
>> 	paulus@samba.org, Ingo Molnar <mingo@redhat.com>
>> User-Agent: quilt/0.46-1
>> From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
>> Subject: [RFC patch 08/15] LTTng - Timestamping
>> Wrapper to use the lower level clock sources available on the systems. 
>> Fall-back
>> on jiffies or'd with a logical clock for architectures lacking CPU 
>> timestamp
>> counters. Fall-back on a mixed TSC-logical clock on architectures lacking
>> synchronized TSC on SMP.
>> A generic fallback based on a logical clock and the timer interrupt is
>> available.
>> generic - Uses jiffies or'd with a logical clock extended to 64 bits by
>>           ltt-timestamp.c.
>> i386 - Uses TSC. If detects non synchronized TSC, uses mixed TSC-logical 
>> clock.
>> mips - Uses TSC extended atomically from 32 to 64 bits by ltt-heartbeat.c.
>> powerpc - Uses TSC or generic ltt clock.
>> x86_64 - Uses TSC. If detects non synchronized TSC, uses mixed TSC-logical 
>> clock
>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
>> CC: Ralf Baechle <ralf@linux-mips.org>
>> CC: benh@kernel.crashing.org
>> CC: paulus@samba.org
>> CC: David Miller <davem@davemloft.net>
>> CC: Linus Torvalds <torvalds@linux-foundation.org>
>> CC: Andrew Morton <akpm@linux-foundation.org>
>> CC: Ingo Molnar <mingo@redhat.com>
>> CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Steven Rostedt <rostedt@goodmis.org>
>> CC: linux-arch@vger.kernel.org
>> ---
>>  include/asm-generic/ltt.h |   53 
>> ++++++++++++++++++++++++++++++++++++++++++++++
>>  include/linux/ltt.h       |   27 +++++++++++++++++++++++
>>  kernel/timer.c            |    2 +
>>  3 files changed, 82 insertions(+)
>> Index: linux-2.6-lttng/kernel/timer.c
>> ===================================================================
>> --- linux-2.6-lttng.orig/kernel/timer.c	2008-09-16 14:50:15.000000000 
>> -0400
>> +++ linux-2.6-lttng/kernel/timer.c	2008-09-16 14:59:17.000000000 -0400
>> @@ -37,6 +37,7 @@
>>  #include <linux/delay.h>
>>  #include <linux/tick.h>
>>  #include <linux/kallsyms.h>
>> +#include <linux/ltt.h>
>>   #include <asm/uaccess.h>
>>  #include <asm/unistd.h>
>> @@ -1066,6 +1067,7 @@ void do_timer(unsigned long ticks)
>>  {
>>  	jiffies_64 += ticks;
>>  	update_times(ticks);
>> +	ltt_add_timestamp(ticks);
>>  }
>>   #ifdef __ARCH_WANT_SYS_ALARM
>> Index: linux-2.6-lttng/include/linux/ltt.h
>> ===================================================================
>> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
>> +++ linux-2.6-lttng/include/linux/ltt.h	2008-09-16 14:58:47.000000000 
>> -0400
>> @@ -0,0 +1,27 @@
>> +#ifndef _LINUX_LTT_H
>> +#define _LINUX_LTT_H
>> +
>> +/*
>> + * Generic LTT clock.
>> + *
>> + * Chooses between an architecture specific clock or an atomic logical 
>> clock.
>> + *
>> + * Copyright (C) 2007 Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
>> + */
>> +
>> +#ifdef CONFIG_LTT_TIMESTAMP
>> +#ifdef CONFIG_HAVE_LTT_CLOCK
>> +#include <asm/ltt.h>
>> +#else
>> +#include <asm-generic/ltt.h>
>> +
>> +#define ltt_get_timestamp32	ltt_get_timestamp32_generic
>> +#define ltt_get_timestamp64	ltt_get_timestamp64_generic
>> +#define ltt_add_timestamp	ltt_add_timestamp_generic
>> +#define ltt_frequency		ltt_frequency_generic
>> +#define ltt_freq_scale		ltt_freq_scale_generic
>> +#endif /* CONFIG_HAVE_LTT_CLOCK */
>> +#else
>> +#define ltt_add_timestamp(ticks)
>> +#endif /* CONFIG_LTT_TIMESTAMP */
>> +#endif /* _LINUX_LTT_H */
>> Index: linux-2.6-lttng/include/asm-generic/ltt.h
>> ===================================================================
>> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
>> +++ linux-2.6-lttng/include/asm-generic/ltt.h	2008-09-16 
>> 14:58:47.000000000 -0400
>> @@ -0,0 +1,53 @@
>> +#ifndef _ASM_GENERIC_LTT_H
>> +#define _ASM_GENERIC_LTT_H
>> +
>> +/*
>> + * linux/include/asm-generic/ltt.h
>> + *
>> + * Copyright (C) 2007 - Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
>> + *
>> + * Generic definitions for LTT
>> + * Architectures without TSC
>> + */
>> +
>> +#include <linux/param.h>	/* For HZ */
>> +#include <asm/atomic.h>
>> +
>> +#define LTT_GENERIC_CLOCK_SHIFT 13
>> +
>> +u64 ltt_read_synthetic_tsc(void);
>> +
>> +extern atomic_t lttng_generic_clock;
>> +
>> +static inline u32 ltt_get_timestamp32_generic(void)
>> +{
>> +	return atomic_add_return(1, &lttng_generic_clock);
>> +}
>> +
>> +static inline u64 ltt_get_timestamp64_generic(void)
>> +{
>> +	return ltt_read_synthetic_tsc();
>> +}
>> +
>> +static inline void ltt_add_timestamp_generic(unsigned long ticks)
>> +{
>> +	int old_clock, new_clock;
>> +
>> +	do {
>> +		old_clock = atomic_read(&lttng_generic_clock);
>> +		new_clock = (old_clock + (ticks << LTT_GENERIC_CLOCK_SHIFT))
>> +			& (~((1 << LTT_GENERIC_CLOCK_SHIFT) - 1));
>> +	} while (atomic_cmpxchg(&lttng_generic_clock, old_clock, new_clock)
>> +			!= old_clock);
>> +}
>> +
>> +static inline unsigned int ltt_frequency_generic(void)
>> +{
>> +	return HZ << LTT_GENERIC_CLOCK_SHIFT;
>> +}
>> +
>> +static inline u32 ltt_freq_scale_generic(void)
>> +{
>> +	return 1;
>> +}
>> +#endif /* _ASM_GENERIC_LTT_H */
>
> -- 
> Masami Hiramatsu
>
> Software Engineer
> Hitachi Computer Products (America) Inc.
> Software Solutions Division
>
> e-mail: mhiramat@redhat.com
>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: (forw) [RFC patch 08/15] LTTng - Timestamping
  2008-10-22 16:27   ` Mathieu Desnoyers
@ 2008-10-23 21:12     ` Masami Hiramatsu
  0 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2008-10-23 21:12 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: ltt-dev, mbligh, systemtap

Hi Mathieu,

Mathieu Desnoyers wrote:
> Hi Masami,
> 
> I'll change to trace_clock (idea from Ingo). I originally created these
> time sources as part of LTTng, it's the only reason why they have a ltt_
> prefix. :)

Great! then, it's time to move to trace_clock ;-)

Thank you for your work!


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-10-23 21:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-17 16:58 (forw) [RFC patch 08/15] LTTng - Timestamping Mathieu Desnoyers
2008-10-18 22:14 ` Masami Hiramatsu
2008-10-20 15:50   ` [ltt-dev] " Mathieu Desnoyers
2008-10-22 16:27   ` Mathieu Desnoyers
2008-10-23 21:12     ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).