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
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 6419static char symbol[KSYM_NAME_LEN] = "kernel_clone";
20static char symbol[MAX_SYMBOL_LEN] = "kernel_clone";20module_param_string(symbol, symbol, KSYM_NAME_LEN, 0644);
21module_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 */
24static struct kprobe kp = {23static struct kprobe kp = {
samples/kprobes/kretprobe_example.c+2−3
@@ -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
29static char func_name[NAME_MAX] = "kernel_clone";28static char func_name[KSYM_NAME_LEN] = "kernel_clone";
30module_param_string(func, func_name, NAME_MAX, S_IRUGO);29module_param_string(func, func_name, KSYM_NAME_LEN, 0644);
31MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the"30MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the"
32 " function's execution time");31 " function's execution time");
33 32