lkml.org 
[lkml]   [2021]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v5 10/15] tools/lib/perf: use TASK_COMM_LEN_16 instead of hard-coded 16
Date
Use TASK_COMM_LEN_16 instead of hard-coded 16 to make it more grepable.
The comm is set in perf_event__prepare_comm(), which makes the comm
always a nul terminated string, so we don't worry about whether it will
be truncated or not.

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>
---
tools/lib/perf/include/perf/event.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h
index 4d0c02ba3f7d..ab22b4e570c6 100644
--- a/tools/lib/perf/include/perf/event.h
+++ b/tools/lib/perf/include/perf/event.h
@@ -6,6 +6,7 @@
#include <linux/types.h>
#include <linux/limits.h>
#include <linux/bpf.h>
+#include <linux/sched/task.h>
#include <sys/types.h> /* pid_t */

#define event_contains(obj, mem) ((obj).header.size > offsetof(typeof(obj), mem))
@@ -47,7 +48,7 @@ struct perf_record_mmap2 {
struct perf_record_comm {
struct perf_event_header header;
__u32 pid, tid;
- char comm[16];
+ char comm[TASK_COMM_LEN_16];
};

struct perf_record_namespaces {
@@ -291,7 +292,7 @@ struct perf_record_itrace_start {

struct perf_record_thread_map_entry {
__u64 pid;
- char comm[16];
+ char comm[TASK_COMM_LEN_16];
};

struct perf_record_thread_map {
--
2.17.1
\
 
 \ /
  Last update: 2021-10-21 05:48    [W:0.081 / U:1.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site