From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753928AbYKMNCV (ORCPT ); Thu, 13 Nov 2008 08:02:21 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752000AbYKMNCN (ORCPT ); Thu, 13 Nov 2008 08:02:13 -0500 Received: from mx2.mail.elte.hu ([157.181.151.9]:40986 "EHLO mx2.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751763AbYKMNCN (ORCPT ); Thu, 13 Nov 2008 08:02:13 -0500 Date: Thu, 13 Nov 2008 14:02:00 +0100 From: Ingo Molnar To: Peter Zijlstra Cc: =?iso-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , Steven Rostedt , Linux Kernel Subject: Re: [PATCH 1/2] tracing/function-return-tracer: Make the function return tracer lockless Message-ID: <20081113130200.GA1531@elte.hu> References: <20081112221552.GA6125@elte.hu> <20081113085551.GF25479@elte.hu> <20081113092340.GJ25479@elte.hu> <20081113094027.GK25479@elte.hu> <20081113125419.GA32574@elte.hu> <1226581181.7685.4714.camel@twins> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1226581181.7685.4714.camel@twins> User-Agent: Mutt/1.5.18 (2008-05-17) X-ELTE-VirusStatus: clean X-ELTE-SpamScore: -1.5 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-1.5 required=5.9 tests=BAYES_00,DNS_FROM_SECURITYSAGE autolearn=no SpamAssassin version=3.2.3 -1.5 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.0 DNS_FROM_SECURITYSAGE RBL: Envelope sender in blackholes.securitysage.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Peter Zijlstra wrote: > On Thu, 2008-11-13 at 13:54 +0100, Ingo Molnar wrote: > > * Frédéric Weisbecker wrote: > > > > > Ok, so correct me if I'm wrong. Global timestamp would be captured > > > by using sched_clock(). That's what is done currently in > > > ring_buffer_time_stamp() And the global timestamp would be > > > combination of a last global timestamp and a relative position from > > > now to this last at each insertion in the ring-buffer (or tracing > > > time capture). Am I right? I don't really understand why you want to > > > update with a cmpxchg loop... > > > > the cmpxchg loop would be needed to ensure timestamp monotonicity: > > every new "global time" is cmpxchg-ed with the "previous global time" > > (and is first monotonicity checked). > > > > "prev_global_time" also acts as a global serializer: it ensures that > > events are timestamped in a monotonic and ordered way. > > > > i.e. something like this (pseudocode, without the cmpxchg): > > > > u64 prev_global_time; > > > > DEFINE_PER_CPU(prev_local_time); > > > > u64 global_time() > > { > > u64 now, delta, now_global; > > > > prev_global = prev_global_time; > > now = sched_clock(); > > delta = now - per_cpu(prev_local_time, this_cpu); > > per_cpu(prev_local_time, this_cpu) = now; > > > > now_global = prev_global + delta; > > prev_global = now_global; > > > > return now_global; > > } > > > > note how we build "global time" out of "local time". > > This goes down shit-creek real fast if the TSC goes funny and jumps > fwd or something. yes, it was simplified pseudocode: instead of raw sched_clock() it should use a more reliable source like cpu_clock(this_cpu). the important bit is how to build a global clock out of the local clock. Ingo