Skip to content

Commit 614cb27

Browse files
committed
Merge tag 'trace-v5.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fix from Steven Rostedt: "Limit the shooting in the foot of tp_printk The "tp_printk" option redirects the trace event output to printk at boot up. This is useful when a machine crashes before boot where the trace events can not be retrieved by the in kernel ring buffer. But it can be "dangerous" because trace events can be located in high frequency locations such as interrupts and the scheduler, where a printk can slow it down that it live locks the machine (because by the time the printk finishes, the next event is triggered). Thus tp_printk must be used with care. It was discovered that the filter logic to trace events does not apply to the tp_printk events. This can cause a surprise and live lock when the user expects it to be filtered to limit the amount of events printed to the console when in fact it still prints everything" * tag 'trace-v5.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Apply trace filters on all output channels
2 parents 794c793 + 6c34df6 commit 614cb27

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed

kernel/trace/trace.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2897,14 +2897,26 @@ int tracepoint_printk_sysctl(struct ctl_table *table, int write,
28972897

28982898
void trace_event_buffer_commit(struct trace_event_buffer *fbuffer)
28992899
{
2900+
enum event_trigger_type tt = ETT_NONE;
2901+
struct trace_event_file *file = fbuffer->trace_file;
2902+
2903+
if (__event_trigger_test_discard(file, fbuffer->buffer, fbuffer->event,
2904+
fbuffer->entry, &tt))
2905+
goto discard;
2906+
29002907
if (static_key_false(&tracepoint_printk_key.key))
29012908
output_printk(fbuffer);
29022909

29032910
if (static_branch_unlikely(&trace_event_exports_enabled))
29042911
ftrace_exports(fbuffer->event, TRACE_EXPORT_EVENT);
2905-
event_trigger_unlock_commit_regs(fbuffer->trace_file, fbuffer->buffer,
2906-
fbuffer->event, fbuffer->entry,
2907-
fbuffer->trace_ctx, fbuffer->regs);
2912+
2913+
trace_buffer_unlock_commit_regs(file->tr, fbuffer->buffer,
2914+
fbuffer->event, fbuffer->trace_ctx, fbuffer->regs);
2915+
2916+
discard:
2917+
if (tt)
2918+
event_triggers_post_call(file, tt);
2919+
29082920
}
29092921
EXPORT_SYMBOL_GPL(trace_event_buffer_commit);
29102922

kernel/trace/trace.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,38 +1389,6 @@ event_trigger_unlock_commit(struct trace_event_file *file,
13891389
event_triggers_post_call(file, tt);
13901390
}
13911391

1392-
/**
1393-
* event_trigger_unlock_commit_regs - handle triggers and finish event commit
1394-
* @file: The file pointer associated with the event
1395-
* @buffer: The ring buffer that the event is being written to
1396-
* @event: The event meta data in the ring buffer
1397-
* @entry: The event itself
1398-
* @trace_ctx: The tracing context flags.
1399-
*
1400-
* This is a helper function to handle triggers that require data
1401-
* from the event itself. It also tests the event against filters and
1402-
* if the event is soft disabled and should be discarded.
1403-
*
1404-
* Same as event_trigger_unlock_commit() but calls
1405-
* trace_buffer_unlock_commit_regs() instead of trace_buffer_unlock_commit().
1406-
*/
1407-
static inline void
1408-
event_trigger_unlock_commit_regs(struct trace_event_file *file,
1409-
struct trace_buffer *buffer,
1410-
struct ring_buffer_event *event,
1411-
void *entry, unsigned int trace_ctx,
1412-
struct pt_regs *regs)
1413-
{
1414-
enum event_trigger_type tt = ETT_NONE;
1415-
1416-
if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
1417-
trace_buffer_unlock_commit_regs(file->tr, buffer, event,
1418-
trace_ctx, regs);
1419-
1420-
if (tt)
1421-
event_triggers_post_call(file, tt);
1422-
}
1423-
14241392
#define FILTER_PRED_INVALID ((unsigned short)-1)
14251393
#define FILTER_PRED_IS_RIGHT (1 << 15)
14261394
#define FILTER_PRED_FOLD (1 << 15)

0 commit comments

Comments
 (0)