[PATCH v5 08/15] samples/bpf/user: use TASK_COMM_LEN_16 instead of hard-coded 16

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The task comm size is invisible to the bpf userspace, we have to
define a new TASK_COMM_LEN_16 in the userspace. Use this macro instead
of the hard-coded 16 can make it more grepable.

Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx>
Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@xxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Kees Cook <keescook@xxxxxxxxxxxx>
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Petr Mladek <pmladek@xxxxxxxx>
---
 samples/bpf/offwaketime_user.c | 6 +++---
 samples/bpf/tracex2_user.c     | 7 ++++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/samples/bpf/offwaketime_user.c b/samples/bpf/offwaketime_user.c
index 73a986876c1a..ca918ac93ee7 100644
--- a/samples/bpf/offwaketime_user.c
+++ b/samples/bpf/offwaketime_user.c
@@ -36,11 +36,11 @@ static void print_ksym(__u64 addr)
 		printf("%s;", sym->name);
 }
 
-#define TASK_COMM_LEN 16
+#define TASK_COMM_LEN_16 16
 
 struct key_t {
-	char waker[TASK_COMM_LEN];
-	char target[TASK_COMM_LEN];
+	char waker[TASK_COMM_LEN_16];
+	char target[TASK_COMM_LEN_16];
 	__u32 wret;
 	__u32 tret;
 };
diff --git a/samples/bpf/tracex2_user.c b/samples/bpf/tracex2_user.c
index 1626d51dfffd..70081d917c6d 100644
--- a/samples/bpf/tracex2_user.c
+++ b/samples/bpf/tracex2_user.c
@@ -10,8 +10,9 @@
 #include <bpf/libbpf.h>
 #include "bpf_util.h"
 
-#define MAX_INDEX	64
-#define MAX_STARS	38
+#define MAX_INDEX		64
+#define MAX_STARS		38
+#define TASK_COMM_LEN_16	16
 
 /* my_map, my_hist_map */
 static int map_fd[2];
@@ -28,7 +29,7 @@ static void stars(char *str, long val, long max, int width)
 }
 
 struct task {
-	char comm[16];
+	char comm[TASK_COMM_LEN_16];
 	__u64 pid_tgid;
 	__u64 uid_gid;
 };
-- 
2.17.1




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux