Commit 6ca6cca3 authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt

tracing: optimize global_trace_clock cachelines

The prev_trace_clock_time is only read or written to when the
trace_clock_lock is taken. For better perfomance, they
should share the same cache line.
Reported-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 555f386c
...@@ -66,10 +66,14 @@ u64 notrace trace_clock(void) ...@@ -66,10 +66,14 @@ u64 notrace trace_clock(void)
* Used by plugins that need globally coherent timestamps. * Used by plugins that need globally coherent timestamps.
*/ */
static u64 prev_trace_clock_time; /* keep prev_time and lock in the same cacheline. */
static struct {
static raw_spinlock_t trace_clock_lock ____cacheline_aligned_in_smp = u64 prev_time;
(raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; raw_spinlock_t lock;
} trace_clock_struct ____cacheline_aligned_in_smp =
{
.lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED,
};
u64 notrace trace_clock_global(void) u64 notrace trace_clock_global(void)
{ {
...@@ -88,19 +92,19 @@ u64 notrace trace_clock_global(void) ...@@ -88,19 +92,19 @@ u64 notrace trace_clock_global(void)
if (unlikely(in_nmi())) if (unlikely(in_nmi()))
goto out; goto out;
__raw_spin_lock(&trace_clock_lock); __raw_spin_lock(&trace_clock_struct.lock);
/* /*
* TODO: if this happens often then maybe we should reset * TODO: if this happens often then maybe we should reset
* my_scd->clock to prev_trace_clock_time+1, to make sure * my_scd->clock to prev_time+1, to make sure
* we start ticking with the local clock from now on? * we start ticking with the local clock from now on?
*/ */
if ((s64)(now - prev_trace_clock_time) < 0) if ((s64)(now - trace_clock_struct.prev_time) < 0)
now = prev_trace_clock_time + 1; now = trace_clock_struct.prev_time + 1;
prev_trace_clock_time = now; trace_clock_struct.prev_time = now;
__raw_spin_unlock(&trace_clock_lock); __raw_spin_unlock(&trace_clock_struct.lock);
out: out:
raw_local_irq_restore(flags); raw_local_irq_restore(flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment