History

samples: Use KSYM_NAME_LEN for kprobes

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

Tiezhu Yang committed 4 years ago

Commit 1e1fb421 parent e3655df2 files · +4 −6Browse files

Unified · Split

2 files
  1. samples/kprobes/kprobe_example.c +2 −3
  2. samples/kprobes/kretprobe_example.c +2 −3
samples/kprobes/kprobe_example.c+2−3
@@ -16,9 +16,8 @@ · 15 unmodified lines
1616 #include <linux/module.h>
1717 #include <linux/kprobes.h>
1818
19−#define MAX_SYMBOL_LEN 64
20−static char symbol[MAX_SYMBOL_LEN] = "kernel_clone";
21−module_param_string(symbol, symbol, sizeof(symbol), 0644);
19+static char symbol[KSYM_NAME_LEN] = "kernel_clone";
20+module_param_string(symbol, symbol, KSYM_NAME_LEN, 0644);
2221
2322 /* For each probe you need to allocate a kprobe structure */
2423 static struct kprobe kp = {
samples/kprobes/kretprobe_example.c+2−3
@@ -23,11 +23,10 @@ · 22 unmodified lines
2323 #include <linux/module.h>
2424 #include <linux/kprobes.h>
2525 #include <linux/ktime.h>
26−#include <linux/limits.h>
2726 #include <linux/sched.h>
2827
29−static char func_name[NAME_MAX] = "kernel_clone";
30−module_param_string(func, func_name, NAME_MAX, S_IRUGO);
28+static char func_name[KSYM_NAME_LEN] = "kernel_clone";
29+module_param_string(func, func_name, KSYM_NAME_LEN, 0644);
3130 MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the"
3231 " function's execution time");
3332