Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

notifiers: add tracepoints to the notifiers infrastructure

Currently there is no way to show the callback names for registered,
unregistered or executed notifiers. This is very useful for debug
purposes, hence add this functionality here in the form of notifiers'
tracepoints, one per operation.

[akpm@linux-foundation.org: coding-style cleanups]
Link: https://lkml.kernel.org/r/20230314200058.1326909-1-gpiccoli@igalia.com
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Michael Kelley <mikelley@microsoft.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Xiaoming Ni <nixiaoming@huawei.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Guilherme G. Piccoli <gpiccoli@igalia.com>
Cc: Guilherme G. Piccoli <kernel@gpiccoli.net>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Valentin Schneider <valentin.schneider@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Guilherme G. Piccoli and committed by
Andrew Morton
f4708a82 882c5b26

+75
+69
include/trace/events/notifier.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #undef TRACE_SYSTEM 3 + #define TRACE_SYSTEM notifier 4 + 5 + #if !defined(_TRACE_NOTIFIERS_H) || defined(TRACE_HEADER_MULTI_READ) 6 + #define _TRACE_NOTIFIERS_H 7 + 8 + #include <linux/tracepoint.h> 9 + 10 + DECLARE_EVENT_CLASS(notifier_info, 11 + 12 + TP_PROTO(void *cb), 13 + 14 + TP_ARGS(cb), 15 + 16 + TP_STRUCT__entry( 17 + __field(void *, cb) 18 + ), 19 + 20 + TP_fast_assign( 21 + __entry->cb = cb; 22 + ), 23 + 24 + TP_printk("%ps", __entry->cb) 25 + ); 26 + 27 + /* 28 + * notifier_register - called upon notifier callback registration 29 + * 30 + * @cb: callback pointer 31 + * 32 + */ 33 + DEFINE_EVENT(notifier_info, notifier_register, 34 + 35 + TP_PROTO(void *cb), 36 + 37 + TP_ARGS(cb) 38 + ); 39 + 40 + /* 41 + * notifier_unregister - called upon notifier callback unregistration 42 + * 43 + * @cb: callback pointer 44 + * 45 + */ 46 + DEFINE_EVENT(notifier_info, notifier_unregister, 47 + 48 + TP_PROTO(void *cb), 49 + 50 + TP_ARGS(cb) 51 + ); 52 + 53 + /* 54 + * notifier_run - called upon notifier callback execution 55 + * 56 + * @cb: callback pointer 57 + * 58 + */ 59 + DEFINE_EVENT(notifier_info, notifier_run, 60 + 61 + TP_PROTO(void *cb), 62 + 63 + TP_ARGS(cb) 64 + ); 65 + 66 + #endif /* _TRACE_NOTIFIERS_H */ 67 + 68 + /* This part must be outside protection */ 69 + #include <trace/define_trace.h>
+6
kernel/notifier.c
··· 7 7 #include <linux/vmalloc.h> 8 8 #include <linux/reboot.h> 9 9 10 + #define CREATE_TRACE_POINTS 11 + #include <trace/events/notifier.h> 12 + 10 13 /* 11 14 * Notifier list for kernel code which wants to be called 12 15 * at shutdown. This is used to stop any idling DMA operations ··· 40 37 } 41 38 n->next = *nl; 42 39 rcu_assign_pointer(*nl, n); 40 + trace_notifier_register((void *)n->notifier_call); 43 41 return 0; 44 42 } 45 43 ··· 50 46 while ((*nl) != NULL) { 51 47 if ((*nl) == n) { 52 48 rcu_assign_pointer(*nl, n->next); 49 + trace_notifier_unregister((void *)n->notifier_call); 53 50 return 0; 54 51 } 55 52 nl = &((*nl)->next); ··· 89 84 continue; 90 85 } 91 86 #endif 87 + trace_notifier_run((void *)nb->notifier_call); 92 88 ret = nb->notifier_call(nb, val, v); 93 89 94 90 if (nr_calls)