From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9954 invoked by alias); 17 Oct 2008 16:58:27 -0000 Received: (qmail 9946 invoked by uid 22791); 17 Oct 2008 16:58:25 -0000 X-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from tomts16.bellnexxia.net (HELO tomts16-srv.bellnexxia.net) (209.226.175.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 17 Oct 2008 16:57:34 +0000 Received: from toip4.srvr.bell.ca ([209.226.175.87]) by tomts16-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20081017165732.YLAC1723.tomts16-srv.bellnexxia.net@toip4.srvr.bell.ca> for ; Fri, 17 Oct 2008 12:57:32 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AugEAHNd+EhMQWq+/2dsb2JhbACBcr8cg2w Received: from bas5-montreal19-1279355582.dsl.bell.ca (HELO krystal.dyndns.org) ([76.65.106.190]) by toip4.srvr.bell.ca with ESMTP; 17 Oct 2008 13:04:47 -0400 Received: from localhost (localhost [127.0.0.1]) (uid 1000) by krystal.dyndns.org with local; Fri, 17 Oct 2008 12:57:31 -0400 id 001F2241.48F8C3FB.00002124 Date: Fri, 17 Oct 2008 16:58:00 -0000 From: Mathieu Desnoyers To: ltt-dev@lists.casi.polymtl.ca, mbligh@google.com, systemtap@sources.redhat.com Subject: (forw) [RFC patch 08/15] LTTng - Timestamping Message-ID: <20081017165731.GI5696@Krystal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-Editor: vi X-Info: http://krystal.dyndns.org:8080 X-Operating-System: Linux/2.6.21.3-grsec (i686) X-Uptime: 12:54:34 up 134 days, 21:34, 9 users, load average: 0.99, 0.97, 0.89 User-Agent: Mutt/1.5.16 (2007-06-11) X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2008-q4/txt/msg00133.txt.bz2 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 ----- Date: Thu, 16 Oct 2008 19:27:37 -0400 To: Linus Torvalds , Andrew Morton , Ingo Molnar , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Steven Rostedt , Peter Zijlstra , Thomas Gleixner Cc: David Miller , Mathieu Desnoyers , Ralf Baechle , benh@kernel.crashing.org, paulus@samba.org, Ingo Molnar User-Agent: quilt/0.46-1 From: Mathieu Desnoyers 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 cl= ock. 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 CC: Ralf Baechle CC: benh@kernel.crashing.org CC: paulus@samba.org CC: David Miller CC: Linus Torvalds CC: Andrew Morton CC: Ingo Molnar CC: Peter Zijlstra CC: Thomas Gleixner CC: Steven Rostedt 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 #include #include +#include =20 #include #include @@ -1066,6 +1067,7 @@ void do_timer(unsigned long ticks) { jiffies_64 +=3D ticks; update_times(ticks); + ltt_add_timestamp(ticks); } =20 #ifdef __ARCH_WANT_SYS_ALARM Index: linux-2.6-lttng/include/linux/ltt.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /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 clo= ck. + * + * Copyright (C) 2007 Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca) + */ + +#ifdef CONFIG_LTT_TIMESTAMP +#ifdef CONFIG_HAVE_LTT_CLOCK +#include +#else +#include + +#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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /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 /* For HZ */ +#include + +#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, <tng_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 =3D atomic_read(<tng_generic_clock); + new_clock =3D (old_clock + (ticks << LTT_GENERIC_CLOCK_SHIFT)) + & (~((1 << LTT_GENERIC_CLOCK_SHIFT) - 1)); + } while (atomic_cmpxchg(<tng_generic_clock, old_clock, new_clock) + !=3D 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 */ --=20 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 ----- --=20 Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68