From: Ingo Molnar <mingo@kernel.org>
To: David Sharp <dhsharp@google.com>
Cc: linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@linux.intel.com>
Subject: Re: [PATCH v2 1/3] tracing,x86: add a TSC trace_clock
Date: Thu, 20 Sep 2012 10:55:45 +0200 [thread overview]
Message-ID: <20120920085545.GA3497@gmail.com> (raw)
In-Reply-To: <1348004227-23575-1-git-send-email-dhsharp@google.com>
* David Sharp <dhsharp@google.com> wrote:
> In order to promote interoperability between userspace tracers and ftrace,
> add a trace_clock that reports raw TSC values which will then be recorded
> in the ring buffer. Userspace tracers that also record TSCs are then on
> exactly the same time base as the kernel and events can be unambiguously
> interlaced.
>
> Tested: Enabled a tracepoint and the "tsc" trace_clock and saw very large
> timestamp values.
>
> v2:
> Move arch-specific bits out of generic code.
>
> Google-Bug-Id: 6980623
> Signed-off-by: David Sharp <dhsharp@google.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: "H. Peter Anvin" <hpa@linux.intel.com>
> ---
> arch/x86/include/asm/trace_clock.h | 16 ++++++++++++++++
> arch/x86/kernel/Makefile | 1 +
> arch/x86/kernel/trace_clock.c | 20 ++++++++++++++++++++
> include/asm-generic/trace_clock.h | 15 +++++++++++++++
> include/linux/trace_clock.h | 2 ++
> kernel/trace/trace.c | 1 +
> 6 files changed, 55 insertions(+), 0 deletions(-)
> create mode 100644 arch/x86/include/asm/trace_clock.h
> create mode 100644 arch/x86/kernel/trace_clock.c
> create mode 100644 include/asm-generic/trace_clock.h
>
> diff --git a/arch/x86/include/asm/trace_clock.h b/arch/x86/include/asm/trace_clock.h
> new file mode 100644
> index 0000000..0b1f391
> --- /dev/null
> +++ b/arch/x86/include/asm/trace_clock.h
> @@ -0,0 +1,16 @@
> +#ifndef _ASM_X86_TRACE_CLOCK_H
> +#define _ASM_X86_TRACE_CLOCK_H
> +
> +#include <linux/compiler.h>
> +#include <linux/types.h>
> +
> +#ifdef CONFIG_X86_TSC
> +
> +extern u64 notrace trace_clock_x86_tsc(void);
> +
> +# define ARCH_TRACE_CLOCKS \
> + { trace_clock_x86_tsc, "tsc" },
I'd name it "x86-tsc", to make sure the naming is unique. That
will also enable the addition of other hw clocks, should the
need arise.
> +
> +#endif
> +
> +#endif /* _ASM_X86_TRACE_CLOCK_H */
> diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
> index 8215e56..0ee9344 100644
> --- a/arch/x86/kernel/Makefile
> +++ b/arch/x86/kernel/Makefile
> @@ -62,6 +62,7 @@ obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o
> obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
> obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
> obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
> +obj-$(CONFIG_X86_TSC) += trace_clock.o
> obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o
> obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o
> obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o
> diff --git a/arch/x86/kernel/trace_clock.c b/arch/x86/kernel/trace_clock.c
> new file mode 100644
> index 0000000..b8959f8
> --- /dev/null
> +++ b/arch/x86/kernel/trace_clock.c
> @@ -0,0 +1,20 @@
> +/*
> + * X86 trace clocks
> + */
> +#include <asm/trace_clock.h>
> +#include <asm/barrier.h>
> +#include <asm/msr.h>
> +
> +/*
> + * trace_clock_x86_tsc(): A clock that is just the cycle counter.
> + *
> + * Unlike the other clocks, this is not in nanoseconds.
> + */
> +u64 notrace trace_clock_x86_tsc(void)
> +{
> + u64 ret;
> + rdtsc_barrier();
Missing newline.
> + rdtscll(ret);
> +
> + return ret;
> +}
> diff --git a/include/asm-generic/trace_clock.h b/include/asm-generic/trace_clock.h
> new file mode 100644
> index 0000000..648cdcd
> --- /dev/null
> +++ b/include/asm-generic/trace_clock.h
> @@ -0,0 +1,15 @@
> +/*
> + * Arch-specific trace clocks.
> + */
> +#ifndef _ASM_GENERIC_TRACE_CLOCK_H
> +#define _ASM_GENERIC_TRACE_CLOCK_H
We typically put header guards to the first and last lines of
the file, that way it can be ignored easily.
> +
> +/*
> + * Additional trace clocks added to the trace_clocks
> + * array in kernel/trace/trace.c
I'd add: "None if the architecture has not defined it."
> + */
> +#ifndef ARCH_TRACE_CLOCKS
> +# define ARCH_TRACE_CLOCKS
> +#endif
> +
> +#endif /* _ASM_GENERIC_TRACE_CLOCK_H */
> diff --git a/include/linux/trace_clock.h b/include/linux/trace_clock.h
> index 4eb4902..d563f37 100644
> --- a/include/linux/trace_clock.h
> +++ b/include/linux/trace_clock.h
> @@ -12,6 +12,8 @@
> #include <linux/compiler.h>
> #include <linux/types.h>
>
> +#include <asm/trace_clock.h>
> +
> extern u64 notrace trace_clock_local(void);
> extern u64 notrace trace_clock(void);
> extern u64 notrace trace_clock_global(void);
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 5c38c81..92fb08e 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -480,6 +480,7 @@ static struct {
> { trace_clock_local, "local" },
> { trace_clock_global, "global" },
> { trace_clock_counter, "counter" },
> + ARCH_TRACE_CLOCKS
> };
>
Looks useful and good otherwise:
Acked-by: Ingo Molnar <mingo@kernel.org>
Thanks,
Ingo
next prev parent reply other threads:[~2012-09-20 8:55 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-12 2:41 [PATCH 0/3] TSC trace_clock David Sharp
2012-09-12 2:41 ` [PATCH 1/3] tracing,x86: add a TSC trace_clock; reset buffer on clock change David Sharp
2012-09-12 3:48 ` Steven Rostedt
2012-09-12 18:48 ` David Sharp
2012-09-12 2:41 ` [PATCH 2/3] tracing: reset ring buffer when changing trace_clocks David Sharp
2012-09-12 2:41 ` [PATCH 3/3] tracing: format non-nanosec times from tsc clock without a decimal point David Sharp
2012-09-12 23:31 ` [PATCH v2 0/3] TSC trace_clock David Sharp
2012-09-12 23:31 ` [PATCH 1/3] tracing,x86: add a TSC trace_clock; reset buffer on clock change David Sharp
2012-09-12 23:31 ` [PATCH v2 1/3] tracing,x86: add a TSC trace_clock David Sharp
2012-09-13 1:15 ` Masami Hiramatsu
2012-09-13 1:23 ` Steven Rostedt
2012-09-18 21:37 ` David Sharp
2012-09-18 21:37 ` [PATCH v2 2/3] tracing: reset ring buffer when changing trace_clocks David Sharp
2012-09-18 21:37 ` [PATCH v2 3/3] tracing: format non-nanosec times from tsc clock without a decimal point David Sharp
2012-09-19 2:10 ` [PATCH v2 1/3] tracing,x86: add a TSC trace_clock Steven Rostedt
2012-09-20 8:55 ` Ingo Molnar [this message]
2012-09-20 13:34 ` Steven Rostedt
2012-09-20 22:52 ` [PATCH v3 " David Sharp
2012-09-20 22:52 ` [PATCH v3 2/3] tracing: reset ring buffer when changing trace_clocks David Sharp
2012-09-20 22:52 ` [PATCH v3 3/3] tracing: format non-nanosec times from tsc clock without a decimal point David Sharp
2012-09-25 3:27 ` Steven Rostedt
2012-09-25 20:48 ` David Sharp
2012-09-25 20:49 ` [PATCH v4 " David Sharp
2012-09-25 21:42 ` Steven Rostedt
2012-09-25 22:29 ` David Sharp
2012-09-25 22:29 ` David Sharp
2012-09-26 18:30 ` Steven Rostedt
2012-09-26 21:03 ` David Sharp
2012-09-25 23:36 ` Steven Rostedt
2012-09-26 0:32 ` David Sharp
2012-09-29 3:15 ` [PATCH v3 1/3] tracing,x86: add a TSC trace_clock Steven Rostedt
2012-10-02 0:33 ` David Sharp
2012-10-02 0:43 ` Steven Rostedt
2012-09-20 22:53 ` [PATCH v2 " David Sharp
2012-09-18 21:46 ` David Sharp
2012-09-12 23:31 ` [PATCH v2 2/3] tracing: reset ring buffer when changing trace_clocks David Sharp
2012-09-12 23:32 ` [PATCH v2 3/3] tracing: format non-nanosec times from tsc clock without a decimal point David Sharp
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=20120920085545.GA3497@gmail.com \
--to=mingo@kernel.org \
--cc=dhsharp@google.com \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.