[PATCH 2/2] tracing: Align task.h to use __assing_str for strings.

From: Peter Enderborg
Date: Fri Apr 30 2021 - 10:23:03 EST


This moves the comm strings to use the tracing string functions
instead of char arrays so they all work in the same way.

Signed-off-by: Peter Enderborg <peter.enderborg@xxxxxxxx>
---
include/trace/events/task.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/trace/events/task.h b/include/trace/events/task.h
index 2e977d2935e1..2bd314e60cb6 100644
--- a/include/trace/events/task.h
+++ b/include/trace/events/task.h
@@ -14,20 +14,20 @@ TRACE_EVENT(task_newtask,

TP_STRUCT__entry(
__field( pid_t, pid)
- __array( char, comm, TASK_COMM_LEN)
+ __string(comm, task->comm)
__field( unsigned long, clone_flags)
__field( short, oom_score_adj)
),

TP_fast_assign(
__entry->pid = task->pid;
- memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
+ __assign_str(comm, task->comm);
__entry->clone_flags = clone_flags;
__entry->oom_score_adj = task->signal->oom_score_adj;
),

TP_printk("pid=%d comm=%s clone_flags=%lx oom_score_adj=%hd",
- __entry->pid, __entry->comm,
+ __entry->pid, __get_str(comm),
__entry->clone_flags, __entry->oom_score_adj)
);

@@ -39,21 +39,21 @@ TRACE_EVENT(task_rename,

TP_STRUCT__entry(
__field( pid_t, pid)
- __array( char, oldcomm, TASK_COMM_LEN)
- __array( char, newcomm, TASK_COMM_LEN)
+ __string(oldcomm, task->comm)
+ __string(newcomm, comm)
__field( short, oom_score_adj)
),

TP_fast_assign(
__entry->pid = task->pid;
- memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN);
- strlcpy(entry->newcomm, comm, TASK_COMM_LEN);
+ __assign_str(oldcomm, task->comm);
+ __assign_str(newcomm, comm);
__entry->oom_score_adj = task->signal->oom_score_adj;
),

TP_printk("pid=%d oldcomm=%s newcomm=%s oom_score_adj=%hd",
- __entry->pid, __entry->oldcomm,
- __entry->newcomm, __entry->oom_score_adj)
+ __entry->pid, __get_str(oldcomm),
+ __get_str(newcomm), __entry->oom_score_adj)
);

TRACE_EVENT(task_exit,
--
2.17.1