tracing: Updates for 6.3
Subsystems (4)
Steven Rostedt
maintainercover tracing: Updates for 6.3
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/for-next
Head SHA1: 9c1c251d670bc107b9ce600a2c20adb08b4849e9
Arnd Bergmann (1):
ftrace: sample: avoid open-coded 64-bit division
Bagas Sanjaya (1):
tracing/histogram: Wrap remaining shell snippets in code blocks
Davidlohr Bueso (1):
tracing/osnoise: No need for schedule_hrtimeout range
Linyu Yuan (1):
tracing: Acquire buffer from temparary trace sequence
Song Shuai (1):
samples: ftrace: Include the nospec-branch.h only for x86
Steven Rostedt (Google) (5):
tracing: Fix trace_event_raw_event_synth() if else statement
tracing: Add creation of instances at boot command line
tracing: Add enabling of events to boot instances
tracing: Add trace_array_puts() to write into instance
tracing: Allow boot instances to have snapshot buffers
Tom Rix (1):
samples: ftrace: Make some global variables static
----
Documentation/admin-guide/kernel-parameters.txt | 29 +++++ Documentation/trace/histogram.rst | 93 +++++++------- include/linux/trace.h | 12 ++ include/linux/trace_seq.h | 5 + include/trace/stages/stage3_trace_output.h | 3 + include/trace/stages/stage7_class_define.h | 1 + kernel/trace/trace.c | 160 +++++++++++++++++++++--- kernel/trace/trace.h | 2 + kernel/trace/trace_events.c | 9 +- kernel/trace/trace_events_synth.c | 4 +- kernel/trace/trace_osnoise.c | 2 +- kernel/trace/trace_seq.c | 23 ++++ samples/ftrace/ftrace-direct-modify.c | 2 +- samples/ftrace/ftrace-direct-multi-modify.c | 2 +- samples/ftrace/ftrace-direct-multi.c | 2 +- samples/ftrace/ftrace-direct-too.c | 2 +- samples/ftrace/ftrace-direct.c | 2 +- samples/ftrace/ftrace-ops.c | 26 ++-- 18 files changed, 290 insertions(+), 89 deletions(-)
Steven Rostedt
maintainerPATCH 1/11 tracing/osnoise: No need for schedule_hrtimeout range
From: Davidlohr Bueso <[email protected]>
No slack time is being passed, just use schedule_hrtimeout().
--- kernel/trace/trace_osnoise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_osnoise.c +1 -1
@@ -1539,7 +1539,7 @@ static void osnoise_sleep(void) wake_time =ktime_add_us (ktime_get (), interval);__set_current_state (TASK_INTERRUPTIBLE ); -while (schedule_hrtimeout_range (&wake_time,0 ,HRTIMER_MODE_ABS )) { +while (schedule_hrtimeout (&wake_time,HRTIMER_MODE_ABS )) {if (kthread_should_stop ())break ; }
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 2/11 tracing/histogram: Wrap remaining shell snippets in code blocks
In reply to Steven RostedtFrom: Bagas Sanjaya <[email protected]>
Most shell command snippets (echo/cat) and their output are already in literal code blocks. However a few still isn't wrapped, in which the htmldocs output is ugly.
Wrap the remaining unwrapped snippets, while also fix recent kernel test robot warnings.
--- Documentation/trace/histogram.rst | 93 ++++++++++++++++--------------- 1 file changed, 47 insertions(+), 46 deletions(-)
Documentation/trace/histogram.rst +47 -46
@@ -1864,7 +1864,7 @@ A histogram can now be defined for the new synthetic event:: The above shows the latency "lat" in a power of 2 grouping. Like any other event, once a histogram is enabled for the event, the -output can be displayed by reading the event's 'hist' file. +output can be displayed by reading the event's 'hist' file:: # cat /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/hist
@@ -1911,7 +1911,7 @@ output can be displayed by reading the event's 'hist' file. The latency values can also be grouped linearly by a given size with -the ".buckets" modifier and specify a size (in this case groups of 10). +the ".buckets" modifier and specify a size (in this case groups of 10):: # echo 'hist:keys=pid,prio,lat.buckets=10:sort=lat' >> \ /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger
@@ -1945,7 +1945,7 @@ the ".buckets" modifier and specify a size (in this case groups of 10). To save stacktraces, create a synthetic event with a field of type "unsigned long[]" or even just "long[]". For example, to see how long a task is blocked in an -uninterruptible state: +uninterruptible state:: # cd /sys/kernel/tracing # echo 's:block_lat pid_t pid; u64 delta; unsigned long[] stack;' > dynamic_events
@@ -1990,7 +1990,8 @@ uninterruptible state: => kthread+0xe9/0x110 => ret_from_fork+0x2c/0x50 -A synthetic event that has a stacktrace field may use it as a key in histogram: +A synthetic event that has a stacktrace field may use it as a key in +histogram:: # echo 'hist:delta.buckets=100,stack.stacktrace:sort=delta' > events/synthetic/block_lat/trigger # cat events/synthetic/block_lat/hist
@@ -2183,11 +2184,11 @@ The following commonly-used handler.action pairs are available: wakeup_new_test($testpid) if comm=="cyclictest"' >> \ /sys/kernel/debug/tracing/events/sched/sched_wakeup_new/trigger - Or, equivalently, using the 'trace' keyword syntax: + Or, equivalently, using the 'trace' keyword syntax:: - # echo 'hist:keys=$testpid:testpid=pid:onmatch(sched.sched_wakeup_new).\ - trace(wakeup_new_test,$testpid) if comm=="cyclictest"' >> \ - /sys/kernel/debug/tracing/events/sched/sched_wakeup_new/trigger + # echo 'hist:keys=$testpid:testpid=pid:onmatch(sched.sched_wakeup_new).\ + trace(wakeup_new_test,$testpid) if comm=="cyclictest"' >> \ + /sys/kernel/debug/tracing/events/sched/sched_wakeup_new/trigger Creating and displaying a histogram based on those events is now just a matter of using the fields and new synthetic event in the
@@ -2320,48 +2321,48 @@ The following commonly-used handler.action pairs are available: resulting latency, stored in wakeup_lat, exceeds the current maximum latency, a snapshot is taken. As part of the setup, all the scheduler events are also enabled, which are the events that - will show up in the snapshot when it is taken at some point: + will show up in the snapshot when it is taken at some point:: - # echo 1 > /sys/kernel/debug/tracing/events/sched/enable + # echo 1 > /sys/kernel/debug/tracing/events/sched/enable - # echo 'hist:keys=pid:ts0=common_timestamp.usecs \ - if comm=="cyclictest"' >> \ - /sys/kernel/debug/tracing/events/sched/sched_waking/trigger + # echo 'hist:keys=pid:ts0=common_timestamp.usecs \ + if comm=="cyclictest"' >> \ + /sys/kernel/debug/tracing/events/sched/sched_waking/trigger - # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0: \ - onmax($wakeup_lat).save(next_prio,next_comm,prev_pid,prev_prio, \ - prev_comm):onmax($wakeup_lat).snapshot() \ - if next_comm=="cyclictest"' >> \ - /sys/kernel/debug/tracing/events/sched/sched_switch/trigger + # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0: \ + onmax($wakeup_lat).save(next_prio,next_comm,prev_pid,prev_prio, \ + prev_comm):onmax($wakeup_lat).snapshot() \ + if next_comm=="cyclictest"' >> \ + /sys/kernel/debug/tracing/events/sched/sched_switch/trigger When the histogram is displayed, for each bucket the max value and the saved values corresponding to the max are displayed following the rest of the fields. If a snapshot was taken, there is also a message indicating that, - along with the value and event that triggered the global maximum: + along with the value and event that triggered the global maximum:: - # cat /sys/kernel/debug/tracing/events/sched/sched_switch/hist - { next_pid: 2101 } hitcount: 200 - max: 52 next_prio: 120 next_comm: cyclictest \ - prev_pid: 0 prev_prio: 120 prev_comm: swapper/6 + # cat /sys/kernel/debug/tracing/events/sched/sched_switch/hist + { next_pid: 2101 } hitcount: 200 + max: 52 next_prio: 120 next_comm: cyclictest \ + prev_pid: 0 prev_prio: 120 prev_comm: swapper/6 - { next_pid: 2103 } hitcount: 1326 - max: 572 next_prio: 19 next_comm: cyclictest \ - prev_pid: 0 prev_prio: 120 prev_comm: swapper/1 + { next_pid: 2103 } hitcount: 1326 + max: 572 next_prio: 19 next_comm: cyclictest \ + prev_pid: 0 prev_prio: 120 prev_comm: swapper/1 - { next_pid: 2102 } hitcount: 1982 \ - max: 74 next_prio: 19 next_comm: cyclictest \ - prev_pid: 0 prev_prio: 120 prev_comm: swapper/5 + { next_pid: 2102 } hitcount: 1982 \ + max: 74 next_prio: 19 next_comm: cyclictest \ + prev_pid: 0 prev_prio: 120 prev_comm: swapper/5 - Snapshot taken (see tracing/snapshot). Details: - triggering value { onmax($wakeup_lat) }: 572 \ - triggered by event with key: { next_pid: 2103 } + Snapshot taken (see tracing/snapshot). Details: + triggering value { onmax($wakeup_lat) }: 572 \ + triggered by event with key: { next_pid: 2103 } - Totals: - Hits: 3508 - Entries: 3 - Dropped: 0 + Totals: + Hits: 3508 + Entries: 3 + Dropped: 0 In the above case, the event that triggered the global maximum has the key with next_pid == 2103. If you look at the bucket that has
@@ -2439,15 +2440,15 @@ The following commonly-used handler.action pairs are available: $cwnd variable. If the value has changed, a snapshot is taken. As part of the setup, all the scheduler and tcp events are also enabled, which are the events that will show up in the snapshot - when it is taken at some point: + when it is taken at some point:: - # echo 1 > /sys/kernel/debug/tracing/events/sched/enable - # echo 1 > /sys/kernel/debug/tracing/events/tcp/enable + # echo 1 > /sys/kernel/debug/tracing/events/sched/enable + # echo 1 > /sys/kernel/debug/tracing/events/tcp/enable - # echo 'hist:keys=dport:cwnd=snd_cwnd: \ - onchange($cwnd).save(snd_wnd,srtt,rcv_wnd): \ - onchange($cwnd).snapshot()' >> \ - /sys/kernel/debug/tracing/events/tcp/tcp_probe/trigger + # echo 'hist:keys=dport:cwnd=snd_cwnd: \ + onchange($cwnd).save(snd_wnd,srtt,rcv_wnd): \ + onchange($cwnd).snapshot()' >> \ + /sys/kernel/debug/tracing/events/tcp/tcp_probe/trigger When the histogram is displayed, for each bucket the tracked value and the saved values corresponding to that value are displayed
@@ -2470,10 +2471,10 @@ The following commonly-used handler.action pairs are available: { dport: 443 } hitcount: 211 changed: 10 snd_wnd: 26960 srtt: 17379 rcv_wnd: 28800 - Snapshot taken (see tracing/snapshot). Details:: + Snapshot taken (see tracing/snapshot). Details: - triggering value { onchange($cwnd) }: 10 - triggered by event with key: { dport: 80 } + triggering value { onchange($cwnd) }: 10 + triggered by event with key: { dport: 80 } Totals: Hits: 414
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 3/11 tracing: Acquire buffer from temparary trace sequence
In reply to Steven RostedtFrom: Linyu Yuan <[email protected]>
there is one dwc3 trace event declare as below,
DECLARE_EVENT_CLASS(dwc3_log_event,
TP_PROTO(u32 event, struct dwc3 *dwc),
TP_ARGS(event, dwc),
TP_STRUCT__entry(
__field(u32, event)
__field(u32, ep0state)
__dynamic_array(char, str, DWC3_MSG_MAX)
),
TP_fast_assign(
__entry->event = event;
__entry->ep0state = dwc->ep0state;
),
TP_printk("event (%08x): %s", __entry->event,
dwc3_decode_event(__get_str(str), DWC3_MSG_MAX,
__entry->event, __entry->ep0state)));
the problem is when trace function called, it will allocate up to DWC3_MSG_MAX bytes from trace event buffer, but never fill the buffer during fast assignment, it only fill the buffer when output function are called, so this means if output function are not called, the buffer will never used.
add __get_buf(len) which acquiree buffer from iter->tmp_seq when trace output function called, it allow user write string to acquired buffer.
the mentioned dwc3 trace event will changed as below, DECLARE_EVENT_CLASS(dwc3_log_event,
TP_PROTO(u32 event, struct dwc3 *dwc),
TP_ARGS(event, dwc),
TP_STRUCT__entry(
__field(u32, event)
__field(u32, ep0state)
),
TP_fast_assign(
__entry->event = event;
__entry->ep0state = dwc->ep0state;
),
TP_printk("event (%08x): %s", __entry->event,
dwc3_decode_event(__get_buf(DWC3_MSG_MAX), DWC3_MSG_MAX,
__entry->event, __entry->ep0state)));.
--- include/linux/trace_seq.h | 5 +++++ include/trace/stages/stage3_trace_output.h | 3 +++ include/trace/stages/stage7_class_define.h | 1 + kernel/trace/trace_seq.c | 23 ++++++++++++++++++++++ 4 files changed, 32 insertions(+)
include/linux/trace_seq.h +5 -0
@@ -95,6 +95,7 @@ extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,extern int trace_seq_hex_dump (struct trace_seq *s,const char *prefix_str,int prefix_type,int rowsize,int groupsize,const void *buf,size_t len,bool ascii); +char *trace_seq_acquire (struct trace_seq *s,unsigned int len);#else /* CONFIG_TRACING */ static inline __printf(2, 3)
@@ -139,6 +140,10 @@ static inline int trace_seq_path(struct trace_seq *s, const struct path *path) {return 0 ; } +static inline char *trace_seq_acquire (struct trace_seq *s,unsigned int len) +{ +return NULL ; +}#endif /* CONFIG_TRACING */ #endif /* _LINUX_TRACE_SEQ_H */
include/trace/stages/stage3_trace_output.h +3 -0
@@ -139,3 +139,6 @@u64 ____val = (u64)(value); \ (u32 )do_div (____val,NSEC_PER_SEC ); \ }) + +#undef __get_buf +#define __get_buf (len) trace_seq_acquire(p, (len))
include/trace/stages/stage7_class_define.h +1 -0
@@ -23,6 +23,7 @@#undef __get_rel_sockaddr#undef __print_array#undef __print_hex_dump +#undef __get_buf/* * The below is not executed in the kernel. It is only what is
kernel/trace/trace_seq.c +23 -0
@@ -403,3 +403,26 @@ int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str,return 1 ; }EXPORT_SYMBOL (trace_seq_hex_dump); + +/* +* trace_seq_acquire - acquire seq buffer with size len +* @s: trace sequence descriptor +* @len: size of buffer to be acquired +* +* acquire buffer with size of @len from trace_seq for output usage, +* user can fill string into that buffer. +* +* Returns start address of acquired buffer. +* +* it allow multiple usage in one trace output function call. +*/ +char *trace_seq_acquire (struct trace_seq *s,unsigned int len) +{ +char *ret =trace_seq_buffer_ptr (s); + +if (!WARN_ON_ONCE (seq_buf_buffer_left (&s->seq) < len)) +seq_buf_commit (&s->seq, len); + +return ret; +} +EXPORT_SYMBOL (trace_seq_acquire);
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 4/11 samples: ftrace: Include the nospec-branch.h only for x86
In reply to Steven RostedtFrom: Song Shuai <[email protected]>
When other architectures without the nospec functionality write their direct-call functions of samples/ftrace/*.c, the including of asm/nospec-branch.h must be taken care to fix the no header file found error in building process.
This commit (ee3e2469b346 "x86/ftrace: Make it call depth tracking aware") file-globally includes asm/nospec-branch.h providing CALL_DEPTH_ACCOUNT for only x86 direct-call functions.
It seems better to move the including to #ifdef CONFIG_X86_64.
--- samples/ftrace/ftrace-direct-modify.c | 2 +- samples/ftrace/ftrace-direct-multi-modify.c | 2 +- samples/ftrace/ftrace-direct-multi.c | 2 +- samples/ftrace/ftrace-direct-too.c | 2 +- samples/ftrace/ftrace-direct.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
samples/ftrace/ftrace-direct-modify.c +1 -1
@@ -3,7 +3,6 @@#include <linux/kthread.h> #include <linux/ftrace.h> #include <asm/asm-offsets.h> -#include <asm/nospec-branch.h> extern void my_direct_func1 (void );extern void my_direct_func2 (void );
@@ -26,6 +25,7 @@ static unsigned long my_ip = (unsigned long)schedule;#ifdef CONFIG_X86_64 #include <asm/ibt.h> +#include <asm/nospec-branch.h> asm ( " .pushsection .text, \"ax\", @progbits\n"
samples/ftrace/ftrace-direct-multi-modify.c +1 -1
@@ -3,7 +3,6 @@#include <linux/kthread.h> #include <linux/ftrace.h> #include <asm/asm-offsets.h> -#include <asm/nospec-branch.h> extern void my_direct_func1 (unsigned long ip);extern void my_direct_func2 (unsigned long ip);
@@ -24,6 +23,7 @@ extern void my_tramp2(void *);#ifdef CONFIG_X86_64 #include <asm/ibt.h> +#include <asm/nospec-branch.h> asm ( " .pushsection .text, \"ax\", @progbits\n"
samples/ftrace/ftrace-direct-multi.c +1 -1
@@ -5,7 +5,6 @@#include <linux/ftrace.h> #include <linux/sched/stat.h> #include <asm/asm-offsets.h> -#include <asm/nospec-branch.h> extern void my_direct_func (unsigned long ip);
@@ -19,6 +18,7 @@ extern void my_tramp(void *);#ifdef CONFIG_X86_64 #include <asm/ibt.h> +#include <asm/nospec-branch.h> asm ( " .pushsection .text, \"ax\", @progbits\n"
samples/ftrace/ftrace-direct-too.c +1 -1
@@ -4,7 +4,6 @@#include <linux/mm.h> /* for handle_mm_fault() */ #include <linux/ftrace.h> #include <asm/asm-offsets.h> -#include <asm/nospec-branch.h> extern void my_direct_func (struct vm_area_struct *vma,unsigned long address,unsigned int flags);
@@ -21,6 +20,7 @@ extern void my_tramp(void *);#ifdef CONFIG_X86_64 #include <asm/ibt.h> +#include <asm/nospec-branch.h> asm ( " .pushsection .text, \"ax\", @progbits\n"
samples/ftrace/ftrace-direct.c +1 -1
@@ -4,7 +4,6 @@#include <linux/sched.h> /* for wake_up_process() */ #include <linux/ftrace.h> #include <asm/asm-offsets.h> -#include <asm/nospec-branch.h> extern void my_direct_func (struct task_struct *p);
@@ -18,6 +17,7 @@ extern void my_tramp(void *);#ifdef CONFIG_X86_64 #include <asm/ibt.h> +#include <asm/nospec-branch.h> asm ( " .pushsection .text, \"ax\", @progbits\n"
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 5/11 ftrace: sample: avoid open-coded 64-bit division
In reply to Steven RostedtFrom: Arnd Bergmann <[email protected]>
Calculating the average period requires a 64-bit division that leads to a link failure on 32-bit architectures:
x86_64-linux-ld: samples/ftrace/ftrace-ops.o: in function `ftrace_ops_sample_init':
ftrace-ops.c:(.init.text+0x23b): undefined reference to `__udivdi3'
Use the div_u64() helper to do this instead. Since this is an init function that is not called frequently, the runtime overhead is going to be acceptable.
--- samples/ftrace/ftrace-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/ftrace/ftrace-ops.c +1 -1
@@ -223,7 +223,7 @@ static int __init ftrace_ops_sample_init(void)pr_info ("Attempted %u calls to %ps in %lluns (%lluns / call)\n" , nr_function_calls, tracee_relevant, - period, period / nr_function_calls); + period,div_u64 (period, nr_function_calls));if (persist)return 0 ;
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 6/11 samples: ftrace: Make some global variables static
In reply to Steven RostedtFrom: Tom Rix <[email protected]>
smatch reports this representative issuesamples/ftrace/ftrace-ops.c:15:14: warning: symbol 'nr_function_calls' was not declared. Should it be static?
The nr_functions_calls and several other global variables are only used in ftrace-ops.c, so they should be static.
Remove the instances of initializing static int to 0.
--- samples/ftrace/ftrace-ops.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
samples/ftrace/ftrace-ops.c +12 -12
@@ -12,7 +12,7 @@* Arbitrary large value chosen to be sufficiently large to minimize noise but * sufficiently small to complete quickly. */ -unsigned int nr_function_calls =100000 ; +static unsigned int nr_function_calls =100000 ;module_param (nr_function_calls, uint,0 );MODULE_PARM_DESC (nr_function_calls,"How many times to call the relevant tracee" );
@@ -21,7 +21,7 @@ MODULE_PARM_DESC(nr_function_calls, "How many times to call the relevant tracee"* be called directly or whether it's necessary to go via the list func, which * can be significantly more expensive. */ -unsigned int nr_ops_relevant =1 ; +static unsigned int nr_ops_relevant =1 ;module_param (nr_ops_relevant, uint,0 );MODULE_PARM_DESC (nr_ops_relevant,"How many ftrace_ops to associate with the relevant tracee" );
@@ -30,7 +30,7 @@ MODULE_PARM_DESC(nr_ops_relevant, "How many ftrace_ops to associate with the rel* tracers enabled for distinct functions can force the use of the list func * and incur overhead for all call sites. */ -unsigned int nr_ops_irrelevant =0 ; +static unsigned int nr_ops_irrelevant;module_param (nr_ops_irrelevant, uint,0 );MODULE_PARM_DESC (nr_ops_irrelevant,"How many ftrace_ops to associate with the irrelevant tracee" );
@@ -38,15 +38,15 @@ MODULE_PARM_DESC(nr_ops_irrelevant, "How many ftrace_ops to associate with the i* On architectures with DYNAMIC_FTRACE_WITH_REGS, saving the full pt_regs can * be more expensive than only saving the minimal necessary regs. */ -bool save_regs = false; +static bool save_regs;module_param (save_regs, bool,0 );MODULE_PARM_DESC (save_regs,"Register ops with FTRACE_OPS_FL_SAVE_REGS (save all registers in the trampoline)" ); -bool assist_recursion = false; +static bool assist_recursion;module_param (assist_recursion, bool,0 );MODULE_PARM_DESC (assist_reursion,"Register ops with FTRACE_OPS_FL_RECURSION" ); -bool assist_rcu = false; +static bool assist_rcu;module_param (assist_rcu, bool,0 );MODULE_PARM_DESC (assist_reursion,"Register ops with FTRACE_OPS_FL_RCU" );
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(assist_reursion, "Register ops with FTRACE_OPS_FL_RCU");* overhead. Sometimes a consistency check using a more expensive tracer is * desireable. */ -bool check_count = false; +static bool check_count;module_param (check_count, bool,0 );MODULE_PARM_DESC (check_count,"Check that tracers are called the expected number of times\n" );
@@ -64,7 +64,7 @@ MODULE_PARM_DESC(check_count, "Check that tracers are called the expected number* runs, but sometimes it can be useful to leave them registered so that they * can be inspected through the tracefs 'enabled_functions' file. */ -bool persist = false; +static bool persist;module_param (persist, bool,0 );MODULE_PARM_DESC (persist,"Successfully load module and leave ftrace ops registered after test completes\n" );
@@ -114,8 +114,8 @@ static void ops_func_count(unsigned long ip, unsigned long parent_ip, self->count++; } -struct sample_ops *ops_relevant; -struct sample_ops *ops_irrelevant; +static struct sample_ops *ops_relevant; +static struct sample_ops *ops_irrelevant;static struct sample_ops *ops_alloc_init (void *tracee,ftrace_func_t func,unsigned long flags,int nr)
@@ -163,8 +163,8 @@ static void ops_check(struct sample_ops *ops, int nr, } } -ftrace_func_t tracer_relevant = ops_func_nop; -ftrace_func_t tracer_irrelevant = ops_func_nop; +static ftrace_func_t tracer_relevant = ops_func_nop; +static ftrace_func_t tracer_irrelevant = ops_func_nop;static int __init ftrace_ops_sample_init (void ) {
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 7/11 tracing: Fix trace_event_raw_event_synth() if else statement
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
The test to check if the field is a stack is to be done if it is not a string. But the code had:
} if (event->fields[i]->is_stack) {and not
} else if (event->fields[i]->is_stack) {which would cause it to always be tested. Worse yet, this also included an "else" statement that was only to be called if the field was not a string and a stack, but this code allows it to be called if it was a string (and not a stack).
Also fixed some whitespace issues.
--- kernel/trace/trace_events_synth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_events_synth.c +2 -2
@@ -564,8 +564,8 @@ static notrace void trace_event_raw_event_synth(void *__data, event->fields[i]->is_dynamic, data_size, &n_u64); data_size += len;/* only dynamic string increments */ - }if (event->fields[i]->is_stack) { -long *stack = (long *)(long )var_ref_vals[val_idx]; + }else if (event->fields[i]->is_stack) { +long *stack = (long *)(long )var_ref_vals[val_idx]; len =trace_stack (entry, event, stack, data_size, &n_u64);
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 8/11 tracing: Add creation of instances at boot command line
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
Add kernel command line to add tracing instances. This only creates instances at boot but still does not enable any events to them. Later changes will extend this command line to add enabling of events, filters, and triggers. As well as possibly redirecting trace_printk()!
--- .../admin-guide/kernel-parameters.txt | 6 +++ kernel/trace/trace.c | 50 +++++++++++++++++++ 2 files changed, 56 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +6 -0
@@ -6272,6 +6272,12 @@ comma-separated list of trace events to enable. See also Documentation/trace/events.rst + trace_instance=[instance-info] + [FTRACE] Create a ring buffer instance early in boot up. + This will be listed in: + + /sys/kernel/tracing/instances + trace_options=[option-list] [FTRACE] Enable or disable tracer options at boot. The option-list is a comma delimited list of options
kernel/trace/trace.c +50 -0
80 lines not on this page · raw message
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 9/11 tracing: Add enabling of events to boot instances
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
Add the format of:
trace_instance=foo,sched:sched_switch,irq_handler_entry,initcall
That will create the "foo" instance and enable the sched_switch event (here were the "sched" system is explicitly specified), the irq_handler_entry event, and all events under the system initcall.
--- Documentation/admin-guide/kernel-parameters.txt | 14 ++++++++++++++ kernel/trace/trace.c | 4 ++++ kernel/trace/trace.h | 2 ++ kernel/trace/trace_events.c | 9 ++++----- 4 files changed, 24 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +14 -0
@@ -6278,6 +6278,20 @@ /sys/kernel/tracing/instances + Events can be enabled at the time the instance is created + via: + + trace_instance=<name>,<system1>:<event1>,<system2>:<event2> + + Note, the "<system*>:" portion is optional if the event is + unique. + + trace_instance=foo,sched:sched_switch,irq_handler_entry,initcall + + will enable the "sched_switch" event (note, the "sched:" is optional, and + the same thing would happen if it was left off). The irq_handler_entry + event, and all events under the "initcall" system. + trace_options=[option-list] [FTRACE] Enable or disable tracer options at boot. The option-list is a comma delimited list of options
kernel/trace/trace.c +4 -0
@@ -10188,6 +10188,10 @@ __init static void enable_instances(void) }/* Allow user space to delete it */ trace_array_put (tr); + +while ((tok =strsep (&curr_str,"," ))) { +early_enable_events (tr, tok, true); + } } }
kernel/trace/trace.h +2 -0
@@ -1334,6 +1334,8 @@ DECLARE_PER_CPU(int, trace_buffered_event_cnt);void trace_buffered_event_disable (void );void trace_buffered_event_enable (void ); +void early_enable_events (struct trace_array *tr,char *buf,bool disable_first); +static inline void __trace_event_discard_commit (struct trace_buffer *buffer,struct ring_buffer_event *event)
kernel/trace/trace_events.c +4 -5
@@ -3750,10 +3750,9 @@ static __init int event_trace_memsetup(void)return 0 ; } -static __init void -early_enable_events (struct trace_array *tr,bool disable_first) +__init void +early_enable_events (struct trace_array *tr,char *buf,bool disable_first) { -char *buf = bootup_event_buf;char *token;int ret;
@@ -3806,7 +3805,7 @@ static __init int event_trace_enable(void)*/ __trace_early_add_events (tr); -early_enable_events (tr, false); +early_enable_events (tr, bootup_event_buf, false);trace_printk_start_comm ();
@@ -3834,7 +3833,7 @@ static __init int event_trace_enable_again(void)if (!tr)return -ENODEV ; -early_enable_events (tr, true); +early_enable_events (tr, bootup_event_buf, true);return 0 ; }
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 10/11 tracing: Add trace_array_puts() to write into instance
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
Add a generic trace_array_puts() that can be used to "trace_puts()" into an allocated trace_array instance. This is just another variant of trace_array_printk().
--- include/linux/trace.h | 12 ++++++++++++ kernel/trace/trace.c | 27 +++++++++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-)
include/linux/trace.h +12 -0
@@ -33,6 +33,18 @@ struct trace_array;int register_ftrace_export (struct trace_export *export);int unregister_ftrace_export (struct trace_export *export); +/** +* trace_array_puts - write a constant string into the trace buffer. +* @tr: The trace array to write to +* @str: The constant string to write +*/ +#define trace_array_puts (tr, str) \ + ({ \ + str ? __trace_array_puts(tr, _THIS_IP_, str, strlen(str)) : -1; \ + }) +int __trace_array_puts (struct trace_array *tr,unsigned long ip, +const char *str,int size); +void trace_printk_init_buffers (void ); __printf(3, 4) int trace_array_printk(struct trace_array *tr, unsigned long ip,
kernel/trace/trace.c +17 -10
@@ -1023,13 +1023,8 @@ __buffer_unlock_commit(struct trace_buffer *buffer, struct ring_buffer_event *evring_buffer_unlock_commit (buffer); } -/** -* __trace_puts - write a constant string into the trace buffer. -* @ip: The address of the caller -* @str: The constant string to write -* @size: The size of the string. -*/ -int __trace_puts (unsigned long ip,const char *str,int size) +int __trace_array_puts (struct trace_array *tr,unsigned long ip, +const char *str,int size) {struct ring_buffer_event *event;struct trace_buffer *buffer;
@@ -1037,7 +1032,7 @@ int __trace_puts(unsigned long ip, const char *str, int size)unsigned int trace_ctx;int alloc; -if (!(global_trace.trace_flags &TRACE_ITER_PRINTK )) +if (!(tr->trace_flags &TRACE_ITER_PRINTK ))return 0 ;if (unlikely (tracing_selftest_running || tracing_disabled))
@@ -1046,7 +1041,7 @@ int __trace_puts(unsigned long ip, const char *str, int size) alloc =sizeof (*entry) + size +2 ;/* possible \n added */ trace_ctx =tracing_gen_ctx (); - buffer = global_trace.array_buffer.buffer; + buffer = tr->array_buffer.buffer;ring_buffer_nest_start (buffer); event =__trace_buffer_lock_reserve (buffer,TRACE_PRINT , alloc, trace_ctx);
@@ -1068,11 +1063,23 @@ int __trace_puts(unsigned long ip, const char *str, int size) entry->buf[size] ='\0' ;__buffer_unlock_commit (buffer, event); -ftrace_trace_stack (&global_trace, buffer, trace_ctx,4 ,NULL ); +ftrace_trace_stack (tr, buffer, trace_ctx,4 ,NULL ); out:ring_buffer_nest_end (buffer);return size; } +EXPORT_SYMBOL_GPL (__trace_array_puts); + +/** +* __trace_puts - write a constant string into the trace buffer. +* @ip: The address of the caller +* @str: The constant string to write +* @size: The size of the string. +*/ +int __trace_puts (unsigned long ip,const char *str,int size) +{ +return __trace_array_puts (&global_trace, ip, str, size); +}EXPORT_SYMBOL_GPL (__trace_puts);/**
Signature · 1 line
2.39.1
Steven Rostedt
maintainerPATCH 11/11 tracing: Allow boot instances to have snapshot buffers
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
Add to ftrace_boot_snapshot, "=<instance>" name, where the instance will get a snapshot buffer, and will take a snapshot at the end of boot (which will save the boot traces).
--- .../admin-guide/kernel-parameters.txt | 9 +++ kernel/trace/trace.c | 79 +++++++++++++++++-- 2 files changed, 81 insertions(+), 7 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +9 -0
@@ -1532,6 +1532,15 @@ boot up that is likely to be overridden by user space start up functionality. + Optionally, the snapshot can also be defined for a tracing + instance that was created by the trace_instance= command + line parameter. + + trace_instance=foo,sched_switch ftrace_boot_snapshot=foo + + The above will cause the "foo" tracing instance to trigger + a snapshot at the end of boot up. + ftrace_dump_on_oops[=orig_cpu] [FTRACE] will dump the trace buffers on oops. If no parameter is passed, ftrace will dump
kernel/trace/trace.c +72 -7
119 lines not on this page · raw message
Signature · 1 line
2.39.1