Skip to content

Commit d1e521a

Browse files
committed
Merge tag 'trace-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: "No new features this release. Mostly clean ups, restructuring and documentation. - Have ftrace_bug() show ftrace errors before the WARN, as the WARN will reboot the box before the error messages are printed if panic_on_warn is set. - Have traceoff_on_warn disable tracing sooner (before prints) - Write a message to the trace buffer that its being disabled when disable_trace_on_warning() is set. - Separate out synthetic events from histogram code to let it be used by other parts of the kernel. - More documentation on histogram design. - Other small fixes and clean ups" * tag 'trace-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Remove obsolete PREEMPTIRQ_EVENTS kconfig option tracing/doc: Fix ascii-art in histogram-design.rst tracing: Add a trace print when traceoff_on_warning is triggered ftrace,bug: Improve traceoff_on_warn selftests/ftrace: Distinguish between hist and synthetic event checks tracing: Move synthetic events to a separate file tracing: Fix events.rst section numbering tracing/doc: Fix typos in histogram-design.rst tracing: Add hist_debug trace event files for histogram debugging tracing: Add histogram-design document tracing: Check state.disabled in synth event trace functions tracing/probe: reverse arguments to list_add tools/bootconfig: Add a summary of test cases and return error ftrace: show debugging information when panic_on_warn set
2 parents 595a56a + 388d8bd commit d1e521a

21 files changed

+4382
-1874
lines changed

Documentation/trace/histogram-design.rst

Lines changed: 2115 additions & 0 deletions
Large diffs are not rendered by default.

kernel/trace/Kconfig

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,6 @@ config TRACE_PREEMPT_TOGGLE
249249
Enables hooks which will be called when preemption is first disabled,
250250
and last enabled.
251251

252-
config PREEMPTIRQ_EVENTS
253-
bool "Enable trace events for preempt and irq disable/enable"
254-
select TRACE_IRQFLAGS
255-
select TRACE_PREEMPT_TOGGLE if PREEMPTION
256-
select GENERIC_TRACER
257-
default n
258-
help
259-
Enable tracing of disable and enable events for preemption and irqs.
260-
261252
config IRQSOFF_TRACER
262253
bool "Interrupts-off Latency Tracer"
263254
default n
@@ -614,12 +605,30 @@ config TRACING_MAP
614605
generally used outside of that context, and is normally
615606
selected by tracers that use it.
616607

608+
config SYNTH_EVENTS
609+
bool "Synthetic trace events"
610+
select TRACING
611+
select DYNAMIC_EVENTS
612+
default n
613+
help
614+
Synthetic events are user-defined trace events that can be
615+
used to combine data from other trace events or in fact any
616+
data source. Synthetic events can be generated indirectly
617+
via the trace() action of histogram triggers or directly
618+
by way of an in-kernel API.
619+
620+
See Documentation/trace/events.rst or
621+
Documentation/trace/histogram.rst for details and examples.
622+
623+
If in doubt, say N.
624+
617625
config HIST_TRIGGERS
618626
bool "Histogram triggers"
619627
depends on ARCH_HAVE_NMI_SAFE_CMPXCHG
620628
select TRACING_MAP
621629
select TRACING
622630
select DYNAMIC_EVENTS
631+
select SYNTH_EVENTS
623632
default n
624633
help
625634
Hist triggers allow one or more arbitrary trace event fields
@@ -815,7 +824,7 @@ config PREEMPTIRQ_DELAY_TEST
815824

816825
config SYNTH_EVENT_GEN_TEST
817826
tristate "Test module for in-kernel synthetic event generation"
818-
depends on HIST_TRIGGERS
827+
depends on SYNTH_EVENTS
819828
help
820829
This option creates a test module to check the base
821830
functionality of in-kernel synthetic event definition and
@@ -838,6 +847,29 @@ config KPROBE_EVENT_GEN_TEST
838847

839848
If unsure, say N.
840849

850+
config HIST_TRIGGERS_DEBUG
851+
bool "Hist trigger debug support"
852+
depends on HIST_TRIGGERS
853+
help
854+
Add "hist_debug" file for each event, which when read will
855+
dump out a bunch of internal details about the hist triggers
856+
defined on that event.
857+
858+
The hist_debug file serves a couple of purposes:
859+
860+
- Helps developers verify that nothing is broken.
861+
862+
- Provides educational information to support the details
863+
of the hist trigger internals as described by
864+
Documentation/trace/histogram-design.rst.
865+
866+
The hist_debug output only covers the data structures
867+
related to the histogram definitions themselves and doesn't
868+
display the internals of map buckets or variable values of
869+
running histograms.
870+
871+
If unsure, say N.
872+
841873
endif # FTRACE
842874

843875
endif # TRACING_SUPPORT

kernel/trace/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ endif
7272
obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o
7373
obj-$(CONFIG_EVENT_TRACING) += trace_events_trigger.o
7474
obj-$(CONFIG_TRACE_EVENT_INJECT) += trace_events_inject.o
75+
obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o
7576
obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o
7677
obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o
7778
obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o

kernel/trace/ftrace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,14 +2016,14 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
20162016
{
20172017
unsigned long ip = rec ? rec->ip : 0;
20182018

2019+
pr_info("------------[ ftrace bug ]------------\n");
2020+
20192021
switch (failed) {
20202022
case -EFAULT:
2021-
FTRACE_WARN_ON_ONCE(1);
20222023
pr_info("ftrace faulted on modifying ");
20232024
print_ip_sym(KERN_INFO, ip);
20242025
break;
20252026
case -EINVAL:
2026-
FTRACE_WARN_ON_ONCE(1);
20272027
pr_info("ftrace failed to modify ");
20282028
print_ip_sym(KERN_INFO, ip);
20292029
print_ip_ins(" actual: ", (unsigned char *)ip);
@@ -2034,12 +2034,10 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
20342034
}
20352035
break;
20362036
case -EPERM:
2037-
FTRACE_WARN_ON_ONCE(1);
20382037
pr_info("ftrace faulted on writing ");
20392038
print_ip_sym(KERN_INFO, ip);
20402039
break;
20412040
default:
2042-
FTRACE_WARN_ON_ONCE(1);
20432041
pr_info("ftrace faulted on unknown error ");
20442042
print_ip_sym(KERN_INFO, ip);
20452043
}
@@ -2066,6 +2064,8 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
20662064
ip = ftrace_get_addr_curr(rec);
20672065
pr_cont("\n expected tramp: %lx\n", ip);
20682066
}
2067+
2068+
FTRACE_WARN_ON_ONCE(1);
20692069
}
20702070

20712071
static int ftrace_check_record(struct dyn_ftrace *rec, bool enable, bool update)

kernel/trace/trace.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,8 +1299,11 @@ EXPORT_SYMBOL_GPL(tracing_off);
12991299

13001300
void disable_trace_on_warning(void)
13011301
{
1302-
if (__disable_trace_on_warning)
1302+
if (__disable_trace_on_warning) {
1303+
trace_array_printk_buf(global_trace.array_buffer.buffer, _THIS_IP_,
1304+
"Disabling tracing due to warning\n");
13031305
tracing_off();
1306+
}
13041307
}
13051308

13061309
/**

kernel/trace/trace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,7 @@ extern struct list_head ftrace_events;
16611661

16621662
extern const struct file_operations event_trigger_fops;
16631663
extern const struct file_operations event_hist_fops;
1664+
extern const struct file_operations event_hist_debug_fops;
16641665
extern const struct file_operations event_inject_fops;
16651666

16661667
#ifdef CONFIG_HIST_TRIGGERS

kernel/trace/trace_events.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,10 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file)
22082208
#ifdef CONFIG_HIST_TRIGGERS
22092209
trace_create_file("hist", 0444, file->dir, file,
22102210
&event_hist_fops);
2211+
#endif
2212+
#ifdef CONFIG_HIST_TRIGGERS_DEBUG
2213+
trace_create_file("hist_debug", 0444, file->dir, file,
2214+
&event_hist_debug_fops);
22112215
#endif
22122216
trace_create_file("format", 0444, file->dir, call,
22132217
&ftrace_event_format_fops);

0 commit comments

Comments
 (0)