Skip to content

Commit 5572ad8

Browse files
committed
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
2 parents f2a3b12 + 1e2ed4b commit 5572ad8

5 files changed

Lines changed: 22 additions & 6 deletions

File tree

include/linux/ftrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ static inline void ftrace_init(void) { }
11671167
*/
11681168
struct ftrace_graph_ent {
11691169
unsigned long func; /* Current function */
1170-
unsigned long depth;
1170+
long depth; /* signed to check for less than zero */
11711171
} __packed;
11721172

11731173
/*

include/linux/trace_recursion.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ enum {
3434
TRACE_INTERNAL_SIRQ_BIT,
3535
TRACE_INTERNAL_TRANSITION_BIT,
3636

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+
3744
TRACE_BRANCH_BIT,
3845
/*
3946
* Abuse of the trace_recursion.
@@ -58,6 +65,8 @@ enum {
5865

5966
#define TRACE_LIST_START TRACE_INTERNAL_BIT
6067

68+
#define TRACE_EVENT_START TRACE_INTERNAL_EVENT_BIT
69+
6170
#define TRACE_CONTEXT_MASK ((1 << (TRACE_LIST_START + TRACE_CONTEXT_BITS)) - 1)
6271

6372
/*

kernel/trace/ring_buffer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,6 +3137,8 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
31373137
list) {
31383138
list_del_init(&bpage->list);
31393139
free_buffer_page(bpage);
3140+
3141+
cond_resched();
31403142
}
31413143
}
31423144
out_err_unlock:

kernel/trace/trace.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ cpumask_var_t __read_mostly tracing_buffer_mask;
138138
* by commas.
139139
*/
140140
/* 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";
142142

143143
/* When set, tracing will stop when a WARN*() is hit */
144144
static int __disable_trace_on_warning;
@@ -3012,6 +3012,11 @@ static void __ftrace_trace_stack(struct trace_array *tr,
30123012
struct ftrace_stack *fstack;
30133013
struct stack_entry *entry;
30143014
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;
30153020

30163021
/*
30173022
* Add one, for this function and the call to save_stack_trace()
@@ -3080,6 +3085,7 @@ static void __ftrace_trace_stack(struct trace_array *tr,
30803085
/* Again, don't let gcc optimize things here */
30813086
barrier();
30823087
__this_cpu_dec(ftrace_stack_reserve);
3088+
trace_clear_recursion(bit);
30833089
}
30843090

30853091
static inline void ftrace_trace_stack(struct trace_array *tr,

kernel/trace/trace_events.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -826,16 +826,15 @@ static int __ftrace_event_enable_disable(struct trace_event_file *file,
826826
* When soft_disable is set and enable is set, we want to
827827
* register the tracepoint for the event, but leave the event
828828
* 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.
832832
*/
833833
if (!soft_disable)
834834
clear_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags);
835835
else {
836836
if (atomic_inc_return(&file->sm_ref) > 1)
837837
break;
838-
soft_mode = true;
839838
/* Enable use of trace_buffered_event */
840839
trace_buffered_event_enable();
841840
}

0 commit comments

Comments
 (0)