From: Peter Zijlstra <peterz@infradead.org>
To: rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>, mingo <mingo@redhat.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] ftrace: use a global counter for the global clock
Date: Fri, 16 Sep 2011 11:02:45 +0200 [thread overview]
Message-ID: <1316163765.10174.8.camel@twins> (raw)
no reason to muck about, just use a counter already.
Requested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/trace/trace_clock.c | 44 +++-----------------------------------------
1 files changed, 3 insertions(+), 41 deletions(-)
diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
index 6302747..1b79441 100644
--- a/kernel/trace/trace_clock.c
+++ b/kernel/trace/trace_clock.c
@@ -68,48 +68,10 @@ u64 notrace trace_clock(void)
* Used by plugins that need globally coherent timestamps.
*/
-/* keep prev_time and lock in the same cacheline. */
-static struct {
- u64 prev_time;
- arch_spinlock_t lock;
-} trace_clock_struct ____cacheline_aligned_in_smp =
- {
- .lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED,
- };
+
+static atomic64_t trace_counter;
u64 notrace trace_clock_global(void)
{
- unsigned long flags;
- int this_cpu;
- u64 now;
-
- local_irq_save(flags);
-
- this_cpu = raw_smp_processor_id();
- now = cpu_clock(this_cpu);
- /*
- * If in an NMI context then dont risk lockups and return the
- * cpu_clock() time:
- */
- if (unlikely(in_nmi()))
- goto out;
-
- arch_spin_lock(&trace_clock_struct.lock);
-
- /*
- * TODO: if this happens often then maybe we should reset
- * my_scd->clock to prev_time+1, to make sure
- * we start ticking with the local clock from now on?
- */
- if ((s64)(now - trace_clock_struct.prev_time) < 0)
- now = trace_clock_struct.prev_time + 1;
-
- trace_clock_struct.prev_time = now;
-
- arch_spin_unlock(&trace_clock_struct.lock);
-
- out:
- local_irq_restore(flags);
-
- return now;
+ return atomic64_add_return(1, &trace_counter);
}
next reply other threads:[~2011-09-16 9:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-16 9:02 Peter Zijlstra [this message]
2011-09-16 12:18 ` [PATCH] ftrace: use a global counter for the global clock Steven Rostedt
2011-09-16 12:35 ` Peter Zijlstra
2011-09-16 12:36 ` Peter Zijlstra
2011-09-16 13:23 ` Steven Rostedt
2011-09-16 13:24 ` Steven Rostedt
2011-09-16 21:14 ` Valdis.Kletnieks
2011-09-16 21:37 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1316163765.10174.8.camel@twins \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox