Tracing updates for 5.8:

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.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYIADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCXt+LEhQccm9zdGVkdEBn
 b29kbWlzLm9yZwAKCRAp5XQQmuv6qj2zAP9sD/W4jafYayucj+MvRP7sy+Q0iAH7
 WMn8fkk958cgfQD8D1QFtkkx+3O3TRT6ApGf11w5+JgSWUE2gSbW9H4fPQk=
 =X5t4
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2020-06-09 10:06:18 -07:00
commit d1e521adad
21 changed files with 4322 additions and 1814 deletions

File diff suppressed because it is too large Load Diff

View File

@ -249,15 +249,6 @@ config TRACE_PREEMPT_TOGGLE
Enables hooks which will be called when preemption is first disabled, Enables hooks which will be called when preemption is first disabled,
and last enabled. and last enabled.
config PREEMPTIRQ_EVENTS
bool "Enable trace events for preempt and irq disable/enable"
select TRACE_IRQFLAGS
select TRACE_PREEMPT_TOGGLE if PREEMPTION
select GENERIC_TRACER
default n
help
Enable tracing of disable and enable events for preemption and irqs.
config IRQSOFF_TRACER config IRQSOFF_TRACER
bool "Interrupts-off Latency Tracer" bool "Interrupts-off Latency Tracer"
default n default n
@ -614,12 +605,30 @@ config TRACING_MAP
generally used outside of that context, and is normally generally used outside of that context, and is normally
selected by tracers that use it. selected by tracers that use it.
config SYNTH_EVENTS
bool "Synthetic trace events"
select TRACING
select DYNAMIC_EVENTS
default n
help
Synthetic events are user-defined trace events that can be
used to combine data from other trace events or in fact any
data source. Synthetic events can be generated indirectly
via the trace() action of histogram triggers or directly
by way of an in-kernel API.
See Documentation/trace/events.rst or
Documentation/trace/histogram.rst for details and examples.
If in doubt, say N.
config HIST_TRIGGERS config HIST_TRIGGERS
bool "Histogram triggers" bool "Histogram triggers"
depends on ARCH_HAVE_NMI_SAFE_CMPXCHG depends on ARCH_HAVE_NMI_SAFE_CMPXCHG
select TRACING_MAP select TRACING_MAP
select TRACING select TRACING
select DYNAMIC_EVENTS select DYNAMIC_EVENTS
select SYNTH_EVENTS
default n default n
help help
Hist triggers allow one or more arbitrary trace event fields Hist triggers allow one or more arbitrary trace event fields
@ -815,7 +824,7 @@ config PREEMPTIRQ_DELAY_TEST
config SYNTH_EVENT_GEN_TEST config SYNTH_EVENT_GEN_TEST
tristate "Test module for in-kernel synthetic event generation" tristate "Test module for in-kernel synthetic event generation"
depends on HIST_TRIGGERS depends on SYNTH_EVENTS
help help
This option creates a test module to check the base This option creates a test module to check the base
functionality of in-kernel synthetic event definition and functionality of in-kernel synthetic event definition and
@ -838,6 +847,29 @@ config KPROBE_EVENT_GEN_TEST
If unsure, say N. If unsure, say N.
config HIST_TRIGGERS_DEBUG
bool "Hist trigger debug support"
depends on HIST_TRIGGERS
help
Add "hist_debug" file for each event, which when read will
dump out a bunch of internal details about the hist triggers
defined on that event.
The hist_debug file serves a couple of purposes:
- Helps developers verify that nothing is broken.
- Provides educational information to support the details
of the hist trigger internals as described by
Documentation/trace/histogram-design.rst.
The hist_debug output only covers the data structures
related to the histogram definitions themselves and doesn't
display the internals of map buckets or variable values of
running histograms.
If unsure, say N.
endif # FTRACE endif # FTRACE
endif # TRACING_SUPPORT endif # TRACING_SUPPORT

View File

@ -72,6 +72,7 @@ endif
obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o
obj-$(CONFIG_EVENT_TRACING) += trace_events_trigger.o obj-$(CONFIG_EVENT_TRACING) += trace_events_trigger.o
obj-$(CONFIG_TRACE_EVENT_INJECT) += trace_events_inject.o obj-$(CONFIG_TRACE_EVENT_INJECT) += trace_events_inject.o
obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o
obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o
obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o
obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o

View File

@ -2016,14 +2016,14 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
{ {
unsigned long ip = rec ? rec->ip : 0; unsigned long ip = rec ? rec->ip : 0;
pr_info("------------[ ftrace bug ]------------\n");
switch (failed) { switch (failed) {
case -EFAULT: case -EFAULT:
FTRACE_WARN_ON_ONCE(1);
pr_info("ftrace faulted on modifying "); pr_info("ftrace faulted on modifying ");
print_ip_sym(KERN_INFO, ip); print_ip_sym(KERN_INFO, ip);
break; break;
case -EINVAL: case -EINVAL:
FTRACE_WARN_ON_ONCE(1);
pr_info("ftrace failed to modify "); pr_info("ftrace failed to modify ");
print_ip_sym(KERN_INFO, ip); print_ip_sym(KERN_INFO, ip);
print_ip_ins(" actual: ", (unsigned char *)ip); print_ip_ins(" actual: ", (unsigned char *)ip);
@ -2034,12 +2034,10 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
} }
break; break;
case -EPERM: case -EPERM:
FTRACE_WARN_ON_ONCE(1);
pr_info("ftrace faulted on writing "); pr_info("ftrace faulted on writing ");
print_ip_sym(KERN_INFO, ip); print_ip_sym(KERN_INFO, ip);
break; break;
default: default:
FTRACE_WARN_ON_ONCE(1);
pr_info("ftrace faulted on unknown error "); pr_info("ftrace faulted on unknown error ");
print_ip_sym(KERN_INFO, ip); print_ip_sym(KERN_INFO, ip);
} }
@ -2066,6 +2064,8 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
ip = ftrace_get_addr_curr(rec); ip = ftrace_get_addr_curr(rec);
pr_cont("\n expected tramp: %lx\n", ip); pr_cont("\n expected tramp: %lx\n", ip);
} }
FTRACE_WARN_ON_ONCE(1);
} }
static int ftrace_check_record(struct dyn_ftrace *rec, bool enable, bool update) static int ftrace_check_record(struct dyn_ftrace *rec, bool enable, bool update)

View File

@ -1299,8 +1299,11 @@ EXPORT_SYMBOL_GPL(tracing_off);
void disable_trace_on_warning(void) void disable_trace_on_warning(void)
{ {
if (__disable_trace_on_warning) if (__disable_trace_on_warning) {
trace_array_printk_buf(global_trace.array_buffer.buffer, _THIS_IP_,
"Disabling tracing due to warning\n");
tracing_off(); tracing_off();
}
} }
/** /**

View File

@ -1661,6 +1661,7 @@ extern struct list_head ftrace_events;
extern const struct file_operations event_trigger_fops; extern const struct file_operations event_trigger_fops;
extern const struct file_operations event_hist_fops; extern const struct file_operations event_hist_fops;
extern const struct file_operations event_hist_debug_fops;
extern const struct file_operations event_inject_fops; extern const struct file_operations event_inject_fops;
#ifdef CONFIG_HIST_TRIGGERS #ifdef CONFIG_HIST_TRIGGERS

View File

@ -2208,6 +2208,10 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file)
#ifdef CONFIG_HIST_TRIGGERS #ifdef CONFIG_HIST_TRIGGERS
trace_create_file("hist", 0444, file->dir, file, trace_create_file("hist", 0444, file->dir, file,
&event_hist_fops); &event_hist_fops);
#endif
#ifdef CONFIG_HIST_TRIGGERS_DEBUG
trace_create_file("hist_debug", 0444, file->dir, file,
&event_hist_debug_fops);
#endif #endif
trace_create_file("format", 0444, file->dir, call, trace_create_file("format", 0444, file->dir, call,
&ftrace_event_format_fops); &ftrace_event_format_fops);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1006,7 +1006,7 @@ int trace_probe_init(struct trace_probe *tp, const char *event,
INIT_LIST_HEAD(&tp->event->class.fields); INIT_LIST_HEAD(&tp->event->class.fields);
INIT_LIST_HEAD(&tp->event->probes); INIT_LIST_HEAD(&tp->event->probes);
INIT_LIST_HEAD(&tp->list); INIT_LIST_HEAD(&tp->list);
list_add(&tp->event->probes, &tp->list); list_add(&tp->list, &tp->event->probes);
call = trace_probe_event_call(tp); call = trace_probe_event_call(tp);
call->class = &tp->event->class; call->class = &tp->event->class;

View File

@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef __TRACE_SYNTH_H
#define __TRACE_SYNTH_H
#include "trace_dynevent.h"
#define SYNTH_SYSTEM "synthetic"
#define SYNTH_FIELDS_MAX 32
#define STR_VAR_LEN_MAX 32 /* must be multiple of sizeof(u64) */
struct synth_field {
char *type;
char *name;
size_t size;
unsigned int offset;
bool is_signed;
bool is_string;
};
struct synth_event {
struct dyn_event devent;
int ref;
char *name;
struct synth_field **fields;
unsigned int n_fields;
unsigned int n_u64;
struct trace_event_class class;
struct trace_event_call call;
struct tracepoint *tp;
struct module *mod;
};
extern struct synth_event *find_synth_event(const char *name);
#endif /* __TRACE_SYNTH_H */

View File

@ -47,6 +47,7 @@
#include <linux/bug.h> #include <linux/bug.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/rculist.h> #include <linux/rculist.h>
#include <linux/ftrace.h>
extern struct bug_entry __start___bug_table[], __stop___bug_table[]; extern struct bug_entry __start___bug_table[], __stop___bug_table[];
@ -153,6 +154,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
if (!bug) if (!bug)
return BUG_TRAP_TYPE_NONE; return BUG_TRAP_TYPE_NONE;
disable_trace_on_warning();
file = NULL; file = NULL;
line = 0; line = 0;
warning = 0; warning = 0;

View File

@ -124,9 +124,16 @@ for i in samples/good-* ; do
xpass $BOOTCONF -a $i $INITRD xpass $BOOTCONF -a $i $INITRD
done done
echo
echo "=== Summary ==="
echo "# of Passed: $(expr $NO - $NG - 1)"
echo "# of Failed: $NG"
echo echo
if [ $NG -eq 0 ]; then if [ $NG -eq 0 ]; then
echo "All tests passed" echo "All tests passed"
else else
echo "$NG tests failed" echo "$NG tests failed"
exit 1
fi fi

View File

@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then
exit_unsupported exit_unsupported
fi fi
if [ ! -f events/sched/sched_process_fork/hist ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
echo "Test field variable support" echo "Test field variable support"
echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events

View File

@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then
exit_unsupported exit_unsupported
fi fi
if [ ! -f events/sched/sched_process_fork/hist ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
echo "Test create synthetic event" echo "Test create synthetic event"
echo 'waking_latency u64 lat pid_t pid' > synthetic_events echo 'waking_latency u64 lat pid_t pid' > synthetic_events

View File

@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then
exit_unsupported exit_unsupported
fi fi
if [ ! -f events/sched/sched_process_fork/hist ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
echo "Test multiple actions on hist trigger" echo "Test multiple actions on hist trigger"
echo 'wakeup_latency u64 lat; pid_t pid' >> synthetic_events echo 'wakeup_latency u64 lat; pid_t pid' >> synthetic_events
TRIGGER1=events/sched/sched_wakeup/trigger TRIGGER1=events/sched/sched_wakeup/trigger

View File

@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then
exit_unsupported exit_unsupported
fi fi
if [ ! -f events/sched/sched_process_fork/hist ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
echo "Test create synthetic event" echo "Test create synthetic event"
echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events

View File

@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then
exit_unsupported exit_unsupported
fi fi
if [ ! -f events/sched/sched_process_fork/hist ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
echo "Test create synthetic event" echo "Test create synthetic event"
echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events

View File

@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then
exit_unsupported exit_unsupported
fi fi
if [ ! -f events/sched/sched_process_fork/hist ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
echo "Test create synthetic event" echo "Test create synthetic event"
echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events

View File

@ -12,6 +12,11 @@ if [ ! -f set_event ]; then
exit_unsupported exit_unsupported
fi fi
if [ ! -f events/sched/sched_process_fork/hist ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
if [ ! -f snapshot ]; then if [ ! -f snapshot ]; then
echo "snapshot is not supported" echo "snapshot is not supported"
exit_unsupported exit_unsupported

View File

@ -17,6 +17,11 @@ if [ ! -f synthetic_events ]; then
exit_unsupported exit_unsupported
fi fi
if [ ! -f events/sched/sched_process_fork/hist ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
grep -q "trace(<synthetic_event>" README || exit_unsupported # version issue grep -q "trace(<synthetic_event>" README || exit_unsupported # version issue
echo "Test create synthetic event" echo "Test create synthetic event"