Re: [PATCH 1/2] tracing/function-return-tracer: Make the function return tracer lockless

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Ingo Molnar <mingo@...>
Cc: Steven Rostedt <rostedt@...>, Linux Kernel <linux-kernel@...>, Peter Zijlstra <a.p.zijlstra@...>
Date: Thursday, November 13, 2008 - 1:26 pm

2008/11/13 Ingo Molnar <mingo@elte.hu>:

Ok, I understand better.
But consider the following:

 u64 global_time()
 {
       u64 now, delta, now_global;
       prev_global = prev_global_time;

       while (atomic64_cmpxchg(&prev_global_time,
                                 prev_global, now_global) != prev_global) {

           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;
 }

Sarting with prev_global_time = 0
If we have two cpu and the above function is executed 5 times on the first cpu.
We couldl have per_cpu(prev_local_time) = 50 for example. And so
prev_global_time will be equal to 50.

Just after that, almost at the same time, cpu2 calls global_time()

delta will be equal to 50 (sched_clock() - per_cpu(prev_local_time)
which is 0) and prev_global_time will be 50 + 50 = 100.
This is not consistent.
I don't know where but I'm pretty sure I missed something....
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/2] tracing/function-return-tracer: Make the functio..., Frederic Weisbecker, (Wed Nov 12, 5:47 pm)
Re: [PATCH 1/2] tracing/function-return-tracer: Make the fun..., Frédéric Weisbecker, (Thu Nov 13, 1:01 pm)
Re: [PATCH 1/2] tracing/function-return-tracer: Make the fun..., Frédéric Weisbecker, (Thu Nov 13, 1:46 pm)
Re: [PATCH 1/2] tracing/function-return-tracer: Make the fun..., Frédéric Weisbecker, (Thu Nov 13, 4:50 am)
Re: [PATCH 1/2] tracing/function-return-tracer: Make the fun..., Frédéric Weisbecker, (Thu Nov 13, 5:16 am)
Re: [PATCH 1/2] tracing/function-return-tracer: Make the fun..., Frédéric Weisbecker, (Thu Nov 13, 5:27 am)
Re: [PATCH 1/2] tracing/function-return-tracer: Make the fun..., Frédéric Weisbecker, (Thu Nov 13, 8:36 am)
Re: [PATCH 1/2] tracing/function-return-tracer: Make the fun..., Frédéric Weisbecker, (Thu Nov 13, 1:26 pm)
Re: [PATCH 1/2] tracing/function-return-tracer: Make the fun..., Frédéric Weisbecker, (Thu Nov 13, 4:06 pm)