]> git.baikalelectronics.ru Git - kernel.git/commitdiff
samples: Use KSYM_NAME_LEN for kprobes
authorTiezhu Yang <yangtiezhu@loongson.cn>
Wed, 8 Jun 2022 01:23:22 +0000 (09:23 +0800)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 12 Jul 2022 20:36:45 +0000 (16:36 -0400)
It is better and enough to use KSYM_NAME_LEN for kprobes
in samples, no need to define and use the other values.

Link: https://lkml.kernel.org/r/1654651402-21552-1-git-send-email-yangtiezhu@loongson.cn
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
samples/kprobes/kprobe_example.c
samples/kprobes/kretprobe_example.c

index f991a66b5b022a83c789d544b43a9be89be5a172..fd346f58ddbaf10889d3de29fd7399cd90a94258 100644 (file)
@@ -16,9 +16,8 @@
 #include <linux/module.h>
 #include <linux/kprobes.h>
 
-#define MAX_SYMBOL_LEN 64
-static char symbol[MAX_SYMBOL_LEN] = "kernel_clone";
-module_param_string(symbol, symbol, sizeof(symbol), 0644);
+static char symbol[KSYM_NAME_LEN] = "kernel_clone";
+module_param_string(symbol, symbol, KSYM_NAME_LEN, 0644);
 
 /* For each probe you need to allocate a kprobe structure */
 static struct kprobe kp = {
index 228321ecb16168e1a61311dda0e7deb783d5dd9c..cbf16542d84e7c1527629de66adb7f5ec057ec62 100644 (file)
 #include <linux/module.h>
 #include <linux/kprobes.h>
 #include <linux/ktime.h>
-#include <linux/limits.h>
 #include <linux/sched.h>
 
-static char func_name[NAME_MAX] = "kernel_clone";
-module_param_string(func, func_name, NAME_MAX, S_IRUGO);
+static char func_name[KSYM_NAME_LEN] = "kernel_clone";
+module_param_string(func, func_name, KSYM_NAME_LEN, 0644);
 MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the"
                        " function's execution time");