lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 13 Nov 2008 14:02:00 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc:	Frédéric Weisbecker <fweisbec@...il.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] tracing/function-return-tracer: Make the function
	return tracer lockless


* Peter Zijlstra <a.p.zijlstra@...llo.nl> wrote:

> On Thu, 2008-11-13 at 13:54 +0100, Ingo Molnar wrote:
> > * Frédéric Weisbecker <fweisbec@...il.com> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ