Re: [PATCH] perf_events: fix time tracking in samples

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Peter Zijlstra
Date: Wednesday, October 20, 2010 - 4:00 am

On Tue, 2010-10-19 at 21:03 +0200, Stephane Eranian wrote:


Take update_context_time(), it has:

 now = perf_clock();
 ctx->time += now - ctx->timestamp;
 ctx->timestamp = now;

If you interleave two of those you get:

 ctx->timestamp = T0;


 now = perf_clock(); /* T1 */
 ctx->time += now - ctx->timestamp;
					now = perf_clock(); /* T2 */
					ctx->time += now - ctx->timestamp;
					ctx->timestamp = now;
 ctx->timestamp = now;


So at this point you would expect timestamp = T2 and time += T2-T0.

Except that: time += T1 - T0 + T2 - T0 != T2 - T0 and
             timestamp = T1

You can of course write it as something like x86_perf_event_update(),
but then there's trying to keep total_time_running and
total_time_enabled in sync.



Well, yes, but it sucks, esp. since its only relevant for
PERF_SAMPLE_READ.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] perf_events: fix time tracking in samples, Stephane Eranian, (Tue Oct 19, 9:47 am)
Re: [PATCH] perf_events: fix time tracking in samples, Peter Zijlstra, (Tue Oct 19, 9:52 am)
Re: [PATCH] perf_events: fix time tracking in samples, Stephane Eranian, (Tue Oct 19, 10:01 am)
Re: [PATCH] perf_events: fix time tracking in samples, Peter Zijlstra, (Tue Oct 19, 10:09 am)
Re: [PATCH] perf_events: fix time tracking in samples, Stephane Eranian, (Tue Oct 19, 12:03 pm)
Re: [PATCH] perf_events: fix time tracking in samples, Peter Zijlstra, (Wed Oct 20, 4:00 am)
Re: [PATCH] perf_events: fix time tracking in samples, Peter Zijlstra, (Wed Oct 20, 4:13 am)
Re: [PATCH] perf_events: fix time tracking in samples, Stephane Eranian, (Wed Oct 20, 5:42 am)
Re: [PATCH] perf_events: fix time tracking in samples, Peter Zijlstra, (Wed Oct 20, 6:04 am)