diff options
Diffstat (limited to 'Documentation/trace/ftrace.txt')
-rw-r--r-- | Documentation/trace/ftrace.txt | 252 |
1 files changed, 156 insertions, 96 deletions
diff --git a/Documentation/trace/ftrace.txt b/Documentation/trace/ftrace.txt index fd9a3e693813..a39b3c749de5 100644 --- a/Documentation/trace/ftrace.txt +++ b/Documentation/trace/ftrace.txt | |||
@@ -7,7 +7,6 @@ Copyright 2008 Red Hat Inc. | |||
7 | (dual licensed under the GPL v2) | 7 | (dual licensed under the GPL v2) |
8 | Reviewers: Elias Oltmanns, Randy Dunlap, Andrew Morton, | 8 | Reviewers: Elias Oltmanns, Randy Dunlap, Andrew Morton, |
9 | John Kacur, and David Teigland. | 9 | John Kacur, and David Teigland. |
10 | |||
11 | Written for: 2.6.28-rc2 | 10 | Written for: 2.6.28-rc2 |
12 | 11 | ||
13 | Introduction | 12 | Introduction |
@@ -33,13 +32,26 @@ The File System | |||
33 | Ftrace uses the debugfs file system to hold the control files as | 32 | Ftrace uses the debugfs file system to hold the control files as |
34 | well as the files to display output. | 33 | well as the files to display output. |
35 | 34 | ||
36 | To mount the debugfs system: | 35 | When debugfs is configured into the kernel (which selecting any ftrace |
36 | option will do) the directory /sys/kernel/debug will be created. To mount | ||
37 | this directory, you can add to your /etc/fstab file: | ||
38 | |||
39 | debugfs /sys/kernel/debug debugfs defaults 0 0 | ||
40 | |||
41 | Or you can mount it at run time with: | ||
42 | |||
43 | mount -t debugfs nodev /sys/kernel/debug | ||
37 | 44 | ||
38 | # mkdir /debug | 45 | For quicker access to that directory you may want to make a soft link to |
39 | # mount -t debugfs nodev /debug | 46 | it: |
40 | 47 | ||
41 | ( Note: it is more common to mount at /sys/kernel/debug, but for | 48 | ln -s /sys/kernel/debug /debug |
42 | simplicity this document will use /debug) | 49 | |
50 | Any selected ftrace option will also create a directory called tracing | ||
51 | within the debugfs. The rest of the document will assume that you are in | ||
52 | the ftrace directory (cd /sys/kernel/debug/tracing) and will only concentrate | ||
53 | on the files within that directory and not distract from the content with | ||
54 | the extended "/sys/kernel/debug/tracing" path name. | ||
43 | 55 | ||
44 | That's it! (assuming that you have ftrace configured into your kernel) | 56 | That's it! (assuming that you have ftrace configured into your kernel) |
45 | 57 | ||
@@ -179,7 +191,7 @@ Here is the list of current tracers that may be configured. | |||
179 | 191 | ||
180 | Function call tracer to trace all kernel functions. | 192 | Function call tracer to trace all kernel functions. |
181 | 193 | ||
182 | "function_graph_tracer" | 194 | "function_graph" |
183 | 195 | ||
184 | Similar to the function tracer except that the | 196 | Similar to the function tracer except that the |
185 | function tracer probes the functions on their entry | 197 | function tracer probes the functions on their entry |
@@ -389,18 +401,18 @@ trace_options | |||
389 | The trace_options file is used to control what gets printed in | 401 | The trace_options file is used to control what gets printed in |
390 | the trace output. To see what is available, simply cat the file: | 402 | the trace output. To see what is available, simply cat the file: |
391 | 403 | ||
392 | cat /debug/tracing/trace_options | 404 | cat trace_options |
393 | print-parent nosym-offset nosym-addr noverbose noraw nohex nobin \ | 405 | print-parent nosym-offset nosym-addr noverbose noraw nohex nobin \ |
394 | noblock nostacktrace nosched-tree nouserstacktrace nosym-userobj | 406 | noblock nostacktrace nosched-tree nouserstacktrace nosym-userobj |
395 | 407 | ||
396 | To disable one of the options, echo in the option prepended with | 408 | To disable one of the options, echo in the option prepended with |
397 | "no". | 409 | "no". |
398 | 410 | ||
399 | echo noprint-parent > /debug/tracing/trace_options | 411 | echo noprint-parent > trace_options |
400 | 412 | ||
401 | To enable an option, leave off the "no". | 413 | To enable an option, leave off the "no". |
402 | 414 | ||
403 | echo sym-offset > /debug/tracing/trace_options | 415 | echo sym-offset > trace_options |
404 | 416 | ||
405 | Here are the available options: | 417 | Here are the available options: |
406 | 418 | ||
@@ -476,11 +488,11 @@ sched_switch | |||
476 | This tracer simply records schedule switches. Here is an example | 488 | This tracer simply records schedule switches. Here is an example |
477 | of how to use it. | 489 | of how to use it. |
478 | 490 | ||
479 | # echo sched_switch > /debug/tracing/current_tracer | 491 | # echo sched_switch > current_tracer |
480 | # echo 1 > /debug/tracing/tracing_enabled | 492 | # echo 1 > tracing_enabled |
481 | # sleep 1 | 493 | # sleep 1 |
482 | # echo 0 > /debug/tracing/tracing_enabled | 494 | # echo 0 > tracing_enabled |
483 | # cat /debug/tracing/trace | 495 | # cat trace |
484 | 496 | ||
485 | # tracer: sched_switch | 497 | # tracer: sched_switch |
486 | # | 498 | # |
@@ -518,9 +530,18 @@ priority with zero (0) being the highest priority and the nice | |||
518 | values starting at 100 (nice -20). Below is a quick chart to map | 530 | values starting at 100 (nice -20). Below is a quick chart to map |
519 | the kernel priority to user land priorities. | 531 | the kernel priority to user land priorities. |
520 | 532 | ||
521 | Kernel priority: 0 to 99 ==> user RT priority 99 to 0 | 533 | Kernel Space User Space |
522 | Kernel priority: 100 to 139 ==> user nice -20 to 19 | 534 | =============================================================== |
523 | Kernel priority: 140 ==> idle task priority | 535 | 0(high) to 98(low) user RT priority 99(high) to 1(low) |
536 | with SCHED_RR or SCHED_FIFO | ||
537 | --------------------------------------------------------------- | ||
538 | 99 sched_priority is not used in scheduling | ||
539 | decisions(it must be specified as 0) | ||
540 | --------------------------------------------------------------- | ||
541 | 100(high) to 139(low) user nice -20(high) to 19(low) | ||
542 | --------------------------------------------------------------- | ||
543 | 140 idle task priority | ||
544 | --------------------------------------------------------------- | ||
524 | 545 | ||
525 | The task states are: | 546 | The task states are: |
526 | 547 | ||
@@ -574,13 +595,13 @@ new trace is saved. | |||
574 | To reset the maximum, echo 0 into tracing_max_latency. Here is | 595 | To reset the maximum, echo 0 into tracing_max_latency. Here is |
575 | an example: | 596 | an example: |
576 | 597 | ||
577 | # echo irqsoff > /debug/tracing/current_tracer | 598 | # echo irqsoff > current_tracer |
578 | # echo 0 > /debug/tracing/tracing_max_latency | 599 | # echo 0 > tracing_max_latency |
579 | # echo 1 > /debug/tracing/tracing_enabled | 600 | # echo 1 > tracing_enabled |
580 | # ls -ltr | 601 | # ls -ltr |
581 | [...] | 602 | [...] |
582 | # echo 0 > /debug/tracing/tracing_enabled | 603 | # echo 0 > tracing_enabled |
583 | # cat /debug/tracing/latency_trace | 604 | # cat latency_trace |
584 | # tracer: irqsoff | 605 | # tracer: irqsoff |
585 | # | 606 | # |
586 | irqsoff latency trace v1.1.5 on 2.6.26 | 607 | irqsoff latency trace v1.1.5 on 2.6.26 |
@@ -681,13 +702,13 @@ Like the irqsoff tracer, it records the maximum latency for | |||
681 | which preemption was disabled. The control of preemptoff tracer | 702 | which preemption was disabled. The control of preemptoff tracer |
682 | is much like the irqsoff tracer. | 703 | is much like the irqsoff tracer. |
683 | 704 | ||
684 | # echo preemptoff > /debug/tracing/current_tracer | 705 | # echo preemptoff > current_tracer |
685 | # echo 0 > /debug/tracing/tracing_max_latency | 706 | # echo 0 > tracing_max_latency |
686 | # echo 1 > /debug/tracing/tracing_enabled | 707 | # echo 1 > tracing_enabled |
687 | # ls -ltr | 708 | # ls -ltr |
688 | [...] | 709 | [...] |
689 | # echo 0 > /debug/tracing/tracing_enabled | 710 | # echo 0 > tracing_enabled |
690 | # cat /debug/tracing/latency_trace | 711 | # cat latency_trace |
691 | # tracer: preemptoff | 712 | # tracer: preemptoff |
692 | # | 713 | # |
693 | preemptoff latency trace v1.1.5 on 2.6.26-rc8 | 714 | preemptoff latency trace v1.1.5 on 2.6.26-rc8 |
@@ -828,13 +849,13 @@ tracer. | |||
828 | Again, using this trace is much like the irqsoff and preemptoff | 849 | Again, using this trace is much like the irqsoff and preemptoff |
829 | tracers. | 850 | tracers. |
830 | 851 | ||
831 | # echo preemptirqsoff > /debug/tracing/current_tracer | 852 | # echo preemptirqsoff > current_tracer |
832 | # echo 0 > /debug/tracing/tracing_max_latency | 853 | # echo 0 > tracing_max_latency |
833 | # echo 1 > /debug/tracing/tracing_enabled | 854 | # echo 1 > tracing_enabled |
834 | # ls -ltr | 855 | # ls -ltr |
835 | [...] | 856 | [...] |
836 | # echo 0 > /debug/tracing/tracing_enabled | 857 | # echo 0 > tracing_enabled |
837 | # cat /debug/tracing/latency_trace | 858 | # cat latency_trace |
838 | # tracer: preemptirqsoff | 859 | # tracer: preemptirqsoff |
839 | # | 860 | # |
840 | preemptirqsoff latency trace v1.1.5 on 2.6.26-rc8 | 861 | preemptirqsoff latency trace v1.1.5 on 2.6.26-rc8 |
@@ -990,12 +1011,12 @@ slightly differently than we did with the previous tracers. | |||
990 | Instead of performing an 'ls', we will run 'sleep 1' under | 1011 | Instead of performing an 'ls', we will run 'sleep 1' under |
991 | 'chrt' which changes the priority of the task. | 1012 | 'chrt' which changes the priority of the task. |
992 | 1013 | ||
993 | # echo wakeup > /debug/tracing/current_tracer | 1014 | # echo wakeup > current_tracer |
994 | # echo 0 > /debug/tracing/tracing_max_latency | 1015 | # echo 0 > tracing_max_latency |
995 | # echo 1 > /debug/tracing/tracing_enabled | 1016 | # echo 1 > tracing_enabled |
996 | # chrt -f 5 sleep 1 | 1017 | # chrt -f 5 sleep 1 |
997 | # echo 0 > /debug/tracing/tracing_enabled | 1018 | # echo 0 > tracing_enabled |
998 | # cat /debug/tracing/latency_trace | 1019 | # cat latency_trace |
999 | # tracer: wakeup | 1020 | # tracer: wakeup |
1000 | # | 1021 | # |
1001 | wakeup latency trace v1.1.5 on 2.6.26-rc8 | 1022 | wakeup latency trace v1.1.5 on 2.6.26-rc8 |
@@ -1105,11 +1126,11 @@ can be done from the debug file system. Make sure the | |||
1105 | ftrace_enabled is set; otherwise this tracer is a nop. | 1126 | ftrace_enabled is set; otherwise this tracer is a nop. |
1106 | 1127 | ||
1107 | # sysctl kernel.ftrace_enabled=1 | 1128 | # sysctl kernel.ftrace_enabled=1 |
1108 | # echo function > /debug/tracing/current_tracer | 1129 | # echo function > current_tracer |
1109 | # echo 1 > /debug/tracing/tracing_enabled | 1130 | # echo 1 > tracing_enabled |
1110 | # usleep 1 | 1131 | # usleep 1 |
1111 | # echo 0 > /debug/tracing/tracing_enabled | 1132 | # echo 0 > tracing_enabled |
1112 | # cat /debug/tracing/trace | 1133 | # cat trace |
1113 | # tracer: function | 1134 | # tracer: function |
1114 | # | 1135 | # |
1115 | # TASK-PID CPU# TIMESTAMP FUNCTION | 1136 | # TASK-PID CPU# TIMESTAMP FUNCTION |
@@ -1146,7 +1167,7 @@ int trace_fd; | |||
1146 | [...] | 1167 | [...] |
1147 | int main(int argc, char *argv[]) { | 1168 | int main(int argc, char *argv[]) { |
1148 | [...] | 1169 | [...] |
1149 | trace_fd = open("/debug/tracing/tracing_enabled", O_WRONLY); | 1170 | trace_fd = open(tracing_file("tracing_enabled"), O_WRONLY); |
1150 | [...] | 1171 | [...] |
1151 | if (condition_hit()) { | 1172 | if (condition_hit()) { |
1152 | write(trace_fd, "0", 1); | 1173 | write(trace_fd, "0", 1); |
@@ -1154,26 +1175,20 @@ int main(int argc, char *argv[]) { | |||
1154 | [...] | 1175 | [...] |
1155 | } | 1176 | } |
1156 | 1177 | ||
1157 | Note: Here we hard coded the path name. The debugfs mount is not | ||
1158 | guaranteed to be at /debug (and is more commonly at | ||
1159 | /sys/kernel/debug). For simple one time traces, the above is | ||
1160 | sufficent. For anything else, a search through /proc/mounts may | ||
1161 | be needed to find where the debugfs file-system is mounted. | ||
1162 | |||
1163 | 1178 | ||
1164 | Single thread tracing | 1179 | Single thread tracing |
1165 | --------------------- | 1180 | --------------------- |
1166 | 1181 | ||
1167 | By writing into /debug/tracing/set_ftrace_pid you can trace a | 1182 | By writing into set_ftrace_pid you can trace a |
1168 | single thread. For example: | 1183 | single thread. For example: |
1169 | 1184 | ||
1170 | # cat /debug/tracing/set_ftrace_pid | 1185 | # cat set_ftrace_pid |
1171 | no pid | 1186 | no pid |
1172 | # echo 3111 > /debug/tracing/set_ftrace_pid | 1187 | # echo 3111 > set_ftrace_pid |
1173 | # cat /debug/tracing/set_ftrace_pid | 1188 | # cat set_ftrace_pid |
1174 | 3111 | 1189 | 3111 |
1175 | # echo function > /debug/tracing/current_tracer | 1190 | # echo function > current_tracer |
1176 | # cat /debug/tracing/trace | head | 1191 | # cat trace | head |
1177 | # tracer: function | 1192 | # tracer: function |
1178 | # | 1193 | # |
1179 | # TASK-PID CPU# TIMESTAMP FUNCTION | 1194 | # TASK-PID CPU# TIMESTAMP FUNCTION |
@@ -1184,8 +1199,8 @@ no pid | |||
1184 | yum-updatesd-3111 [003] 1637.254683: lock_hrtimer_base <-hrtimer_try_to_cancel | 1199 | yum-updatesd-3111 [003] 1637.254683: lock_hrtimer_base <-hrtimer_try_to_cancel |
1185 | yum-updatesd-3111 [003] 1637.254685: fget_light <-do_sys_poll | 1200 | yum-updatesd-3111 [003] 1637.254685: fget_light <-do_sys_poll |
1186 | yum-updatesd-3111 [003] 1637.254686: pipe_poll <-do_sys_poll | 1201 | yum-updatesd-3111 [003] 1637.254686: pipe_poll <-do_sys_poll |
1187 | # echo -1 > /debug/tracing/set_ftrace_pid | 1202 | # echo -1 > set_ftrace_pid |
1188 | # cat /debug/tracing/trace |head | 1203 | # cat trace |head |
1189 | # tracer: function | 1204 | # tracer: function |
1190 | # | 1205 | # |
1191 | # TASK-PID CPU# TIMESTAMP FUNCTION | 1206 | # TASK-PID CPU# TIMESTAMP FUNCTION |
@@ -1207,6 +1222,51 @@ something like this simple program: | |||
1207 | #include <fcntl.h> | 1222 | #include <fcntl.h> |
1208 | #include <unistd.h> | 1223 | #include <unistd.h> |
1209 | 1224 | ||
1225 | #define _STR(x) #x | ||
1226 | #define STR(x) _STR(x) | ||
1227 | #define MAX_PATH 256 | ||
1228 | |||
1229 | const char *find_debugfs(void) | ||
1230 | { | ||
1231 | static char debugfs[MAX_PATH+1]; | ||
1232 | static int debugfs_found; | ||
1233 | char type[100]; | ||
1234 | FILE *fp; | ||
1235 | |||
1236 | if (debugfs_found) | ||
1237 | return debugfs; | ||
1238 | |||
1239 | if ((fp = fopen("/proc/mounts","r")) == NULL) { | ||
1240 | perror("/proc/mounts"); | ||
1241 | return NULL; | ||
1242 | } | ||
1243 | |||
1244 | while (fscanf(fp, "%*s %" | ||
1245 | STR(MAX_PATH) | ||
1246 | "s %99s %*s %*d %*d\n", | ||
1247 | debugfs, type) == 2) { | ||
1248 | if (strcmp(type, "debugfs") == 0) | ||
1249 | break; | ||
1250 | } | ||
1251 | fclose(fp); | ||
1252 | |||
1253 | if (strcmp(type, "debugfs") != 0) { | ||
1254 | fprintf(stderr, "debugfs not mounted"); | ||
1255 | return NULL; | ||
1256 | } | ||
1257 | |||
1258 | debugfs_found = 1; | ||
1259 | |||
1260 | return debugfs; | ||
1261 | } | ||
1262 | |||
1263 | const char *tracing_file(const char *file_name) | ||
1264 | { | ||
1265 | static char trace_file[MAX_PATH+1]; | ||
1266 | snprintf(trace_file, MAX_PATH, "%s/%s", find_debugfs(), file_name); | ||
1267 | return trace_file; | ||
1268 | } | ||
1269 | |||
1210 | int main (int argc, char **argv) | 1270 | int main (int argc, char **argv) |
1211 | { | 1271 | { |
1212 | if (argc < 1) | 1272 | if (argc < 1) |
@@ -1217,12 +1277,12 @@ int main (int argc, char **argv) | |||
1217 | char line[64]; | 1277 | char line[64]; |
1218 | int s; | 1278 | int s; |
1219 | 1279 | ||
1220 | ffd = open("/debug/tracing/current_tracer", O_WRONLY); | 1280 | ffd = open(tracing_file("current_tracer"), O_WRONLY); |
1221 | if (ffd < 0) | 1281 | if (ffd < 0) |
1222 | exit(-1); | 1282 | exit(-1); |
1223 | write(ffd, "nop", 3); | 1283 | write(ffd, "nop", 3); |
1224 | 1284 | ||
1225 | fd = open("/debug/tracing/set_ftrace_pid", O_WRONLY); | 1285 | fd = open(tracing_file("set_ftrace_pid"), O_WRONLY); |
1226 | s = sprintf(line, "%d\n", getpid()); | 1286 | s = sprintf(line, "%d\n", getpid()); |
1227 | write(fd, line, s); | 1287 | write(fd, line, s); |
1228 | 1288 | ||
@@ -1374,22 +1434,22 @@ want, depending on your needs. | |||
1374 | tracing_cpu_mask file) or you might sometimes see unordered | 1434 | tracing_cpu_mask file) or you might sometimes see unordered |
1375 | function calls while cpu tracing switch. | 1435 | function calls while cpu tracing switch. |
1376 | 1436 | ||
1377 | hide: echo nofuncgraph-cpu > /debug/tracing/trace_options | 1437 | hide: echo nofuncgraph-cpu > trace_options |
1378 | show: echo funcgraph-cpu > /debug/tracing/trace_options | 1438 | show: echo funcgraph-cpu > trace_options |
1379 | 1439 | ||
1380 | - The duration (function's time of execution) is displayed on | 1440 | - The duration (function's time of execution) is displayed on |
1381 | the closing bracket line of a function or on the same line | 1441 | the closing bracket line of a function or on the same line |
1382 | than the current function in case of a leaf one. It is default | 1442 | than the current function in case of a leaf one. It is default |
1383 | enabled. | 1443 | enabled. |
1384 | 1444 | ||
1385 | hide: echo nofuncgraph-duration > /debug/tracing/trace_options | 1445 | hide: echo nofuncgraph-duration > trace_options |
1386 | show: echo funcgraph-duration > /debug/tracing/trace_options | 1446 | show: echo funcgraph-duration > trace_options |
1387 | 1447 | ||
1388 | - The overhead field precedes the duration field in case of | 1448 | - The overhead field precedes the duration field in case of |
1389 | reached duration thresholds. | 1449 | reached duration thresholds. |
1390 | 1450 | ||
1391 | hide: echo nofuncgraph-overhead > /debug/tracing/trace_options | 1451 | hide: echo nofuncgraph-overhead > trace_options |
1392 | show: echo funcgraph-overhead > /debug/tracing/trace_options | 1452 | show: echo funcgraph-overhead > trace_options |
1393 | depends on: funcgraph-duration | 1453 | depends on: funcgraph-duration |
1394 | 1454 | ||
1395 | ie: | 1455 | ie: |
@@ -1418,8 +1478,8 @@ want, depending on your needs. | |||
1418 | - The task/pid field displays the thread cmdline and pid which | 1478 | - The task/pid field displays the thread cmdline and pid which |
1419 | executed the function. It is default disabled. | 1479 | executed the function. It is default disabled. |
1420 | 1480 | ||
1421 | hide: echo nofuncgraph-proc > /debug/tracing/trace_options | 1481 | hide: echo nofuncgraph-proc > trace_options |
1422 | show: echo funcgraph-proc > /debug/tracing/trace_options | 1482 | show: echo funcgraph-proc > trace_options |
1423 | 1483 | ||
1424 | ie: | 1484 | ie: |
1425 | 1485 | ||
@@ -1442,8 +1502,8 @@ want, depending on your needs. | |||
1442 | system clock since it started. A snapshot of this time is | 1502 | system clock since it started. A snapshot of this time is |
1443 | given on each entry/exit of functions | 1503 | given on each entry/exit of functions |
1444 | 1504 | ||
1445 | hide: echo nofuncgraph-abstime > /debug/tracing/trace_options | 1505 | hide: echo nofuncgraph-abstime > trace_options |
1446 | show: echo funcgraph-abstime > /debug/tracing/trace_options | 1506 | show: echo funcgraph-abstime > trace_options |
1447 | 1507 | ||
1448 | ie: | 1508 | ie: |
1449 | 1509 | ||
@@ -1540,7 +1600,7 @@ listed in: | |||
1540 | 1600 | ||
1541 | available_filter_functions | 1601 | available_filter_functions |
1542 | 1602 | ||
1543 | # cat /debug/tracing/available_filter_functions | 1603 | # cat available_filter_functions |
1544 | put_prev_task_idle | 1604 | put_prev_task_idle |
1545 | kmem_cache_create | 1605 | kmem_cache_create |
1546 | pick_next_task_rt | 1606 | pick_next_task_rt |
@@ -1552,12 +1612,12 @@ mutex_lock | |||
1552 | If I am only interested in sys_nanosleep and hrtimer_interrupt: | 1612 | If I am only interested in sys_nanosleep and hrtimer_interrupt: |
1553 | 1613 | ||
1554 | # echo sys_nanosleep hrtimer_interrupt \ | 1614 | # echo sys_nanosleep hrtimer_interrupt \ |
1555 | > /debug/tracing/set_ftrace_filter | 1615 | > set_ftrace_filter |
1556 | # echo ftrace > /debug/tracing/current_tracer | 1616 | # echo ftrace > current_tracer |
1557 | # echo 1 > /debug/tracing/tracing_enabled | 1617 | # echo 1 > tracing_enabled |
1558 | # usleep 1 | 1618 | # usleep 1 |
1559 | # echo 0 > /debug/tracing/tracing_enabled | 1619 | # echo 0 > tracing_enabled |
1560 | # cat /debug/tracing/trace | 1620 | # cat trace |
1561 | # tracer: ftrace | 1621 | # tracer: ftrace |
1562 | # | 1622 | # |
1563 | # TASK-PID CPU# TIMESTAMP FUNCTION | 1623 | # TASK-PID CPU# TIMESTAMP FUNCTION |
@@ -1568,7 +1628,7 @@ If I am only interested in sys_nanosleep and hrtimer_interrupt: | |||
1568 | 1628 | ||
1569 | To see which functions are being traced, you can cat the file: | 1629 | To see which functions are being traced, you can cat the file: |
1570 | 1630 | ||
1571 | # cat /debug/tracing/set_ftrace_filter | 1631 | # cat set_ftrace_filter |
1572 | hrtimer_interrupt | 1632 | hrtimer_interrupt |
1573 | sys_nanosleep | 1633 | sys_nanosleep |
1574 | 1634 | ||
@@ -1588,7 +1648,7 @@ Note: It is better to use quotes to enclose the wild cards, | |||
1588 | otherwise the shell may expand the parameters into names | 1648 | otherwise the shell may expand the parameters into names |
1589 | of files in the local directory. | 1649 | of files in the local directory. |
1590 | 1650 | ||
1591 | # echo 'hrtimer_*' > /debug/tracing/set_ftrace_filter | 1651 | # echo 'hrtimer_*' > set_ftrace_filter |
1592 | 1652 | ||
1593 | Produces: | 1653 | Produces: |
1594 | 1654 | ||
@@ -1609,7 +1669,7 @@ Produces: | |||
1609 | 1669 | ||
1610 | Notice that we lost the sys_nanosleep. | 1670 | Notice that we lost the sys_nanosleep. |
1611 | 1671 | ||
1612 | # cat /debug/tracing/set_ftrace_filter | 1672 | # cat set_ftrace_filter |
1613 | hrtimer_run_queues | 1673 | hrtimer_run_queues |
1614 | hrtimer_run_pending | 1674 | hrtimer_run_pending |
1615 | hrtimer_init | 1675 | hrtimer_init |
@@ -1635,17 +1695,17 @@ To append to the filters, use '>>' | |||
1635 | To clear out a filter so that all functions will be recorded | 1695 | To clear out a filter so that all functions will be recorded |
1636 | again: | 1696 | again: |
1637 | 1697 | ||
1638 | # echo > /debug/tracing/set_ftrace_filter | 1698 | # echo > set_ftrace_filter |
1639 | # cat /debug/tracing/set_ftrace_filter | 1699 | # cat set_ftrace_filter |
1640 | # | 1700 | # |
1641 | 1701 | ||
1642 | Again, now we want to append. | 1702 | Again, now we want to append. |
1643 | 1703 | ||
1644 | # echo sys_nanosleep > /debug/tracing/set_ftrace_filter | 1704 | # echo sys_nanosleep > set_ftrace_filter |
1645 | # cat /debug/tracing/set_ftrace_filter | 1705 | # cat set_ftrace_filter |
1646 | sys_nanosleep | 1706 | sys_nanosleep |
1647 | # echo 'hrtimer_*' >> /debug/tracing/set_ftrace_filter | 1707 | # echo 'hrtimer_*' >> set_ftrace_filter |
1648 | # cat /debug/tracing/set_ftrace_filter | 1708 | # cat set_ftrace_filter |
1649 | hrtimer_run_queues | 1709 | hrtimer_run_queues |
1650 | hrtimer_run_pending | 1710 | hrtimer_run_pending |
1651 | hrtimer_init | 1711 | hrtimer_init |
@@ -1668,7 +1728,7 @@ hrtimer_init_sleeper | |||
1668 | The set_ftrace_notrace prevents those functions from being | 1728 | The set_ftrace_notrace prevents those functions from being |
1669 | traced. | 1729 | traced. |
1670 | 1730 | ||
1671 | # echo '*preempt*' '*lock*' > /debug/tracing/set_ftrace_notrace | 1731 | # echo '*preempt*' '*lock*' > set_ftrace_notrace |
1672 | 1732 | ||
1673 | Produces: | 1733 | Produces: |
1674 | 1734 | ||
@@ -1758,13 +1818,13 @@ the effect on the tracing is different. Every read from | |||
1758 | trace_pipe is consumed. This means that subsequent reads will be | 1818 | trace_pipe is consumed. This means that subsequent reads will be |
1759 | different. The trace is live. | 1819 | different. The trace is live. |
1760 | 1820 | ||
1761 | # echo function > /debug/tracing/current_tracer | 1821 | # echo function > current_tracer |
1762 | # cat /debug/tracing/trace_pipe > /tmp/trace.out & | 1822 | # cat trace_pipe > /tmp/trace.out & |
1763 | [1] 4153 | 1823 | [1] 4153 |
1764 | # echo 1 > /debug/tracing/tracing_enabled | 1824 | # echo 1 > tracing_enabled |
1765 | # usleep 1 | 1825 | # usleep 1 |
1766 | # echo 0 > /debug/tracing/tracing_enabled | 1826 | # echo 0 > tracing_enabled |
1767 | # cat /debug/tracing/trace | 1827 | # cat trace |
1768 | # tracer: function | 1828 | # tracer: function |
1769 | # | 1829 | # |
1770 | # TASK-PID CPU# TIMESTAMP FUNCTION | 1830 | # TASK-PID CPU# TIMESTAMP FUNCTION |
@@ -1800,7 +1860,7 @@ number listed is the number of entries that can be recorded per | |||
1800 | CPU. To know the full size, multiply the number of possible CPUS | 1860 | CPU. To know the full size, multiply the number of possible CPUS |
1801 | with the number of entries. | 1861 | with the number of entries. |
1802 | 1862 | ||
1803 | # cat /debug/tracing/buffer_size_kb | 1863 | # cat buffer_size_kb |
1804 | 1408 (units kilobytes) | 1864 | 1408 (units kilobytes) |
1805 | 1865 | ||
1806 | Note, to modify this, you must have tracing completely disabled. | 1866 | Note, to modify this, you must have tracing completely disabled. |
@@ -1808,21 +1868,21 @@ To do that, echo "nop" into the current_tracer. If the | |||
1808 | current_tracer is not set to "nop", an EINVAL error will be | 1868 | current_tracer is not set to "nop", an EINVAL error will be |
1809 | returned. | 1869 | returned. |
1810 | 1870 | ||
1811 | # echo nop > /debug/tracing/current_tracer | 1871 | # echo nop > current_tracer |
1812 | # echo 10000 > /debug/tracing/buffer_size_kb | 1872 | # echo 10000 > buffer_size_kb |
1813 | # cat /debug/tracing/buffer_size_kb | 1873 | # cat buffer_size_kb |
1814 | 10000 (units kilobytes) | 1874 | 10000 (units kilobytes) |
1815 | 1875 | ||
1816 | The number of pages which will be allocated is limited to a | 1876 | The number of pages which will be allocated is limited to a |
1817 | percentage of available memory. Allocating too much will produce | 1877 | percentage of available memory. Allocating too much will produce |
1818 | an error. | 1878 | an error. |
1819 | 1879 | ||
1820 | # echo 1000000000000 > /debug/tracing/buffer_size_kb | 1880 | # echo 1000000000000 > buffer_size_kb |
1821 | -bash: echo: write error: Cannot allocate memory | 1881 | -bash: echo: write error: Cannot allocate memory |
1822 | # cat /debug/tracing/buffer_size_kb | 1882 | # cat buffer_size_kb |
1823 | 85 | 1883 | 85 |
1824 | 1884 | ||
1825 | ----------- | 1885 | ----------- |
1826 | 1886 | ||
1827 | More details can be found in the source code, in the | 1887 | More details can be found in the source code, in the |
1828 | kernel/tracing/*.c files. | 1888 | kernel/trace/*.c files. |