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
Unified · Split
| @@ -16,9 +16,8 @@ · 15 unmodified lines | |||
| 16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
| 17 | #include <linux/kprobes.h> | 17 | #include <linux/kprobes.h> |
| 18 | 18 | ||
| 19 | #define MAX_SYMBOL_LEN 64 | 19 | static char symbol[KSYM_NAME_LEN] = "kernel_clone"; |
| 20 | static char symbol[MAX_SYMBOL_LEN] = "kernel_clone"; | 20 | module_param_string(symbol, symbol, KSYM_NAME_LEN, 0644); |
| 21 | module_param_string(symbol, symbol, sizeof(symbol), 0644); | ||
| 22 | 21 | ||
| 23 | /* For each probe you need to allocate a kprobe structure */ | 22 | /* For each probe you need to allocate a kprobe structure */ |
| 24 | static struct kprobe kp = { | 23 | static struct kprobe kp = { |
| @@ -23,11 +23,10 @@ · 22 unmodified lines | |||
| 23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
| 24 | #include <linux/kprobes.h> | 24 | #include <linux/kprobes.h> |
| 25 | #include <linux/ktime.h> | 25 | #include <linux/ktime.h> |
| 26 | #include <linux/limits.h> | ||
| 27 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
| 28 | 27 | ||
| 29 | static char func_name[NAME_MAX] = "kernel_clone"; | 28 | static char func_name[KSYM_NAME_LEN] = "kernel_clone"; |
| 30 | module_param_string(func, func_name, NAME_MAX, S_IRUGO); | 29 | module_param_string(func, func_name, KSYM_NAME_LEN, 0644); |
| 31 | MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the" | 30 | MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the" |
| 32 | " function's execution time"); | 31 | " function's execution time"); |
| 33 | 32 | ||