All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] samples: Use KSYM_NAME_LEN for kprobes
@ 2022-06-08  1:23 Tiezhu Yang
  2022-06-21 11:44 ` Tiezhu Yang
  2022-06-22  2:06 ` Masami Hiramatsu
  0 siblings, 2 replies; 3+ messages in thread
From: Tiezhu Yang @ 2022-06-08  1:23 UTC (permalink / raw)
  To: Masami Hiramatsu, Steven Rostedt; +Cc: Xuefeng Li, linux-kernel

It is better and enough to use KSYM_NAME_LEN for kprobes
in samples, no need to define and use the other values.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 samples/kprobes/kprobe_example.c    | 5 ++---
 samples/kprobes/kretprobe_example.c | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c
index f991a66..fd346f5 100644
--- a/samples/kprobes/kprobe_example.c
+++ b/samples/kprobes/kprobe_example.c
@@ -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 = {
diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprobe_example.c
index 228321e..cbf1654 100644
--- a/samples/kprobes/kretprobe_example.c
+++ b/samples/kprobes/kretprobe_example.c
@@ -23,11 +23,10 @@
 #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");
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] samples: Use KSYM_NAME_LEN for kprobes
  2022-06-08  1:23 [PATCH v2] samples: Use KSYM_NAME_LEN for kprobes Tiezhu Yang
@ 2022-06-21 11:44 ` Tiezhu Yang
  2022-06-22  2:06 ` Masami Hiramatsu
  1 sibling, 0 replies; 3+ messages in thread
From: Tiezhu Yang @ 2022-06-21 11:44 UTC (permalink / raw)
  To: yangtiezhu; +Cc: linux-kernel, lixuefeng, mhiramat, rostedt

Hi Masami,

Are you OK with this version?

[PATCH v2] samples: Use KSYM_NAME_LEN for kprobes
https://lore.kernel.org/lkml/1654651402-21552-1-git-send-email-yangtiezhu@loongson.cn/

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] samples: Use KSYM_NAME_LEN for kprobes
  2022-06-08  1:23 [PATCH v2] samples: Use KSYM_NAME_LEN for kprobes Tiezhu Yang
  2022-06-21 11:44 ` Tiezhu Yang
@ 2022-06-22  2:06 ` Masami Hiramatsu
  1 sibling, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2022-06-22  2:06 UTC (permalink / raw)
  To: Tiezhu Yang; +Cc: Steven Rostedt, Xuefeng Li, linux-kernel

Hi,

On Wed,  8 Jun 2022 09:23:22 +0800
Tiezhu Yang <yangtiezhu@loongson.cn> wrote:

> It is better and enough to use KSYM_NAME_LEN for kprobes
> in samples, no need to define and use the other values.

This looks good to me.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thank you!

> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  samples/kprobes/kprobe_example.c    | 5 ++---
>  samples/kprobes/kretprobe_example.c | 5 ++---
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c
> index f991a66..fd346f5 100644
> --- a/samples/kprobes/kprobe_example.c
> +++ b/samples/kprobes/kprobe_example.c
> @@ -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 = {
> diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprobe_example.c
> index 228321e..cbf1654 100644
> --- a/samples/kprobes/kretprobe_example.c
> +++ b/samples/kprobes/kretprobe_example.c
> @@ -23,11 +23,10 @@
>  #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");
>  
> -- 
> 2.1.0
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-22  2:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08  1:23 [PATCH v2] samples: Use KSYM_NAME_LEN for kprobes Tiezhu Yang
2022-06-21 11:44 ` Tiezhu Yang
2022-06-22  2:06 ` Masami Hiramatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.