[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211021034516.4400-9-laoar.shao@gmail.com>
Date: Thu, 21 Oct 2021 03:45:15 +0000
From: Yafang Shao <laoar.shao@...il.com>
To: keescook@...omium.org, rostedt@...dmis.org,
mathieu.desnoyers@...icios.com, arnaldo.melo@...il.com,
pmladek@...e.com, peterz@...radead.org, viro@...iv.linux.org.uk,
akpm@...ux-foundation.org, valentin.schneider@....com,
qiang.zhang@...driver.com, robdclark@...omium.org,
christian@...uner.io, dietmar.eggemann@....com, mingo@...hat.com,
juri.lelli@...hat.com, vincent.guittot@...aro.org,
davem@...emloft.net, kuba@...nel.org, ast@...nel.org,
daniel@...earbox.net, andrii@...nel.org, kafai@...com,
songliubraving@...com, yhs@...com, john.fastabend@...il.com,
kpsingh@...nel.org
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org,
linux-perf-users@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, oliver.sang@...el.com, lkp@...el.com,
Yafang Shao <laoar.shao@...il.com>
Subject: [PATCH v5 08/15] samples/bpf/user: use TASK_COMM_LEN_16 instead of hard-coded 16
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@...il.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Kees Cook <keescook@...omium.org>
Cc: Al Viro <viro@...iv.linux.org.uk>
Cc: Petr Mladek <pmladek@...e.com>
---
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
Powered by blists - more mailing lists