Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/ftrace: add powerpc timebase as a trace clock source

Add a new powerpc-specific trace clock using the timebase register,
similar to x86-tsc. This gives us
- a fast, monotonic, hardware clock source for trace entries, and
- a clock that can be used to correlate events across cpus as well as across
hypervisor and guests.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Naveen N. Rao and committed by
Michael Ellerman
197165d4 35a7f41c

+40 -1
+5
Documentation/trace/ftrace.txt
··· 346 346 x86-tsc: Architectures may define their own clocks. For 347 347 example, x86 uses its own TSC cycle clock here. 348 348 349 + ppc-tb: This uses the powerpc timebase register value. 350 + This is in sync across CPUs and can also be used 351 + to correlate events across hypervisor/guest if 352 + tb_offset is known. 353 + 349 354 To set a clock, simply echo the clock name into this file. 350 355 351 356 echo global > trace_clock
-1
arch/powerpc/include/asm/Kbuild
··· 6 6 generic-y += mcs_spinlock.h 7 7 generic-y += preempt.h 8 8 generic-y += rwsem.h 9 - generic-y += trace_clock.h 10 9 generic-y += vtime.h
+19
arch/powerpc/include/asm/trace_clock.h
··· 1 + /* 2 + * This program is free software; you can redistribute it and/or modify 3 + * it under the terms of the GNU General Public License, version 2, as 4 + * published by the Free Software Foundation. 5 + * 6 + * Copyright (C) 2015 Naveen N. Rao, IBM Corporation 7 + */ 8 + 9 + #ifndef _ASM_PPC_TRACE_CLOCK_H 10 + #define _ASM_PPC_TRACE_CLOCK_H 11 + 12 + #include <linux/compiler.h> 13 + #include <linux/types.h> 14 + 15 + extern u64 notrace trace_clock_ppc_tb(void); 16 + 17 + #define ARCH_TRACE_CLOCKS { trace_clock_ppc_tb, "ppc-tb", 0 }, 18 + 19 + #endif /* _ASM_PPC_TRACE_CLOCK_H */
+1
arch/powerpc/kernel/Makefile
··· 118 118 obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o 119 119 obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o 120 120 obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o 121 + obj-$(CONFIG_TRACING) += trace_clock.o 121 122 122 123 ifneq ($(CONFIG_PPC_INDIRECT_PIO),y) 123 124 obj-y += iomap.o
+15
arch/powerpc/kernel/trace_clock.c
··· 1 + /* 2 + * This program is free software; you can redistribute it and/or modify 3 + * it under the terms of the GNU General Public License, version 2, as 4 + * published by the Free Software Foundation. 5 + * 6 + * Copyright (C) 2015 Naveen N. Rao, IBM Corporation 7 + */ 8 + 9 + #include <asm/trace_clock.h> 10 + #include <asm/time.h> 11 + 12 + u64 notrace trace_clock_ppc_tb(void) 13 + { 14 + return get_tb(); 15 + }