···247247- Support the TIF_SYSCALL_TRACEPOINT thread flags.248248- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace249249 in the ptrace syscalls tracing path.250250+- If the system call table on this arch is more complicated than a simple array251251+ of addresses of the system calls, implement an arch_syscall_addr to return252252+ the address of a given system call.253253+- If the symbol names of the system calls do not match the function names on254254+ this arch, define ARCH_HAS_SYSCALL_MATCH_SYM_NAME in asm/ftrace.h and255255+ implement arch_syscall_match_sym_name with the appropriate logic to return256256+ true if the function name corresponds with the symbol name.250257- Tag this arch as HAVE_SYSCALL_TRACEPOINTS.251258252259
+19-129
Documentation/trace/ftrace.txt
···8080 tracers listed here can be configured by8181 echoing their name into current_tracer.82828383- tracing_enabled:8383+ tracing_on:84848585- This sets or displays whether the current_tracer8686- is activated and tracing or not. Echo 0 into this8787- file to disable the tracer or 1 to enable it.8585+ This sets or displays whether writing to the trace8686+ ring buffer is enabled. Echo 0 into this file to disable8787+ the tracer or 1 to enable it.88888989 trace:9090···202202 to draw a graph of function calls similar to C code203203 source.204204205205- "sched_switch"206206-207207- Traces the context switches and wakeups between tasks.208208-209205 "irqsoff"210206211207 Traces the areas that disable interrupts and saves···268272format, the function name that was traced "path_put" and the269273parent function that called this function "path_walk". The270274timestamp is the time at which the function was entered.271271-272272-The sched_switch tracer also includes tracing of task wakeups273273-and context switches.274274-275275- ksoftirqd/1-7 [01] 1453.070013: 7:115:R + 2916:115:S276276- ksoftirqd/1-7 [01] 1453.070013: 7:115:R + 10:115:S277277- ksoftirqd/1-7 [01] 1453.070013: 7:115:R ==> 10:115:R278278- events/1-10 [01] 1453.070013: 10:115:S ==> 2916:115:R279279- kondemand/1-2916 [01] 1453.070013: 2916:115:S ==> 7:115:R280280- ksoftirqd/1-7 [01] 1453.070013: 7:115:S ==> 0:140:R281281-282282-Wake ups are represented by a "+" and the context switches are283283-shown as "==>". The format is:284284-285285- Context switches:286286-287287- Previous task Next Task288288-289289- <pid>:<prio>:<state> ==> <pid>:<prio>:<state>290290-291291- Wake ups:292292-293293- Current task Task waking up294294-295295- <pid>:<prio>:<state> + <pid>:<prio>:<state>296296-297297-The prio is the internal kernel priority, which is the inverse298298-of the priority that is usually displayed by user-space tools.299299-Zero represents the highest priority (99). Prio 100 starts the300300-"nice" priorities with 100 being equal to nice -20 and 139 being301301-nice 19. The prio "140" is reserved for the idle task which is302302-the lowest priority thread (pid 0).303303-304275305276Latency trace format306277--------------------···454491 latencies, as described in "Latency455492 trace format".456493457457-sched_switch458458-------------459459-460460-This tracer simply records schedule switches. Here is an example461461-of how to use it.462462-463463- # echo sched_switch > current_tracer464464- # echo 1 > tracing_enabled465465- # sleep 1466466- # echo 0 > tracing_enabled467467- # cat trace468468-469469-# tracer: sched_switch470470-#471471-# TASK-PID CPU# TIMESTAMP FUNCTION472472-# | | | | |473473- bash-3997 [01] 240.132281: 3997:120:R + 4055:120:R474474- bash-3997 [01] 240.132284: 3997:120:R ==> 4055:120:R475475- sleep-4055 [01] 240.132371: 4055:120:S ==> 3997:120:R476476- bash-3997 [01] 240.132454: 3997:120:R + 4055:120:S477477- bash-3997 [01] 240.132457: 3997:120:R ==> 4055:120:R478478- sleep-4055 [01] 240.132460: 4055:120:D ==> 3997:120:R479479- bash-3997 [01] 240.132463: 3997:120:R + 4055:120:D480480- bash-3997 [01] 240.132465: 3997:120:R ==> 4055:120:R481481- <idle>-0 [00] 240.132589: 0:140:R + 4:115:S482482- <idle>-0 [00] 240.132591: 0:140:R ==> 4:115:R483483- ksoftirqd/0-4 [00] 240.132595: 4:115:S ==> 0:140:R484484- <idle>-0 [00] 240.132598: 0:140:R + 4:115:S485485- <idle>-0 [00] 240.132599: 0:140:R ==> 4:115:R486486- ksoftirqd/0-4 [00] 240.132603: 4:115:S ==> 0:140:R487487- sleep-4055 [01] 240.133058: 4055:120:S ==> 3997:120:R488488- [...]489489-490490-491491-As we have discussed previously about this format, the header492492-shows the name of the trace and points to the options. The493493-"FUNCTION" is a misnomer since here it represents the wake ups494494-and context switches.495495-496496-The sched_switch file only lists the wake ups (represented with497497-'+') and context switches ('==>') with the previous task or498498-current task first followed by the next task or task waking up.499499-The format for both of these is PID:KERNEL-PRIO:TASK-STATE.500500-Remember that the KERNEL-PRIO is the inverse of the actual501501-priority with zero (0) being the highest priority and the nice502502-values starting at 100 (nice -20). Below is a quick chart to map503503-the kernel priority to user land priorities.504504-505505- Kernel Space User Space506506- ===============================================================507507- 0(high) to 98(low) user RT priority 99(high) to 1(low)508508- with SCHED_RR or SCHED_FIFO509509- ---------------------------------------------------------------510510- 99 sched_priority is not used in scheduling511511- decisions(it must be specified as 0)512512- ---------------------------------------------------------------513513- 100(high) to 139(low) user nice -20(high) to 19(low)514514- ---------------------------------------------------------------515515- 140 idle task priority516516- ---------------------------------------------------------------517517-518518-The task states are:519519-520520- R - running : wants to run, may not actually be running521521- S - sleep : process is waiting to be woken up (handles signals)522522- D - disk sleep (uninterruptible sleep) : process must be woken up523523- (ignores signals)524524- T - stopped : process suspended525525- t - traced : process is being traced (with something like gdb)526526- Z - zombie : process waiting to be cleaned up527527- X - unknown528528-529529-530494ftrace_enabled531495--------------532496···497607 # echo irqsoff > current_tracer498608 # echo latency-format > trace_options499609 # echo 0 > tracing_max_latency500500- # echo 1 > tracing_enabled610610+ # echo 1 > tracing_on501611 # ls -ltr502612 [...]503503- # echo 0 > tracing_enabled613613+ # echo 0 > tracing_on504614 # cat trace505615# tracer: irqsoff506616#···605715 # echo preemptoff > current_tracer606716 # echo latency-format > trace_options607717 # echo 0 > tracing_max_latency608608- # echo 1 > tracing_enabled718718+ # echo 1 > tracing_on609719 # ls -ltr610720 [...]611611- # echo 0 > tracing_enabled721721+ # echo 0 > tracing_on612722 # cat trace613723# tracer: preemptoff614724#···753863 # echo preemptirqsoff > current_tracer754864 # echo latency-format > trace_options755865 # echo 0 > tracing_max_latency756756- # echo 1 > tracing_enabled866866+ # echo 1 > tracing_on757867 # ls -ltr758868 [...]759759- # echo 0 > tracing_enabled869869+ # echo 0 > tracing_on760870 # cat trace761871# tracer: preemptirqsoff762872#···9161026 # echo wakeup > current_tracer9171027 # echo latency-format > trace_options9181028 # echo 0 > tracing_max_latency919919- # echo 1 > tracing_enabled10291029+ # echo 1 > tracing_on9201030 # chrt -f 5 sleep 1921921- # echo 0 > tracing_enabled10311031+ # echo 0 > tracing_on9221032 # cat trace9231033# tracer: wakeup9241034#···1030114010311141 # sysctl kernel.ftrace_enabled=110321142 # echo function > current_tracer10331033- # echo 1 > tracing_enabled11431143+ # echo 1 > tracing_on10341144 # usleep 110351035- # echo 0 > tracing_enabled11451145+ # echo 0 > tracing_on10361146 # cat trace10371147# tracer: function10381148#···10701180[...]10711181int main(int argc, char *argv[]) {10721182 [...]10731073- trace_fd = open(tracing_file("tracing_enabled"), O_WRONLY);11831183+ trace_fd = open(tracing_file("tracing_on"), O_WRONLY);10741184 [...]10751185 if (condition_hit()) {10761186 write(trace_fd, "0", 1);···15211631 # echo sys_nanosleep hrtimer_interrupt \15221632 > set_ftrace_filter15231633 # echo function > current_tracer15241524- # echo 1 > tracing_enabled16341634+ # echo 1 > tracing_on15251635 # usleep 115261526- # echo 0 > tracing_enabled16361636+ # echo 0 > tracing_on15271637 # cat trace15281638# tracer: ftrace15291639#···17691879 # echo function > current_tracer17701880 # cat trace_pipe > /tmp/trace.out &17711881[1] 415317721772- # echo 1 > tracing_enabled18821882+ # echo 1 > tracing_on17731883 # usleep 117741774- # echo 0 > tracing_enabled18841884+ # echo 0 > tracing_on17751885 # cat trace17761886# tracer: function17771887#
···21632163 delta = diff;21642164 if (unlikely(test_time_stamp(delta))) {21652165 WARN_ONCE(delta > (1ULL << 59),21662166- KERN_WARNING "Delta way too big! %llu ts=%llu write stamp = %llu\n",21662166+ KERN_WARNING "Delta way too big! %llu ts=%llu write stamp = %llu\n%s",21672167 (unsigned long long)delta,21682168 (unsigned long long)ts,21692169- (unsigned long long)cpu_buffer->write_stamp);21692169+ (unsigned long long)cpu_buffer->write_stamp,21702170+ sched_clock_stable ? "" :21712171+ "If you just came from a suspend/resume,\n"21722172+ "please switch to the trace global clock:\n"21732173+ " echo global > /sys/kernel/debug/tracing/trace_clock\n");21702174 add_timestamp = 1;21712175 }21722176 }
+4
kernel/trace/trace.c
···2710271027112711 mutex_lock(&trace_types_lock);27122712 if (tracer_enabled ^ val) {27132713+27142714+ /* Only need to warn if this is used to change the state */27152715+ WARN_ONCE(1, "tracing_enabled is deprecated. Use tracing_on");27162716+27132717 if (val) {27142718 tracer_enabled = 1;27152719 if (current_trace->start)
···60606161static struct syscall_metadata **syscalls_metadata;62626363+#ifndef ARCH_HAS_SYSCALL_MATCH_SYM_NAME6464+static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)6565+{6666+ /*6767+ * Only compare after the "sys" prefix. Archs that use6868+ * syscall wrappers may have syscalls symbols aliases prefixed6969+ * with "SyS" instead of "sys", leading to an unwanted7070+ * mismatch.7171+ */7272+ return !strcmp(sym + 3, name + 3);7373+}7474+#endif7575+6376static __init struct syscall_metadata *6477find_syscall_meta(unsigned long syscall)6578{···8572 stop = __stop_syscalls_metadata;8673 kallsyms_lookup(syscall, NULL, NULL, NULL, str);87747575+ if (arch_syscall_match_sym_name(str, "sys_ni_syscall"))7676+ return NULL;7777+8878 for ( ; start < stop; start++) {8989- /*9090- * Only compare after the "sys" prefix. Archs that use9191- * syscall wrappers may have syscalls symbols aliases prefixed9292- * with "SyS" instead of "sys", leading to an unwanted9393- * mismatch.9494- */9595- if ((*start)->name && !strcmp((*start)->name + 3, str + 3))7979+ if ((*start)->name && arch_syscall_match_sym_name(str, (*start)->name))9680 return *start;9781 }9882 return NULL;···369359 int num;370360371361 num = ((struct syscall_metadata *)call->data)->syscall_nr;372372- if (num < 0 || num >= NR_syscalls)362362+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))373363 return -ENOSYS;374364 mutex_lock(&syscall_trace_lock);375365 if (!sys_refcount_enter)···387377 int num;388378389379 num = ((struct syscall_metadata *)call->data)->syscall_nr;390390- if (num < 0 || num >= NR_syscalls)380380+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))391381 return;392382 mutex_lock(&syscall_trace_lock);393383 sys_refcount_enter--;···403393 int num;404394405395 num = ((struct syscall_metadata *)call->data)->syscall_nr;406406- if (num < 0 || num >= NR_syscalls)396396+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))407397 return -ENOSYS;408398 mutex_lock(&syscall_trace_lock);409399 if (!sys_refcount_exit)···421411 int num;422412423413 num = ((struct syscall_metadata *)call->data)->syscall_nr;424424- if (num < 0 || num >= NR_syscalls)414414+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))425415 return;426416 mutex_lock(&syscall_trace_lock);427417 sys_refcount_exit--;···434424int init_syscall_trace(struct ftrace_event_call *call)435425{436426 int id;427427+ int num;428428+429429+ num = ((struct syscall_metadata *)call->data)->syscall_nr;430430+ if (num < 0 || num >= NR_syscalls) {431431+ pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",432432+ ((struct syscall_metadata *)call->data)->name);433433+ return -ENOSYS;434434+ }437435438436 if (set_syscall_print_fmt(call) < 0)439437 return -ENOMEM;···456438 return id;457439}458440459459-unsigned long __init arch_syscall_addr(int nr)441441+unsigned long __init __weak arch_syscall_addr(int nr)460442{461443 return (unsigned long)sys_call_table[nr];462444}
+1-1
scripts/kconfig/streamline_config.pl
···11#!/usr/bin/perl -w22#33-# Copywrite 2005-2009 - Steven Rostedt33+# Copyright 2005-2009 - Steven Rostedt44# Licensed under the terms of the GNU GPL License version 255#66# It's simple enough to figure out how this works.
+1-1
tools/testing/ktest/ktest.pl
···11#!/usr/bin/perl -w22#33-# Copywrite 2010 - Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.33+# Copyright 2010 - Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.44# Licensed under the terms of the GNU GPL License version 255#66