From de8bfae0606d748908a70a435fee9d9ce57b13ea Mon Sep 17 00:00:00 2001 From: David Ahern Date: Mon, 29 Apr 2019 11:38:49 -0700 Subject: [PATCH] notifier: add tracepoint to notifier_call_chain Signed-off-by: David Ahern --- include/trace/events/notifier.h | 49 +++++++++++++++++++++++++++++++++++++++++ kernel/notifier.c | 3 +++ 2 files changed, 52 insertions(+) create mode 100644 include/trace/events/notifier.h diff --git a/include/trace/events/notifier.h b/include/trace/events/notifier.h new file mode 100644 index 000000000000..7c531a1135cb --- /dev/null +++ b/include/trace/events/notifier.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM notifier + +#if !defined(_TRACE_NOTIFIER_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_NOTIFIER_H + +#include +#include +#include + +TRACE_EVENT(notifier_call_chain, + + TP_PROTO(struct notifier_block *nb, unsigned long val), + + TP_ARGS(nb, val), + + TP_STRUCT__entry( + __field( u64, val ) + __field( u64, fcn ) + __dynamic_array(char, fcnstr, KSYM_SYMBOL_LEN) + ), + + TP_fast_assign( + void *p = nb->notifier_call; + char sym[KSYM_SYMBOL_LEN]; + + __entry->val = val; + __entry->fcn = (u64) p; + + p = dereference_symbol_descriptor(p); +#ifdef CONFIG_KALLSYMS + sprint_symbol_no_offset(sym, __entry->fcn); + /* avoid a bogus warning: + * "the address of sym will always evaluate as true" + * by using &sym[0] + */ + __assign_str(fcnstr, &sym[0]); +#else + __entry->fcnstr[0] = '\0'; +#endif + ), + + TP_printk("val %lld fcn %llx name %s", __entry->val, __entry->fcn, __get_str(fcnstr)) +); +#endif /* _TRACE_NOTIFIER_H */ + +/* This part must be outside protection */ +#include diff --git a/kernel/notifier.c b/kernel/notifier.c index 6196af8a8223..9b65a9c56fd7 100644 --- a/kernel/notifier.c +++ b/kernel/notifier.c @@ -5,6 +5,8 @@ #include #include #include +#define CREATE_TRACE_POINTS +#include /* * Notifier list for kernel code which wants to be called @@ -90,6 +92,7 @@ static int notifier_call_chain(struct notifier_block **nl, continue; } #endif + trace_notifier_call_chain(nb, val); ret = nb->notifier_call(nb, val, v); if (nr_calls) -- 2.11.0