[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220719195325.402745-10-gpiccoli@igalia.com>
Date: Tue, 19 Jul 2022 16:53:22 -0300
From: "Guilherme G. Piccoli" <gpiccoli@...lia.com>
To: akpm@...ux-foundation.org, bhe@...hat.com, pmladek@...e.com,
kexec@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org, linux-hyperv@...r.kernel.org,
netdev@...r.kernel.org, x86@...nel.org, kernel-dev@...lia.com,
kernel@...ccoli.net, halves@...onical.com, fabiomirmar@...il.com,
alejandro.j.jimenez@...cle.com, andriy.shevchenko@...ux.intel.com,
arnd@...db.de, bp@...en8.de, corbet@....net,
d.hatayama@...fujitsu.com, dave.hansen@...ux.intel.com,
dyoung@...hat.com, feng.tang@...el.com, gregkh@...uxfoundation.org,
mikelley@...rosoft.com, hidehiro.kawai.ez@...achi.com,
jgross@...e.com, john.ogness@...utronix.de, keescook@...omium.org,
luto@...nel.org, mhiramat@...nel.org, mingo@...hat.com,
paulmck@...nel.org, peterz@...radead.org, rostedt@...dmis.org,
senozhatsky@...omium.org, stern@...land.harvard.edu,
tglx@...utronix.de, vgoyal@...hat.com, vkuznets@...hat.com,
will@...nel.org, "Guilherme G. Piccoli" <gpiccoli@...lia.com>,
Arjan van de Ven <arjan@...ux.intel.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Valentin Schneider <valentin.schneider@....com>,
Xiaoming Ni <nixiaoming@...wei.com>
Subject: [PATCH v2 09/13] notifier: Show function names on notifier routines if DEBUG_NOTIFIERS is set
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@...ux.intel.com>
Cc: Cong Wang <xiyou.wangcong@...il.com>
Cc: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Valentin Schneider <valentin.schneider@....com>
Cc: Xiaoming Ni <nixiaoming@...wei.com>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@...lia.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
Powered by blists - more mailing lists