tracing; Fixes for 6.5
Subsystems (4)
Steven Rostedt
maintainerLinus,
[ Note, I'm having issues with my nitro key, so I used my main PGP key
to sign the tag ]
Tracing fixes for 6.5:
- Fix ring buffer being permanently disabled due to missed record_disabled() Changing the trace cpu mask will disable the ring buffers for the CPUs no longer in the mask. But it fails to update the snapshot buffer. If a snapshot takes place, the accounting for the ring buffer being disabled is corrupted and this can lead to the ring buffer being permanently disabled.
- Add test case for snapshot and cpu mask working together
- Fix memleak by the function graph tracer not getting closed properly. The iterator is used to read the ring buffer. When it opens, it calls the open function of a tracer, and when it is closed, it calls the close iteration. While a trace is being read, it is still possible to change the tracer. If this happens between the function graph tracer and the wakeup tracer (which uses function graph tracing), the tracers are not closed properly during when the iterator sees the switch, and the wakeup function did not initialize its private pointer to NULL, which is used to know if the function graph tracer was the last tracer. It could be fooled in thinking it is, but then on exit it does not call the close function of the function graph tracer to clean up its data.
- Fix synthetic events on big endian machines, by introducing a union that does the conversions properly.
- Fix synthetic events from printing out the number of elements in the stacktrace when it shouldn't.
- Fix synthetic events stacktrace to not print a bogus value at the end.
- Introduce a pipe_cpumask that prevents the trace_pipe files from being opened by more than one task (file descriptor). There was a race found where if splice is called, the iter->ent could become stale and events could be missed. There's no point reading a producer/consumer file by more than one task as they will corrupt each other anyway. Add a cpumask that keeps track of the per_cpu trace_pipe files as well as the global trace_pipe file that prevents more than one open of a trace_pipe file that represents the same ring buffer. This prevents the race from happening.
- Fix ftrace samples for arm64 to work with older compilers.
Please pull the latest trace-v6.5-rc6 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-v6.5-rc6
Tag SHA1: d0cdb2b90c69a61f03822610d2925d31ad195dc8 Head SHA1: e332938e6fc8117fb9bb1374339cea879b3972d9
GONG, Ruiqi (1):
samples: ftrace: Replace bti assembly with hint for older compiler
Sven Schnelle (3):
tracing/synthetic: Use union instead of casts tracing/synthetic: Skip first entry for stack traces tracing/synthetic: Allocate one additional element for size
Zheng Yejian (4):
tracing: Fix cpu buffers unavailable due to 'record_disabled' missed selftests/ftrace: Add a basic testcase for snapshot
tracing: Fix memleak due to race between current_tracer and trace
tracing: Introduce pipe_cpumask to avoid race on trace_pipes
----
include/linux/trace_events.h | 11 +++ kernel/trace/trace.c | 70 ++++++++++++-- kernel/trace/trace.h | 10 ++ kernel/trace/trace_events_synth.c | 103 ++++++++------------- kernel/trace/trace_irqsoff.c | 3 +- kernel/trace/trace_sched_wakeup.c | 2 + samples/ftrace/ftrace-direct-modify.c | 4 +- samples/ftrace/ftrace-direct-multi-modify.c | 4 +- samples/ftrace/ftrace-direct-multi.c | 2 +- samples/ftrace/ftrace-direct-too.c | 2 +- samples/ftrace/ftrace-direct.c | 2 +- .../selftests/ftrace/test.d/00basic/snapshot1.tc | 31 +++++++ 12 files changed, 166 insertions(+), 78 deletions(-) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/snapshot1.tc
---------------------------
include/linux/trace_events.h +11 -0
@@ -59,6 +59,17 @@ int trace_raw_output_prep(struct trace_iterator *iter, extern __printf(2, 3) void trace_event_printf(struct trace_iterator *iter, const char *fmt, ...); +/* Used to find the offset and length of dynamic fields in trace events */ +struct trace_dynamic_info { +#ifdef CONFIG_CPU_BIG_ENDIAN + u16 offset; + u16 len; +#else + u16 len; + u16 offset; +#endif +}; + /* * The trace entry - the most basic unit of tracing. This is what * is printed in the end as a single line in the trace output, such as:
kernel/trace/trace.c +62 -8
166 lines not on this page · raw message
kernel/trace/trace.h +10 -0
@@ -377,6 +377,8 @@ struct trace_array {struct list_head events;struct trace_event_file *trace_marker_file;cpumask_var_t tracing_cpumask;/* only trace on set CPUs */ +/* one per_cpu trace_pipe can be opened by only one user */ +cpumask_var_t pipe_cpumask;int ref;int trace_ref;#ifdef CONFIG_FUNCTION_TRACER
@@ -1295,6 +1297,14 @@ static inline void trace_branch_disable(void)/* set ring buffers to default size if not already done so */ int tracing_update_buffers (void ); +union trace_synth_field { +u8 as_u8; +u16 as_u16; +u32 as_u32; +u64 as_u64; +struct trace_dynamic_info as_dynamic; +}; +struct ftrace_event_field {struct list_head link;const char *name;
kernel/trace/trace_events_synth.c +41 -62
258 lines not on this page · raw message
kernel/trace/trace_irqsoff.c +2 -1
@@ -231,7 +231,8 @@ static void irqsoff_trace_open(struct trace_iterator *iter) {if (is_graph (iter->tr))graph_trace_open (iter); - +else + iter->private =NULL ; }static void irqsoff_trace_close (struct trace_iterator *iter)
kernel/trace/trace_sched_wakeup.c +2 -0
@@ -168,6 +168,8 @@ static void wakeup_trace_open(struct trace_iterator *iter) {if (is_graph (iter->tr))graph_trace_open (iter); +else + iter->private =NULL ; }static void wakeup_trace_close (struct trace_iterator *iter)
samples/ftrace/ftrace-direct-modify.c +2 -2
@@ -105,7 +105,7 @@ asm (" .type my_tramp1, @function\n" " .globl my_tramp1\n" " my_tramp1:" -" bti c\n" +" hint 34\n" // bti c " sub sp, sp, #16\n" " stp x9, x30, [sp]\n" " bl my_direct_func1\n"
@@ -117,7 +117,7 @@ asm (" .type my_tramp2, @function\n" " .globl my_tramp2\n" " my_tramp2:" -" bti c\n" +" hint 34\n" // bti c " sub sp, sp, #16\n" " stp x9, x30, [sp]\n" " bl my_direct_func2\n"
samples/ftrace/ftrace-direct-multi-modify.c +2 -2
@@ -112,7 +112,7 @@ asm (" .type my_tramp1, @function\n" " .globl my_tramp1\n" " my_tramp1:" -" bti c\n" +" hint 34\n" // bti c " sub sp, sp, #32\n" " stp x9, x30, [sp]\n" " str x0, [sp, #16]\n"
@@ -127,7 +127,7 @@ asm (" .type my_tramp2, @function\n" " .globl my_tramp2\n" " my_tramp2:" -" bti c\n" +" hint 34\n" // bti c " sub sp, sp, #32\n" " stp x9, x30, [sp]\n" " str x0, [sp, #16]\n"
samples/ftrace/ftrace-direct-multi.c +1 -1
@@ -75,7 +75,7 @@ asm (" .type my_tramp, @function\n" " .globl my_tramp\n" " my_tramp:" -" bti c\n" +" hint 34\n" // bti c " sub sp, sp, #32\n" " stp x9, x30, [sp]\n" " str x0, [sp, #16]\n"
samples/ftrace/ftrace-direct-too.c +1 -1
@@ -81,7 +81,7 @@ asm (" .type my_tramp, @function\n" " .globl my_tramp\n" " my_tramp:" -" bti c\n" +" hint 34\n" // bti c " sub sp, sp, #48\n" " stp x9, x30, [sp]\n" " stp x0, x1, [sp, #16]\n"
samples/ftrace/ftrace-direct.c +1 -1
@@ -72,7 +72,7 @@ asm (" .type my_tramp, @function\n" " .globl my_tramp\n" " my_tramp:" -" bti c\n" +" hint 34\n" // bti c " sub sp, sp, #32\n" " stp x9, x30, [sp]\n" " str x0, [sp, #16]\n"
tools/testing/selftests/ftrace/test.d/00basic/snapshot1.tc new file +31 -0
@@ -0,0 +1,31 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Snapshot and tracing_cpumask +# requires: trace_marker tracing_cpumask snapshot +# flags: instance + +# This testcase is constrived to reproduce a problem that the cpu buffers +# become unavailable which is due to 'record_disabled' of array_buffer and +# max_buffer being messed up. + +# Store origin cpumask +ORIG_CPUMASK=`cat tracing_cpumask` + +# Stop tracing all cpu +echo 0 > tracing_cpumask + +# Take a snapshot of the main buffer +echo 1 > snapshot + +# Restore origin cpumask, note that there should be some cpus being traced +echo ${ORIG_CPUMASK} > tracing_cpumask + +# Set tracing on +echo 1 > tracing_on + +# Write a log into buffer +echo "test input 1" > trace_marker + +# Ensure the log writed so that cpu buffers are still available +grep -q "test input 1" trace +exit 0
The pull request you sent on Thu, 24 Aug 2023 20:04:01 -0400:
The pull request you sent on Thu, 24 Aug 2023 20:04:01 -0400:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.gittrace-v6.5-rc6
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/4f9e7fabf8643003afefc172e62dd276686f016e
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html