mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
tracing: add error_report_end trace point
Patch series "Add error_report_end tracepoint to KFENCE and KASAN", v3. This patchset adds a tracepoint, error_repor_end, that is to be used by KFENCE, KASAN, and potentially other bug detection tools, when they print an error report. One of the possible use cases is userspace collection of kernel error reports: interested parties can subscribe to the tracing event via tracefs, and get notified when an error report occurs. This patch (of 3): Introduce error_report_end tracepoint. It can be used in debugging tools like KASAN, KFENCE, etc. to provide extensions to the error reporting mechanisms (e.g. allow tests hook into error reporting, ease error report collection from production kernels). Another benefit would be making use of ftrace for debugging or benchmarking the tools themselves. Should we need it, the tracepoint name leaves us with the possibility to introduce a complementary error_report_start tracepoint in the future. Link: https://lkml.kernel.org/r/20210121131915.1331302-1-glider@google.com Link: https://lkml.kernel.org/r/20210121131915.1331302-2-glider@google.com Signed-off-by: Alexander Potapenko <glider@google.com> Suggested-by: Marco Elver <elver@google.com> Cc: Andrey Konovalov <andreyknvl@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Petr Mladek <pmladek@suse.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
35beccf092
commit
9c0dee54eb
74
include/trace/events/error_report.h
Normal file
74
include/trace/events/error_report.h
Normal file
@ -0,0 +1,74 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Declarations for error reporting tracepoints.
|
||||
*
|
||||
* Copyright (C) 2021, Google LLC.
|
||||
*/
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM error_report
|
||||
|
||||
#if !defined(_TRACE_ERROR_REPORT_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_ERROR_REPORT_H
|
||||
|
||||
#include <linux/tracepoint.h>
|
||||
|
||||
#ifndef __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY
|
||||
#define __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY
|
||||
|
||||
enum error_detector {
|
||||
ERROR_DETECTOR_KFENCE,
|
||||
ERROR_DETECTOR_KASAN
|
||||
};
|
||||
|
||||
#endif /* __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY */
|
||||
|
||||
#define error_detector_list \
|
||||
EM(ERROR_DETECTOR_KFENCE, "kfence") \
|
||||
EMe(ERROR_DETECTOR_KASAN, "kasan")
|
||||
/* Always end the list with an EMe. */
|
||||
|
||||
#undef EM
|
||||
#undef EMe
|
||||
|
||||
#define EM(a, b) TRACE_DEFINE_ENUM(a);
|
||||
#define EMe(a, b) TRACE_DEFINE_ENUM(a);
|
||||
|
||||
error_detector_list
|
||||
|
||||
#undef EM
|
||||
#undef EMe
|
||||
|
||||
#define EM(a, b) { a, b },
|
||||
#define EMe(a, b) { a, b }
|
||||
|
||||
#define show_error_detector_list(val) \
|
||||
__print_symbolic(val, error_detector_list)
|
||||
|
||||
DECLARE_EVENT_CLASS(error_report_template,
|
||||
TP_PROTO(enum error_detector error_detector, unsigned long id),
|
||||
TP_ARGS(error_detector, id),
|
||||
TP_STRUCT__entry(__field(enum error_detector, error_detector)
|
||||
__field(unsigned long, id)),
|
||||
TP_fast_assign(__entry->error_detector = error_detector;
|
||||
__entry->id = id;),
|
||||
TP_printk("[%s] %lx",
|
||||
show_error_detector_list(__entry->error_detector),
|
||||
__entry->id));
|
||||
|
||||
/**
|
||||
* error_report_end - called after printing the error report
|
||||
* @error_detector: short string describing the error detection tool
|
||||
* @id: pseudo-unique descriptor identifying the report
|
||||
* (e.g. the memory access address)
|
||||
*
|
||||
* This event occurs right after a debugging tool finishes printing the error
|
||||
* report.
|
||||
*/
|
||||
DEFINE_EVENT(error_report_template, error_report_end,
|
||||
TP_PROTO(enum error_detector error_detector, unsigned long id),
|
||||
TP_ARGS(error_detector, id));
|
||||
|
||||
#endif /* _TRACE_ERROR_REPORT_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
@ -81,6 +81,7 @@ obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o
|
||||
obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o
|
||||
obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o
|
||||
obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o
|
||||
obj-$(CONFIG_TRACEPOINTS) += error_report-traces.o
|
||||
obj-$(CONFIG_TRACEPOINTS) += power-traces.o
|
||||
ifeq ($(CONFIG_PM),y)
|
||||
obj-$(CONFIG_TRACEPOINTS) += rpm-traces.o
|
||||
|
11
kernel/trace/error_report-traces.c
Normal file
11
kernel/trace/error_report-traces.c
Normal file
@ -0,0 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Error reporting trace points.
|
||||
*
|
||||
* Copyright (C) 2021, Google LLC.
|
||||
*/
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/error_report.h>
|
||||
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(error_report_end);
|
Loading…
Reference in New Issue
Block a user