From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: 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>,
Thomas Gleixner <tglx@linutronix.de>,
David Miller <davem@davemloft.net>
Subject: Re: [RFC patch 00/15] Tracer Timestamping
Date: Mon, 20 Oct 2008 16:25:17 -0400 [thread overview]
Message-ID: <20081020202517.GF28562@Krystal> (raw)
In-Reply-To: <1224230353.28131.65.camel@twins>
* Peter Zijlstra (a.p.zijlstra@chello.nl) wrote:
> On Thu, 2008-10-16 at 19:27 -0400, Mathieu Desnoyers wrote:
> > Hi,
> >
> > Starting with the bottom of my LTTng patchset
> > (git://git.kernel.org/pub/scm/linux/kernel/git/compudj/linux-2.6-lttng.git)
> > I post as RFC the timestamping infrastructure I have been using for a while in
> > the tracer. It integrates get_cycles() standardization following David Miller's
> > comments I did more recently.
> >
> > It also deals with 32 -> 64 bits timestamp counter extension with a RCU-style
> > algorithm, which is especially useful on MIPS and SuperH architectures.
>
> Have you looked at the existing 32->63 extention code in
> include/linux/cnt32_to_63.h and considered unifying it?
>
Yep, I felt this code was dangerous on SMP given it could suffer from
the following type of race due to lack of proper barriers :
CPU A B
read hw cnt low
read __m_cnt_hi
read hw cnt low
(wrap detected)
write __m_cnt_hi (incremented)
read __m_cnt_hi
(wrap detected)
write __m_cnt_hi (incremented)
we therefore increment the high bits twice in the given race.
On UP, the same race could happen if the code is called with preemption
enabled.
I don't think the "volatile" statement would necessarily make sure the
compiler and CPU would do the __m_cnt_hi read before the hw cnt low
read. A real memory barrier to order mmio reads wrt memory reads (or
instruction sync barrier if the value is taken from the cpu registers)
would be required to insure such order.
I also felt it would be more solid to have per-cpu structures to keep
track of 32->64 bits TSC updates, given the TSCs can always be slightly
out-of-sync :
CPU A B
read __m_cnt_hi
read hw cnt low (+200 cycles)
(wrap detected)
write __m_cnt_hi (incremented)
read __m_cnt_hi
read hw cnt low (-200 cycles)
(no wrap)
-> bogus value returned.
> > There is also a TSC synchronization test within this patchset to detect
> > unsynchronized TSCs.
>
> We already have such code, no? Does this code replace that one or just
> add a second test?
>
It adds a second test, which seems more solid to me than the existing
x86 tsc_sync detection code.
> > See comments in this specific patch to figure out the
> > difference between the current x86 tsc_sync.c and the one I propose in this
> > patch.
>
> Right so you don't unify, that's a missed opportunity, no?
>
Yep, If we can switch the current x86 tsc_sync code to use my
architecture agnostic implementation, that would be a gain. We could
probably port other tsc sync detect code (ia64 ?) to use this
infrastructure too.
> > It also provides an architecture-agnostic fallback in case there is no
> > timestamp counter available : basically, it's
> > (jiffies << 13) | atomically_incremented_counter (if there are more than 8192
> > events per jiffy, time will still be monotonic, but will increment faster than
> > the actual system frequency).
> >
> > Comments are welcome. Note that this is only the beginning of the patchset. I
> > plan to submit the event ID allocation/portable event typing aimed at exporting
> > the data to userspace and buffering mechanism as soon as I integrate a core
> > version of the LTTV userspace tools to the kernel build tree. Other than that, I
> > currently have a tracer which fulfills most of the requirements expressed
> > earlier. I just fear that if I release only the kernel part without foolproof
> > binary-to-ascii trace decoder within the kernel, people might be a bit reluctant
> > to fetch a separate userspace package.
>
> It might be good to drop all the ltt naming and pick more generic names,
> esp. as ftrace could use a lot of this infrastructure as well.
>
Sure. I've done all this development as part of the LTTng project, but I
don't care about renaming stuff. trace_clock() seems like a good name
for trace clock source. The unsync TSC detection and the 23->64 bits TSC
extension would also probably require more generic names (and would
benefit to be moved to kernel/).
Mathieu
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
next prev parent reply other threads:[~2008-10-20 20:25 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-16 23:27 [RFC patch 00/15] Tracer Timestamping Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 01/15] get_cycles() : kconfig HAVE_GET_CYCLES Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 02/15] get_cycles() : x86 HAVE_GET_CYCLES Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 03/15] get_cycles() : sparc64 HAVE_GET_CYCLES Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-17 2:48 ` [RFC patch 03/15] get_cycles() : sparc64 HAVE_GET_CYCLES (update) Mathieu Desnoyers
2008-10-17 2:48 ` Mathieu Desnoyers
2008-10-17 2:57 ` David Miller
2008-10-16 23:27 ` [RFC patch 04/15] get_cycles() : powerpc64 HAVE_GET_CYCLES Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-17 0:26 ` Paul Mackerras
2008-10-17 0:43 ` [RFC patch 04/15] get_cycles() : powerpc64 HAVE_GET_CYCLES (update) Mathieu Desnoyers
2008-10-17 0:43 ` Mathieu Desnoyers
2008-10-17 0:54 ` Paul Mackerras
2008-10-17 1:42 ` David Miller
2008-10-17 2:08 ` Mathieu Desnoyers
2008-10-17 2:08 ` Mathieu Desnoyers
2008-10-17 2:33 ` David Miller
2008-10-16 23:27 ` [RFC patch 05/15] get_cycles() : MIPS HAVE_GET_CYCLES_32 Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-26 10:18 ` Ralf Baechle
2008-10-26 10:18 ` Ralf Baechle
2008-10-26 20:39 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 06/15] LTTng build Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-17 8:10 ` KOSAKI Motohiro
2008-10-17 16:18 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 07/15] LTTng timestamp Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-17 8:15 ` KOSAKI Motohiro
2008-10-17 16:23 ` Mathieu Desnoyers
2008-10-17 16:23 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 08/15] LTTng - Timestamping Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 09/15] LTTng mips export hpt frequency Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 10/15] LTTng timestamp mips Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 11/15] LTTng timestamp powerpc Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 12/15] LTTng timestamp sparc64 Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 13/15] LTTng timestamp sh Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 14/15] LTTng - TSC synchronicity test Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-16 23:27 ` [RFC patch 15/15] LTTng timestamp x86 Mathieu Desnoyers
2008-10-16 23:27 ` Mathieu Desnoyers
2008-10-17 0:08 ` Linus Torvalds
2008-10-17 0:12 ` Linus Torvalds
2008-10-17 1:28 ` Mathieu Desnoyers
2008-10-17 2:19 ` Luck, Tony
2008-10-17 2:19 ` Luck, Tony
2008-10-17 17:25 ` Steven Rostedt
2008-10-17 18:08 ` Luck, Tony
2008-10-17 18:42 ` Mathieu Desnoyers
2008-10-17 18:58 ` Luck, Tony
2008-10-17 20:23 ` Mathieu Desnoyers
2008-10-17 23:52 ` Luck, Tony
2008-10-18 17:01 ` Mathieu Desnoyers
2008-10-18 17:01 ` Mathieu Desnoyers
2008-10-18 17:35 ` Linus Torvalds
2008-10-18 17:50 ` Ingo Molnar
2008-10-22 16:19 ` Mathieu Desnoyers
2008-10-22 15:53 ` Mathieu Desnoyers
2008-10-20 18:07 ` Luck, Tony
2008-10-22 16:51 ` Mathieu Desnoyers
2008-10-17 19:17 ` Steven Rostedt
2008-10-20 20:10 ` Linus Torvalds
2008-10-20 20:10 ` Linus Torvalds
2008-10-20 21:38 ` john stultz
2008-10-20 22:06 ` Linus Torvalds
2008-10-20 22:17 ` Ingo Molnar
2008-10-20 22:17 ` Ingo Molnar
2008-10-20 22:29 ` H. Peter Anvin
2008-10-20 22:29 ` H. Peter Anvin
2008-10-21 18:10 ` Bjorn Helgaas
2008-10-23 15:47 ` Linus Torvalds
2008-10-23 16:39 ` H. Peter Anvin
2008-10-23 21:54 ` Paul Mackerras
2008-10-20 23:47 ` john stultz
2008-10-20 23:47 ` john stultz
2008-10-22 17:05 ` Mathieu Desnoyers
2008-10-17 19:36 ` Christoph Lameter
2008-10-17 7:59 ` [RFC patch 00/15] Tracer Timestamping Peter Zijlstra
2008-10-20 20:25 ` Mathieu Desnoyers [this message]
2008-10-20 20:25 ` Mathieu Desnoyers
2008-10-21 0:20 ` Nicolas Pitre
2008-10-21 1:32 ` Mathieu Desnoyers
2008-10-21 2:32 ` Nicolas Pitre
2008-10-21 4:05 ` Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081020202517.GF28562@Krystal \
--to=mathieu.desnoyers@polymtl.ca \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).