[PATCH v5 10/15] tools/lib/perf: use TASK_COMM_LEN_16 instead of hard-coded 16

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

 



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@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>
---
 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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux