Re: [PATCH 2/2] dmabuf/tracing: Add dma-buf trace events

From: Kalesh Singh
Date: Mon Aug 03 2020 - 12:33:41 EST


On Mon, Aug 03, 2020 at 11:32:39AM -0400, Steven Rostedt wrote:
> On Mon, 3 Aug 2020 14:47:19 +0000
> Kalesh Singh <kaleshsingh@xxxxxxxxxx> wrote:
>
> > +DECLARE_EVENT_CLASS(dma_buf_ref_template,
> > +
> > + TP_PROTO(struct task_struct *task, struct file *filp),
> > +
> > + TP_ARGS(task, filp),
> > +
> > + TP_STRUCT__entry(
> > + __field(u32, tgid)
> > + __field(u32, pid)
>
> I only see "current" passed in as "task". Why are you recording the pid
> and tgid as these are available by the tracing infrastructure.
>
> At least the pid is saved at every event. You can see the tgid when
> enabling the "record_tgid".
>
> # trace-cmd start -e all -O record_tgid
> # trace-cmd show
>
> # tracer: nop
> #
> # entries-in-buffer/entries-written: 39750/39750 #P:8
> #
> # _-----=> irqs-off
> # / _----=> need-resched
> # | / _---=> hardirq/softirq
> # || / _--=> preempt-depth
> # ||| / delay
> # TASK-PID TGID CPU# |||| TIMESTAMP FUNCTION
> # | | | | |||| | |
> trace-cmd-28284 (28284) [005] .... 240338.934671: sys_exit: NR 1 = 1
> kworker/3:2-27891 (27891) [003] d... 240338.934671: timer_start: timer=00000000d643debd function=delayed_work_timer_fn expires=4535008893 [timeout=1981] cpu=3 idx=186 flags=I
> trace-cmd-28284 (28284) [005] .... 240338.934672: sys_write -> 0x1
> kworker/3:2-27891 (27891) [003] .... 240338.934672: workqueue_execute_end: work struct 000000008fddd403: function psi_avgs_work
> kworker/3:2-27891 (27891) [003] .... 240338.934673: workqueue_execute_start: work struct 00000000111c941e: function dbs_work_handler
> kworker/3:2-27891 (27891) [003] .... 240338.934673: workqueue_execute_end: work struct 00000000111c941e: function dbs_work_handler
> kworker/3:2-27891 (27891) [003] d... 240338.934673: rcu_utilization: Start context switch
> kworker/3:2-27891 (27891) [003] d... 240338.934673: rcu_utilization: End context switch
>
> -- Steve
>
Thanks for the comments Steve. I'll remove the task arg.

> > + __field(u64, size)
> > + __field(s64, count)
> > + __string(exp_name, dma_buffer(filp)->exp_name)
> > + __string(name, dma_buffer(filp)->name ? dma_buffer(filp)->name : UNKNOWN)
> > + __field(u64, i_ino)
> > + ),
> > +
> > + TP_fast_assign(
> > + __entry->tgid = task->tgid;
> > + __entry->pid = task->pid;
> > + __entry->size = dma_buffer(filp)->size;
> > + __entry->count = file_count(filp);
> > + __assign_str(exp_name, dma_buffer(filp)->exp_name);
> > + __assign_str(name, dma_buffer(filp)->name ? dma_buffer(filp)->name : UNKNOWN);
> > + __entry->i_ino = filp->f_inode->i_ino;
> > + ),
> > +