hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/samples/kprobes/kretprobe_example.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * kretprobe_example.c
34 *
....@@ -7,10 +8,10 @@
78 *
89 * usage: insmod kretprobe_example.ko func=<func_name>
910 *
10
- * If no func_name is specified, _do_fork is instrumented
11
+ * If no func_name is specified, kernel_clone is instrumented
1112 *
1213 * For more information on theory of operation of kretprobes, see
13
- * Documentation/kprobes.txt
14
+ * Documentation/trace/kprobes.rst
1415 *
1516 * Build and insert the kernel module as done in the kprobe example.
1617 * You will see the trace data in /var/log/messages and on the console
....@@ -25,7 +26,7 @@
2526 #include <linux/limits.h>
2627 #include <linux/sched.h>
2728
28
-static char func_name[NAME_MAX] = "_do_fork";
29
+static char func_name[NAME_MAX] = "kernel_clone";
2930 module_param_string(func, func_name, NAME_MAX, S_IRUGO);
3031 MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the"
3132 " function's execution time");
....@@ -47,6 +48,7 @@
4748 data->entry_stamp = ktime_get();
4849 return 0;
4950 }
51
+NOKPROBE_SYMBOL(entry_handler);
5052
5153 /*
5254 * Return-probe handler: Log the return value and duration. Duration may turn
....@@ -66,6 +68,7 @@
6668 func_name, retval, (long long)delta);
6769 return 0;
6870 }
71
+NOKPROBE_SYMBOL(ret_handler);
6972
7073 static struct kretprobe my_kretprobe = {
7174 .handler = ret_handler,