Skip to content

Commit 5beda5f

Browse files
author
Ingo Molnar
committed
Merge branch 'tip/perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into perf/core
2 parents ba3dd36 + 6752ab4 commit 5beda5f

9 files changed

Lines changed: 74 additions & 197 deletions

File tree

‎Documentation/trace/ftrace-design.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ You need very few things to get the syscalls tracing in an arch.
247247
- Support the TIF_SYSCALL_TRACEPOINT thread flags.
248248
- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
249249
in the ptrace syscalls tracing path.
250+
- If the system call table on this arch is more complicated than a simple array
251+
of addresses of the system calls, implement an arch_syscall_addr to return
252+
the address of a given system call.
253+
- If the symbol names of the system calls do not match the function names on
254+
this arch, define ARCH_HAS_SYSCALL_MATCH_SYM_NAME in asm/ftrace.h and
255+
implement arch_syscall_match_sym_name with the appropriate logic to return
256+
true if the function name corresponds with the symbol name.
250257
- Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
251258

252259

‎Documentation/trace/ftrace.txt‎

Lines changed: 19 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ of ftrace. Here is a list of some of the key files:
8080
tracers listed here can be configured by
8181
echoing their name into current_tracer.
8282

83-
tracing_enabled:
83+
tracing_on:
8484

85-
This sets or displays whether the current_tracer
86-
is activated and tracing or not. Echo 0 into this
87-
file to disable the tracer or 1 to enable it.
85+
This sets or displays whether writing to the trace
86+
ring buffer is enabled. Echo 0 into this file to disable
87+
the tracer or 1 to enable it.
8888

8989
trace:
9090

@@ -202,10 +202,6 @@ Here is the list of current tracers that may be configured.
202202
to draw a graph of function calls similar to C code
203203
source.
204204

205-
"sched_switch"
206-
207-
Traces the context switches and wakeups between tasks.
208-
209205
"irqsoff"
210206

211207
Traces the areas that disable interrupts and saves
@@ -273,39 +269,6 @@ format, the function name that was traced "path_put" and the
273269
parent function that called this function "path_walk". The
274270
timestamp is the time at which the function was entered.
275271

276-
The sched_switch tracer also includes tracing of task wakeups
277-
and context switches.
278-
279-
ksoftirqd/1-7 [01] 1453.070013: 7:115:R + 2916:115:S
280-
ksoftirqd/1-7 [01] 1453.070013: 7:115:R + 10:115:S
281-
ksoftirqd/1-7 [01] 1453.070013: 7:115:R ==> 10:115:R
282-
events/1-10 [01] 1453.070013: 10:115:S ==> 2916:115:R
283-
kondemand/1-2916 [01] 1453.070013: 2916:115:S ==> 7:115:R
284-
ksoftirqd/1-7 [01] 1453.070013: 7:115:S ==> 0:140:R
285-
286-
Wake ups are represented by a "+" and the context switches are
287-
shown as "==>". The format is:
288-
289-
Context switches:
290-
291-
Previous task Next Task
292-
293-
<pid>:<prio>:<state> ==> <pid>:<prio>:<state>
294-
295-
Wake ups:
296-
297-
Current task Task waking up
298-
299-
<pid>:<prio>:<state> + <pid>:<prio>:<state>
300-
301-
The prio is the internal kernel priority, which is the inverse
302-
of the priority that is usually displayed by user-space tools.
303-
Zero represents the highest priority (99). Prio 100 starts the
304-
"nice" priorities with 100 being equal to nice -20 and 139 being
305-
nice 19. The prio "140" is reserved for the idle task which is
306-
the lowest priority thread (pid 0).
307-
308-
309272
Latency trace format
310273
--------------------
311274

@@ -491,79 +454,6 @@ x494] <- /root/a.out[+0x4a8] <- /lib/libc-2.7.so[+0x1e1a6]
491454
latencies, as described in "Latency
492455
trace format".
493456

494-
sched_switch
495-
------------
496-
497-
This tracer simply records schedule switches. Here is an example
498-
of how to use it.
499-
500-
# echo sched_switch > current_tracer
501-
# echo 1 > tracing_enabled
502-
# sleep 1
503-
# echo 0 > tracing_enabled
504-
# cat trace
505-
506-
# tracer: sched_switch
507-
#
508-
# TASK-PID CPU# TIMESTAMP FUNCTION
509-
# | | | | |
510-
bash-3997 [01] 240.132281: 3997:120:R + 4055:120:R
511-
bash-3997 [01] 240.132284: 3997:120:R ==> 4055:120:R
512-
sleep-4055 [01] 240.132371: 4055:120:S ==> 3997:120:R
513-
bash-3997 [01] 240.132454: 3997:120:R + 4055:120:S
514-
bash-3997 [01] 240.132457: 3997:120:R ==> 4055:120:R
515-
sleep-4055 [01] 240.132460: 4055:120:D ==> 3997:120:R
516-
bash-3997 [01] 240.132463: 3997:120:R + 4055:120:D
517-
bash-3997 [01] 240.132465: 3997:120:R ==> 4055:120:R
518-
<idle>-0 [00] 240.132589: 0:140:R + 4:115:S
519-
<idle>-0 [00] 240.132591: 0:140:R ==> 4:115:R
520-
ksoftirqd/0-4 [00] 240.132595: 4:115:S ==> 0:140:R
521-
<idle>-0 [00] 240.132598: 0:140:R + 4:115:S
522-
<idle>-0 [00] 240.132599: 0:140:R ==> 4:115:R
523-
ksoftirqd/0-4 [00] 240.132603: 4:115:S ==> 0:140:R
524-
sleep-4055 [01] 240.133058: 4055:120:S ==> 3997:120:R
525-
[...]
526-
527-
528-
As we have discussed previously about this format, the header
529-
shows the name of the trace and points to the options. The
530-
"FUNCTION" is a misnomer since here it represents the wake ups
531-
and context switches.
532-
533-
The sched_switch file only lists the wake ups (represented with
534-
'+') and context switches ('==>') with the previous task or
535-
current task first followed by the next task or task waking up.
536-
The format for both of these is PID:KERNEL-PRIO:TASK-STATE.
537-
Remember that the KERNEL-PRIO is the inverse of the actual
538-
priority with zero (0) being the highest priority and the nice
539-
values starting at 100 (nice -20). Below is a quick chart to map
540-
the kernel priority to user land priorities.
541-
542-
Kernel Space User Space
543-
===============================================================
544-
0(high) to 98(low) user RT priority 99(high) to 1(low)
545-
with SCHED_RR or SCHED_FIFO
546-
---------------------------------------------------------------
547-
99 sched_priority is not used in scheduling
548-
decisions(it must be specified as 0)
549-
---------------------------------------------------------------
550-
100(high) to 139(low) user nice -20(high) to 19(low)
551-
---------------------------------------------------------------
552-
140 idle task priority
553-
---------------------------------------------------------------
554-
555-
The task states are:
556-
557-
R - running : wants to run, may not actually be running
558-
S - sleep : process is waiting to be woken up (handles signals)
559-
D - disk sleep (uninterruptible sleep) : process must be woken up
560-
(ignores signals)
561-
T - stopped : process suspended
562-
t - traced : process is being traced (with something like gdb)
563-
Z - zombie : process waiting to be cleaned up
564-
X - unknown
565-
566-
567457
ftrace_enabled
568458
--------------
569459

@@ -607,10 +497,10 @@ an example:
607497
# echo irqsoff > current_tracer
608498
# echo latency-format > trace_options
609499
# echo 0 > tracing_max_latency
610-
# echo 1 > tracing_enabled
500+
# echo 1 > tracing_on
611501
# ls -ltr
612502
[...]
613-
# echo 0 > tracing_enabled
503+
# echo 0 > tracing_on
614504
# cat trace
615505
# tracer: irqsoff
616506
#
@@ -715,10 +605,10 @@ is much like the irqsoff tracer.
715605
# echo preemptoff > current_tracer
716606
# echo latency-format > trace_options
717607
# echo 0 > tracing_max_latency
718-
# echo 1 > tracing_enabled
608+
# echo 1 > tracing_on
719609
# ls -ltr
720610
[...]
721-
# echo 0 > tracing_enabled
611+
# echo 0 > tracing_on
722612
# cat trace
723613
# tracer: preemptoff
724614
#
@@ -863,10 +753,10 @@ tracers.
863753
# echo preemptirqsoff > current_tracer
864754
# echo latency-format > trace_options
865755
# echo 0 > tracing_max_latency
866-
# echo 1 > tracing_enabled
756+
# echo 1 > tracing_on
867757
# ls -ltr
868758
[...]
869-
# echo 0 > tracing_enabled
759+
# echo 0 > tracing_on
870760
# cat trace
871761
# tracer: preemptirqsoff
872762
#
@@ -1026,9 +916,9 @@ Instead of performing an 'ls', we will run 'sleep 1' under
1026916
# echo wakeup > current_tracer
1027917
# echo latency-format > trace_options
1028918
# echo 0 > tracing_max_latency
1029-
# echo 1 > tracing_enabled
919+
# echo 1 > tracing_on
1030920
# chrt -f 5 sleep 1
1031-
# echo 0 > tracing_enabled
921+
# echo 0 > tracing_on
1032922
# cat trace
1033923
# tracer: wakeup
1034924
#
@@ -1140,9 +1030,9 @@ ftrace_enabled is set; otherwise this tracer is a nop.
11401030

11411031
# sysctl kernel.ftrace_enabled=1
11421032
# echo function > current_tracer
1143-
# echo 1 > tracing_enabled
1033+
# echo 1 > tracing_on
11441034
# usleep 1
1145-
# echo 0 > tracing_enabled
1035+
# echo 0 > tracing_on
11461036
# cat trace
11471037
# tracer: function
11481038
#
@@ -1180,7 +1070,7 @@ int trace_fd;
11801070
[...]
11811071
int main(int argc, char *argv[]) {
11821072
[...]
1183-
trace_fd = open(tracing_file("tracing_enabled"), O_WRONLY);
1073+
trace_fd = open(tracing_file("tracing_on"), O_WRONLY);
11841074
[...]
11851075
if (condition_hit()) {
11861076
write(trace_fd, "0", 1);
@@ -1631,9 +1521,9 @@ If I am only interested in sys_nanosleep and hrtimer_interrupt:
16311521
# echo sys_nanosleep hrtimer_interrupt \
16321522
> set_ftrace_filter
16331523
# echo function > current_tracer
1634-
# echo 1 > tracing_enabled
1524+
# echo 1 > tracing_on
16351525
# usleep 1
1636-
# echo 0 > tracing_enabled
1526+
# echo 0 > tracing_on
16371527
# cat trace
16381528
# tracer: ftrace
16391529
#
@@ -1879,9 +1769,9 @@ different. The trace is live.
18791769
# echo function > current_tracer
18801770
# cat trace_pipe > /tmp/trace.out &
18811771
[1] 4153
1882-
# echo 1 > tracing_enabled
1772+
# echo 1 > tracing_on
18831773
# usleep 1
1884-
# echo 0 > tracing_enabled
1774+
# echo 0 > tracing_on
18851775
# cat trace
18861776
# tracer: function
18871777
#

‎include/linux/syscalls.h‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ extern struct trace_event_functions exit_syscall_print_funcs;
132132
.class = &event_class_syscall_enter, \
133133
.event.funcs = &enter_syscall_print_funcs, \
134134
.data = (void *)&__syscall_meta_##sname,\
135+
.flags = TRACE_EVENT_FL_CAP_ANY, \
135136
}; \
136137
static struct ftrace_event_call __used \
137138
__attribute__((section("_ftrace_events"))) \
138-
*__event_enter_##sname = &event_enter_##sname; \
139-
__TRACE_EVENT_FLAGS(enter_##sname, TRACE_EVENT_FL_CAP_ANY)
139+
*__event_enter_##sname = &event_enter_##sname;
140140

141141
#define SYSCALL_TRACE_EXIT_EVENT(sname) \
142142
static struct syscall_metadata __syscall_meta_##sname; \
@@ -146,18 +146,19 @@ extern struct trace_event_functions exit_syscall_print_funcs;
146146
.class = &event_class_syscall_exit, \
147147
.event.funcs = &exit_syscall_print_funcs, \
148148
.data = (void *)&__syscall_meta_##sname,\
149+
.flags = TRACE_EVENT_FL_CAP_ANY, \
149150
}; \
150151
static struct ftrace_event_call __used \
151152
__attribute__((section("_ftrace_events"))) \
152-
*__event_exit_##sname = &event_exit_##sname; \
153-
__TRACE_EVENT_FLAGS(exit_##sname, TRACE_EVENT_FL_CAP_ANY)
153+
*__event_exit_##sname = &event_exit_##sname;
154154

155155
#define SYSCALL_METADATA(sname, nb) \
156156
SYSCALL_TRACE_ENTER_EVENT(sname); \
157157
SYSCALL_TRACE_EXIT_EVENT(sname); \
158158
static struct syscall_metadata __used \
159159
__syscall_meta_##sname = { \
160160
.name = "sys"#sname, \
161+
.syscall_nr = -1, /* Filled in at boot */ \
161162
.nb_args = nb, \
162163
.types = types_##sname, \
163164
.args = args_##sname, \
@@ -175,6 +176,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
175176
static struct syscall_metadata __used \
176177
__syscall_meta__##sname = { \
177178
.name = "sys_"#sname, \
179+
.syscall_nr = -1, /* Filled in at boot */ \
178180
.nb_args = 0, \
179181
.enter_event = &event_enter__##sname, \
180182
.exit_event = &event_exit__##sname, \

‎kernel/trace/ring_buffer.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,10 +2163,14 @@ rb_reserve_next_event(struct ring_buffer *buffer,
21632163
delta = diff;
21642164
if (unlikely(test_time_stamp(delta))) {
21652165
WARN_ONCE(delta > (1ULL << 59),
2166-
KERN_WARNING "Delta way too big! %llu ts=%llu write stamp = %llu\n",
2166+
KERN_WARNING "Delta way too big! %llu ts=%llu write stamp = %llu\n%s",
21672167
(unsigned long long)delta,
21682168
(unsigned long long)ts,
2169-
(unsigned long long)cpu_buffer->write_stamp);
2169+
(unsigned long long)cpu_buffer->write_stamp,
2170+
sched_clock_stable ? "" :
2171+
"If you just came from a suspend/resume,\n"
2172+
"please switch to the trace global clock:\n"
2173+
" echo global > /sys/kernel/debug/tracing/trace_clock\n");
21702174
add_timestamp = 1;
21712175
}
21722176
}

‎kernel/trace/trace.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,10 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf,
27102710

27112711
mutex_lock(&trace_types_lock);
27122712
if (tracer_enabled ^ val) {
2713+
2714+
/* Only need to warn if this is used to change the state */
2715+
WARN_ONCE(1, "tracing_enabled is deprecated. Use tracing_on");
2716+
27132717
if (val) {
27142718
tracer_enabled = 1;
27152719
if (current_trace->start)

‎kernel/trace/trace_sched_switch.c‎

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -247,51 +247,3 @@ void tracing_sched_switch_assign_trace(struct trace_array *tr)
247247
ctx_trace = tr;
248248
}
249249

250-
static void stop_sched_trace(struct trace_array *tr)
251-
{
252-
tracing_stop_sched_switch_record();
253-
}
254-
255-
static int sched_switch_trace_init(struct trace_array *tr)
256-
{
257-
ctx_trace = tr;
258-
tracing_reset_online_cpus(tr);
259-
tracing_start_sched_switch_record();
260-
return 0;
261-
}
262-
263-
static void sched_switch_trace_reset(struct trace_array *tr)
264-
{
265-
if (sched_ref)
266-
stop_sched_trace(tr);
267-
}
268-
269-
static void sched_switch_trace_start(struct trace_array *tr)
270-
{
271-
sched_stopped = 0;
272-
}
273-
274-
static void sched_switch_trace_stop(struct trace_array *tr)
275-
{
276-
sched_stopped = 1;
277-
}
278-
279-
static struct tracer sched_switch_trace __read_mostly =
280-
{
281-
.name = "sched_switch",
282-
.init = sched_switch_trace_init,
283-
.reset = sched_switch_trace_reset,
284-
.start = sched_switch_trace_start,
285-
.stop = sched_switch_trace_stop,
286-
.wait_pipe = poll_wait_pipe,
287-
#ifdef CONFIG_FTRACE_SELFTEST
288-
.selftest = trace_selftest_startup_sched_switch,
289-
#endif
290-
};
291-
292-
__init static int init_sched_switch_trace(void)
293-
{
294-
return register_tracer(&sched_switch_trace);
295-
}
296-
device_initcall(init_sched_switch_trace);
297-

0 commit comments

Comments
 (0)