[PATCH v2 09/13] notifier: Show function names on notifier routines if DEBUG_NOTIFIERS is set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
Cc: Cong Wang <xiyou.wangcong@xxxxxxxxx>
Cc: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Valentin Schneider <valentin.schneider@xxxxxxx>
Cc: Xiaoming Ni <nixiaoming@xxxxxxxxxx>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@xxxxxxxxxx>

---

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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux