Skip to content

Commit 92b29b8

Browse files
committed
Merge branch 'tracing-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'tracing-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (131 commits) tracing/fastboot: improve help text tracing/stacktrace: improve help text tracing/fastboot: fix initcalls disposition in bootgraph.pl tracing/fastboot: fix bootgraph.pl initcall name regexp tracing/fastboot: fix issues and improve output of bootgraph.pl tracepoints: synchronize unregister static inline tracepoints: tracepoint_synchronize_unregister() ftrace: make ftrace_test_p6nop disassembler-friendly markers: fix synchronize marker unregister static inline tracing/fastboot: add better resolution to initcall debug/tracing trace: add build-time check to avoid overrunning hex buffer ftrace: fix hex output mode of ftrace tracing/fastboot: fix initcalls disposition in bootgraph.pl tracing/fastboot: fix printk format typo in boot tracer ftrace: return an error when setting a nonexistent tracer ftrace: make some tracers reentrant ring-buffer: make reentrant ring-buffer: move page indexes into page headers tracing/fastboot: only trace non-module initcalls ftrace: move pc counter in irqtrace ... Manually fix conflicts: - init/main.c: initcall tracing - kernel/module.c: verbose level vs tracepoints - scripts/bootgraph.pl: fallout from cherry-picking commits.
2 parents b9d7ccf + 98d9c66 commit 92b29b8

65 files changed

Lines changed: 6109 additions & 1586 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/markers.txt‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ Connecting a function (probe) to a marker is done by providing a probe (function
5050
to call) for the specific marker through marker_probe_register() and can be
5151
activated by calling marker_arm(). Marker deactivation can be done by calling
5252
marker_disarm() as many times as marker_arm() has been called. Removing a probe
53-
is done through marker_probe_unregister(); it will disarm the probe and make
54-
sure there is no caller left using the probe when it returns. Probe removal is
55-
preempt-safe because preemption is disabled around the probe call. See the
56-
"Probe example" section below for a sample probe module.
53+
is done through marker_probe_unregister(); it will disarm the probe.
54+
marker_synchronize_unregister() must be called before the end of the module exit
55+
function to make sure there is no caller left using the probe. This, and the
56+
fact that preemption is disabled around the probe call, make sure that probe
57+
removal and module unload are safe. See the "Probe example" section below for a
58+
sample probe module.
5759

5860
The marker mechanism supports inserting multiple instances of the same marker.
5961
Markers can be put in inline functions, inlined static functions, and

‎Documentation/tracepoints.txt‎

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
Using the Linux Kernel Tracepoints
2+
3+
Mathieu Desnoyers
4+
5+
6+
This document introduces Linux Kernel Tracepoints and their use. It provides
7+
examples of how to insert tracepoints in the kernel and connect probe functions
8+
to them and provides some examples of probe functions.
9+
10+
11+
* Purpose of tracepoints
12+
13+
A tracepoint placed in code provides a hook to call a function (probe) that you
14+
can provide at runtime. A tracepoint can be "on" (a probe is connected to it) or
15+
"off" (no probe is attached). When a tracepoint is "off" it has no effect,
16+
except for adding a tiny time penalty (checking a condition for a branch) and
17+
space penalty (adding a few bytes for the function call at the end of the
18+
instrumented function and adds a data structure in a separate section). When a
19+
tracepoint is "on", the function you provide is called each time the tracepoint
20+
is executed, in the execution context of the caller. When the function provided
21+
ends its execution, it returns to the caller (continuing from the tracepoint
22+
site).
23+
24+
You can put tracepoints at important locations in the code. They are
25+
lightweight hooks that can pass an arbitrary number of parameters,
26+
which prototypes are described in a tracepoint declaration placed in a header
27+
file.
28+
29+
They can be used for tracing and performance accounting.
30+
31+
32+
* Usage
33+
34+
Two elements are required for tracepoints :
35+
36+
- A tracepoint definition, placed in a header file.
37+
- The tracepoint statement, in C code.
38+
39+
In order to use tracepoints, you should include linux/tracepoint.h.
40+
41+
In include/trace/subsys.h :
42+
43+
#include <linux/tracepoint.h>
44+
45+
DEFINE_TRACE(subsys_eventname,
46+
TPPTOTO(int firstarg, struct task_struct *p),
47+
TPARGS(firstarg, p));
48+
49+
In subsys/file.c (where the tracing statement must be added) :
50+
51+
#include <trace/subsys.h>
52+
53+
void somefct(void)
54+
{
55+
...
56+
trace_subsys_eventname(arg, task);
57+
...
58+
}
59+
60+
Where :
61+
- subsys_eventname is an identifier unique to your event
62+
- subsys is the name of your subsystem.
63+
- eventname is the name of the event to trace.
64+
- TPPTOTO(int firstarg, struct task_struct *p) is the prototype of the function
65+
called by this tracepoint.
66+
- TPARGS(firstarg, p) are the parameters names, same as found in the prototype.
67+
68+
Connecting a function (probe) to a tracepoint is done by providing a probe
69+
(function to call) for the specific tracepoint through
70+
register_trace_subsys_eventname(). Removing a probe is done through
71+
unregister_trace_subsys_eventname(); it will remove the probe sure there is no
72+
caller left using the probe when it returns. Probe removal is preempt-safe
73+
because preemption is disabled around the probe call. See the "Probe example"
74+
section below for a sample probe module.
75+
76+
The tracepoint mechanism supports inserting multiple instances of the same
77+
tracepoint, but a single definition must be made of a given tracepoint name over
78+
all the kernel to make sure no type conflict will occur. Name mangling of the
79+
tracepoints is done using the prototypes to make sure typing is correct.
80+
Verification of probe type correctness is done at the registration site by the
81+
compiler. Tracepoints can be put in inline functions, inlined static functions,
82+
and unrolled loops as well as regular functions.
83+
84+
The naming scheme "subsys_event" is suggested here as a convention intended
85+
to limit collisions. Tracepoint names are global to the kernel: they are
86+
considered as being the same whether they are in the core kernel image or in
87+
modules.
88+
89+
90+
* Probe / tracepoint example
91+
92+
See the example provided in samples/tracepoints/src
93+
94+
Compile them with your kernel.
95+
96+
Run, as root :
97+
modprobe tracepoint-example (insmod order is not important)
98+
modprobe tracepoint-probe-example
99+
cat /proc/tracepoint-example (returns an expected error)
100+
rmmod tracepoint-example tracepoint-probe-example
101+
dmesg

‎Documentation/tracers/mmiotrace.txt‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $ mount -t debugfs debugfs /debug
3636
$ echo mmiotrace > /debug/tracing/current_tracer
3737
$ cat /debug/tracing/trace_pipe > mydump.txt &
3838
Start X or whatever.
39-
$ echo "X is up" > /debug/tracing/marker
39+
$ echo "X is up" > /debug/tracing/trace_marker
4040
$ echo none > /debug/tracing/current_tracer
4141
Check for lost events.
4242

@@ -59,9 +59,8 @@ The 'cat' process should stay running (sleeping) in the background.
5959
Load the driver you want to trace and use it. Mmiotrace will only catch MMIO
6060
accesses to areas that are ioremapped while mmiotrace is active.
6161

62-
[Unimplemented feature:]
6362
During tracing you can place comments (markers) into the trace by
64-
$ echo "X is up" > /debug/tracing/marker
63+
$ echo "X is up" > /debug/tracing/trace_marker
6564
This makes it easier to see which part of the (huge) trace corresponds to
6665
which action. It is recommended to place descriptive markers about what you
6766
do.

‎arch/powerpc/platforms/cell/spufs/sputrace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ static void __exit sputrace_exit(void)
232232

233233
remove_proc_entry("sputrace", NULL);
234234
kfree(sputrace_log);
235+
marker_synchronize_unregister();
235236
}
236237

237238
module_init(sputrace_init);

‎arch/x86/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ config X86
2626
select HAVE_KPROBES
2727
select ARCH_WANT_OPTIONAL_GPIOLIB
2828
select HAVE_KRETPROBES
29+
select HAVE_FTRACE_MCOUNT_RECORD
2930
select HAVE_DYNAMIC_FTRACE
3031
select HAVE_FTRACE
3132
select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64)

‎arch/x86/kernel/cpu/perfctr-watchdog.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <linux/bitops.h>
1818
#include <linux/smp.h>
1919
#include <linux/nmi.h>
20+
#include <linux/kprobes.h>
21+
2022
#include <asm/apic.h>
2123
#include <asm/intel_arch_perfmon.h>
2224

@@ -336,7 +338,8 @@ static void single_msr_unreserve(void)
336338
release_perfctr_nmi(wd_ops->perfctr);
337339
}
338340

339-
static void single_msr_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
341+
static void __kprobes
342+
single_msr_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
340343
{
341344
/* start the cycle over again */
342345
write_watchdog_counter(wd->perfctr_msr, NULL, nmi_hz);
@@ -401,7 +404,7 @@ static int setup_p6_watchdog(unsigned nmi_hz)
401404
return 1;
402405
}
403406

404-
static void p6_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
407+
static void __kprobes p6_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
405408
{
406409
/*
407410
* P6 based Pentium M need to re-unmask
@@ -605,7 +608,7 @@ static void p4_unreserve(void)
605608
release_perfctr_nmi(MSR_P4_IQ_PERFCTR0);
606609
}
607610

608-
static void p4_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
611+
static void __kprobes p4_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
609612
{
610613
unsigned dummy;
611614
/*
@@ -784,7 +787,7 @@ unsigned lapic_adjust_nmi_hz(unsigned hz)
784787
return hz;
785788
}
786789

787-
int lapic_wd_event(unsigned nmi_hz)
790+
int __kprobes lapic_wd_event(unsigned nmi_hz)
788791
{
789792
struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
790793
u64 ctr;

‎arch/x86/kernel/entry_32.S‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,20 +1153,6 @@ ENDPROC(xen_failsafe_callback)
11531153
#ifdef CONFIG_DYNAMIC_FTRACE
11541154

11551155
ENTRY(mcount)
1156-
pushl %eax
1157-
pushl %ecx
1158-
pushl %edx
1159-
movl 0xc(%esp), %eax
1160-
subl $MCOUNT_INSN_SIZE, %eax
1161-
1162-
.globl mcount_call
1163-
mcount_call:
1164-
call ftrace_stub
1165-
1166-
popl %edx
1167-
popl %ecx
1168-
popl %eax
1169-
11701156
ret
11711157
END(mcount)
11721158

‎arch/x86/kernel/entry_64.S‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,32 +64,6 @@
6464
#ifdef CONFIG_FTRACE
6565
#ifdef CONFIG_DYNAMIC_FTRACE
6666
ENTRY(mcount)
67-
68-
subq $0x38, %rsp
69-
movq %rax, (%rsp)
70-
movq %rcx, 8(%rsp)
71-
movq %rdx, 16(%rsp)
72-
movq %rsi, 24(%rsp)
73-
movq %rdi, 32(%rsp)
74-
movq %r8, 40(%rsp)
75-
movq %r9, 48(%rsp)
76-
77-
movq 0x38(%rsp), %rdi
78-
subq $MCOUNT_INSN_SIZE, %rdi
79-
80-
.globl mcount_call
81-
mcount_call:
82-
call ftrace_stub
83-
84-
movq 48(%rsp), %r9
85-
movq 40(%rsp), %r8
86-
movq 32(%rsp), %rdi
87-
movq 24(%rsp), %rsi
88-
movq 16(%rsp), %rdx
89-
movq 8(%rsp), %rcx
90-
movq (%rsp), %rax
91-
addq $0x38, %rsp
92-
9367
retq
9468
END(mcount)
9569

0 commit comments

Comments
 (0)