Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'trace-v6.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull tracing fixes from Steven Rostedt:

- Remove useless assignment of soft_mode variable

The function __ftrace_event_enable_disable() sets "soft_mode" in one
of the branch paths but doesn't use it after that. Remove the setting
of that variable.

- Add a cond_resched() in ring_buffer_resize()

The resize function that allocates all the pages for the ring buffer
was causing a soft lockup on PREEMPT_NONE configs when allocating
large buffers on machines with many CPUs. Hopefully this is the last
cond_resched() needed to be added as PREEMPT_LAZY becomes the norm in
the future.

- Make ftrace_graph_ent depth field signed

The "depth" field of struct ftrace_graph_ent was converted from "int"
to "unsigned long" for alignment reasons to work with being embedded
in other structures. The conversion from a signed to unsigned caused
integrity checks to always pass as they were comparing "depth" to
less than zero. Make the field signed long.

- Add recursion protection to stack trace events

A infinite recursion was triggered by a stack trace event calling RCU
which internally called rcu_read_unlock_special(), which triggered an
event that was also doing stacktraces which cause it to trigger the
same RCU lock that called rcu_read_unlock_special() again.

Update the trace_test_and_set_recursion() to add a set of context
checks for events to use, and have the stack trace event use that for
recursion protection.

- Make the variable ftrace_dump_on_oops static

The cleanup of sysctl that moved all the updates to the files that
use them moved the reference of ftrace_dump_on_oops to where it is
used. It is no longer used outside of the trace.c file. Make it
static.

* tag 'trace-v6.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
trace: ftrace_dump_on_oops[] is not exported, make it static
tracing: Add recursion protection in kernel stack trace recording
ftrace: Make ftrace_graph_ent depth field signed
ring-buffer: Avoid softlockup in ring_buffer_resize() during memory free
tracing: Drop unneeded assignment to soft_mode

+22 -6
+1 -1
include/linux/ftrace.h
··· 1167 1167 */ 1168 1168 struct ftrace_graph_ent { 1169 1169 unsigned long func; /* Current function */ 1170 - unsigned long depth; 1170 + long depth; /* signed to check for less than zero */ 1171 1171 } __packed; 1172 1172 1173 1173 /*
+9
include/linux/trace_recursion.h
··· 34 34 TRACE_INTERNAL_SIRQ_BIT, 35 35 TRACE_INTERNAL_TRANSITION_BIT, 36 36 37 + /* Internal event use recursion bits */ 38 + TRACE_INTERNAL_EVENT_BIT, 39 + TRACE_INTERNAL_EVENT_NMI_BIT, 40 + TRACE_INTERNAL_EVENT_IRQ_BIT, 41 + TRACE_INTERNAL_EVENT_SIRQ_BIT, 42 + TRACE_INTERNAL_EVENT_TRANSITION_BIT, 43 + 37 44 TRACE_BRANCH_BIT, 38 45 /* 39 46 * Abuse of the trace_recursion. ··· 64 57 #define TRACE_FTRACE_START TRACE_FTRACE_BIT 65 58 66 59 #define TRACE_LIST_START TRACE_INTERNAL_BIT 60 + 61 + #define TRACE_EVENT_START TRACE_INTERNAL_EVENT_BIT 67 62 68 63 #define TRACE_CONTEXT_MASK ((1 << (TRACE_LIST_START + TRACE_CONTEXT_BITS)) - 1) 69 64
+2
kernel/trace/ring_buffer.c
··· 3137 3137 list) { 3138 3138 list_del_init(&bpage->list); 3139 3139 free_buffer_page(bpage); 3140 + 3141 + cond_resched(); 3140 3142 } 3141 3143 } 3142 3144 out_err_unlock:
+7 -1
kernel/trace/trace.c
··· 138 138 * by commas. 139 139 */ 140 140 /* Set to string format zero to disable by default */ 141 - char ftrace_dump_on_oops[MAX_TRACER_SIZE] = "0"; 141 + static char ftrace_dump_on_oops[MAX_TRACER_SIZE] = "0"; 142 142 143 143 /* When set, tracing will stop when a WARN*() is hit */ 144 144 static int __disable_trace_on_warning; ··· 3012 3012 struct ftrace_stack *fstack; 3013 3013 struct stack_entry *entry; 3014 3014 int stackidx; 3015 + int bit; 3016 + 3017 + bit = trace_test_and_set_recursion(_THIS_IP_, _RET_IP_, TRACE_EVENT_START); 3018 + if (bit < 0) 3019 + return; 3015 3020 3016 3021 /* 3017 3022 * Add one, for this function and the call to save_stack_trace() ··· 3085 3080 /* Again, don't let gcc optimize things here */ 3086 3081 barrier(); 3087 3082 __this_cpu_dec(ftrace_stack_reserve); 3083 + trace_clear_recursion(bit); 3088 3084 } 3089 3085 3090 3086 static inline void ftrace_trace_stack(struct trace_array *tr,
+3 -4
kernel/trace/trace_events.c
··· 826 826 * When soft_disable is set and enable is set, we want to 827 827 * register the tracepoint for the event, but leave the event 828 828 * as is. That means, if the event was already enabled, we do 829 - * nothing (but set soft_mode). If the event is disabled, we 830 - * set SOFT_DISABLED before enabling the event tracepoint, so 831 - * it still seems to be disabled. 829 + * nothing. If the event is disabled, we set SOFT_DISABLED 830 + * before enabling the event tracepoint, so it still seems 831 + * to be disabled. 832 832 */ 833 833 if (!soft_disable) 834 834 clear_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags); 835 835 else { 836 836 if (atomic_inc_return(&file->sm_ref) > 1) 837 837 break; 838 - soft_mode = true; 839 838 /* Enable use of trace_buffered_event */ 840 839 trace_buffered_event_enable(); 841 840 }