Skip to contentSkip to conversation

trace/kprobe: Display the actual notrace function when rejecting a probe

PATCH In review Naveen N Rao 2 participants 2 messages Dec 14, 2023 – Dec 17, 2023 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 trace/kprobe: Display the actual notrace function when rejecting a probe

Trying to probe update_sd_lb_stats() using perf results in the below message in the kernel log:
trace_kprobe: Could not probe notrace function _text

This is because 'perf probe' specifies the kprobe location as an offset from '_text':

	$ sudo perf probe -D update_sd_lb_stats
	p:probe/update_sd_lb_stats _text+1830728

However, the error message is misleading and doesn't help convey the actual notrace function that is being probed. Fix this by looking up the actual function name that is being probed. With this fix, we now get the below message in the kernel log:
trace_kprobe: Could not probe notrace function update_sd_lb_stats.constprop.0

---
v4: Use printk format specifier %ps with probe address to lookup the symbol, as suggested by Masami.

 kernel/trace/trace_kprobe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_kprobe.c +2 -2
index 3d7a180a8427..0017404d6e8d 100644
@@ -487,8 +487,8 @@ static int __register_trace_kprobe(struct trace_kprobe *tk)
 		return -EINVAL;
 
 	if (within_notrace_func(tk)) {
-		pr_warn("Could not probe notrace function %s\n",
-			trace_kprobe_symbol(tk));
+		pr_warn("Could not probe notrace function %ps\n",
+			(void *)trace_kprobe_address(tk));
 		return -EINVAL;
 	}
 

base-commit: 4758560fa268cecfa1144f015aa9f2525d164b7e

Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · On Thu, 14 Dec 2023 10:47:02 +0530 Naveen N Rao <[email protected]> wrote:

Trying to probe update_sd_lb_stats() using perf results in the below message in the kernel log:
trace_kprobe: Could not probe notrace function _text

This is because 'perf probe' specifies the kprobe location as an offset from '_text':

Quoted 9 lines
	$ sudo perf probe -D update_sd_lb_stats
	p:probe/update_sd_lb_stats _text+1830728

However, the error message is misleading and doesn't help convey the actual notrace function that is being probed. Fix this by looking up the actual function name that is being probed. With this fix, we now get the below message in the kernel log:
trace_kprobe: Could not probe notrace function update_sd_lb_stats.constprop.0

OK, this looks good to me. let me pick this.

Thank you!

Quoted 28 lines

---
v4: Use printk format specifier %ps with probe address to lookup the symbol, as suggested by Masami.

 kernel/trace/trace_kprobe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_kprobe.c +2 -2
index 3d7a180a8427..0017404d6e8d 100644
@@ -487,8 +487,8 @@ static int __register_trace_kprobe(struct trace_kprobe *tk)
 		return -EINVAL;
 
 	if (within_notrace_func(tk)) {
-		pr_warn("Could not probe notrace function %s\n",
-			trace_kprobe_symbol(tk));
+		pr_warn("Could not probe notrace function %ps\n",
+			(void *)trace_kprobe_address(tk));
 		return -EINVAL;
 	}
 

base-commit: 4758560fa268cecfa1144f015aa9f2525d164b7e

Signature · 1 line
2.43.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>