diff mbox series

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

Message ID 20211021034516.4400-9-laoar.shao@gmail.com (mailing list archive)
State Not Applicable
Delegated to: BPF
Headers show
Series extend task comm from 16 to 24 for CONFIG_BASE_FULL | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch
bpf/vmtest-bpf-next-PR fail merge-conflict
bpf/vmtest-bpf success VM_Test
bpf/vmtest-bpf-PR success PR summary

Commit Message

Yafang Shao Oct. 21, 2021, 3:45 a.m. UTC
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@gmail.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Petr Mladek <pmladek@suse.com>
---
 samples/bpf/offwaketime_user.c | 6 +++---
 samples/bpf/tracex2_user.c     | 7 ++++---
 2 files changed, 7 insertions(+), 6 deletions(-)
diff mbox series

Patch

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;
 };