[PATCH v2 09/13] notifier: Show function names on notifier routines if DEBUG_NOTIFIERS is set
Guilherme G. Piccoli
gpiccoli at igalia.com
Tue Jul 19 12:53:22 PDT 2022
Currently we have a debug infrastructure in the notifiers file, but
it's very simple/limited. Extend it by:
(a) Showing all registered/unregistered notifiers' callback names;
(b) Adding a dynamic debug tuning to allow showing called notifiers'
function names. Notice that this should be guarded as a tunable since
it can flood the kernel log buffer.
Cc: Arjan van de Ven <arjan at linux.intel.com>
Cc: Cong Wang <xiyou.wangcong at gmail.com>
Cc: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
Cc: Steven Rostedt <rostedt at goodmis.org>
Cc: Valentin Schneider <valentin.schneider at arm.com>
Cc: Xiaoming Ni <nixiaoming at huawei.com>
Signed-off-by: Guilherme G. Piccoli <gpiccoli at igalia.com>
---
V2:
- Major improvement thanks to the great idea from Xiaoming - changed
all the ksym wheel reinvention to printk %ps modifier;
- Instead of ifdefs, using IS_ENABLED() - thanks Steven.
- Removed an unlikely() hint on debug path.
kernel/notifier.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/kernel/notifier.c b/kernel/notifier.c
index 0d5bd62c480e..350761b34f8a 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -37,6 +37,10 @@ static int notifier_chain_register(struct notifier_block **nl,
}
n->next = *nl;
rcu_assign_pointer(*nl, n);
+
+ if (IS_ENABLED(CONFIG_DEBUG_NOTIFIERS))
+ pr_info("notifiers: registered %ps\n", n->notifier_call);
+
return 0;
}
@@ -46,6 +50,11 @@ static int notifier_chain_unregister(struct notifier_block **nl,
while ((*nl) != NULL) {
if ((*nl) == n) {
rcu_assign_pointer(*nl, n->next);
+
+ if (IS_ENABLED(CONFIG_DEBUG_NOTIFIERS))
+ pr_info("notifiers: unregistered %ps\n",
+ n->notifier_call);
+
return 0;
}
nl = &((*nl)->next);
@@ -77,13 +86,14 @@ static int notifier_call_chain(struct notifier_block **nl,
while (nb && nr_to_call) {
next_nb = rcu_dereference_raw(nb->next);
-#ifdef CONFIG_DEBUG_NOTIFIERS
- if (unlikely(!func_ptr_is_kernel_text(nb->notifier_call))) {
- WARN(1, "Invalid notifier called!");
- nb = next_nb;
- continue;
+ if (IS_ENABLED(CONFIG_DEBUG_NOTIFIERS)) {
+ if (!func_ptr_is_kernel_text(nb->notifier_call)) {
+ WARN(1, "Invalid notifier called!");
+ nb = next_nb;
+ continue;
+ }
+ pr_debug("notifiers: calling %ps\n", nb->notifier_call);
}
-#endif
ret = nb->notifier_call(nb, val, v);
if (nr_calls)
--
2.37.1
More information about the kexec
mailing list