diff mbox series

drm/amdgpu: adjust the pid in the grab_id trace point

Message ID 20200807133658.1866-2-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series drm/amdgpu: adjust the pid in the grab_id trace point | expand

Commit Message

Christian König Aug. 7, 2020, 1:36 p.m. UTC
Trace something useful instead of the pid of a kernel thread here.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Steven Rostedt Aug. 12, 2020, 2:17 p.m. UTC | #1
On Fri, Aug 07, 2020 at 03:36:58PM +0200, Christian König wrote:
> Trace something useful instead of the pid of a kernel thread here.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
> index 5da20fc166d9..07f99ef69d91 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
> @@ -228,6 +228,7 @@ TRACE_EVENT(amdgpu_vm_grab_id,
>  			     ),
>  
>  	    TP_fast_assign(
> +			   __entry->ent.pid = vm->task_info.pid;

If the ent.pid is not the pid you are interested in for this trace event, just
add a "pid" field to the trace event and place it there. Do not modify the
generic pid that is recorded, as we would like that to be consistent for all
trace events.

The "ent.pid" turns into "common_pid" in the field, leaving "pid" free to use.
Other trace events (like sched_waking) record a pid field that is not the same
as the pid of the executing task.

The "ent.pid" should always be the pid of the task that executed the event.

-- Steve


>  			   __entry->pasid = vm->pasid;
>  			   __assign_str(ring, ring->name)
>  			   __entry->vmid = job->vmid;
> -- 
> 2.17.1
Christian König Aug. 12, 2020, 2:36 p.m. UTC | #2
Am 12.08.20 um 16:17 schrieb Steven Rostedt:
> On Fri, Aug 07, 2020 at 03:36:58PM +0200, Christian König wrote:
>> Trace something useful instead of the pid of a kernel thread here.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
>> index 5da20fc166d9..07f99ef69d91 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
>> @@ -228,6 +228,7 @@ TRACE_EVENT(amdgpu_vm_grab_id,
>>   			     ),
>>   
>>   	    TP_fast_assign(
>> +			   __entry->ent.pid = vm->task_info.pid;
> If the ent.pid is not the pid you are interested in for this trace event, just
> add a "pid" field to the trace event and place it there. Do not modify the
> generic pid that is recorded, as we would like that to be consistent for all
> trace events.

The problem my userspace guys have is that this doesn't work with 
"trace-cmd -P $pid".

But I think I can teach them how filters work :)

> The "ent.pid" turns into "common_pid" in the field, leaving "pid" free to use.
> Other trace events (like sched_waking) record a pid field that is not the same
> as the pid of the executing task.

Yes, we thought about this alternative as well.

> The "ent.pid" should always be the pid of the task that executed the event.

Why? For the case here we just execute a work item in the background for 
an userspace process.

Tracing the pid of the worker pool which executes it doesn't seem to 
make to much sense.

Thanks for the quick reply,
Christian.

>
> -- Steve
>
>
>>   			   __entry->pasid = vm->pasid;
>>   			   __assign_str(ring, ring->name)
>>   			   __entry->vmid = job->vmid;
>> -- 
>> 2.17.1
Steven Rostedt Aug. 12, 2020, 3:19 p.m. UTC | #3
On Wed, 12 Aug 2020 16:36:36 +0200
Christian König <ckoenig.leichtzumerken@gmail.com> wrote:

> Am 12.08.20 um 16:17 schrieb Steven Rostedt:
> > On Fri, Aug 07, 2020 at 03:36:58PM +0200, Christian König wrote:  
> >> Trace something useful instead of the pid of a kernel thread here.
> >>
> >> Signed-off-by: Christian König <christian.koenig@amd.com>
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 1 +
> >>   1 file changed, 1 insertion(+)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
> >> index 5da20fc166d9..07f99ef69d91 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
> >> @@ -228,6 +228,7 @@ TRACE_EVENT(amdgpu_vm_grab_id,
> >>   			     ),
> >>   
> >>   	    TP_fast_assign(
> >> +			   __entry->ent.pid = vm->task_info.pid;  
> > If the ent.pid is not the pid you are interested in for this trace event, just
> > add a "pid" field to the trace event and place it there. Do not modify the
> > generic pid that is recorded, as we would like that to be consistent for all
> > trace events.  
> 
> The problem my userspace guys have is that this doesn't work with 
> "trace-cmd -P $pid".
> 
> But I think I can teach them how filters work :)

Yep, trace-cmd record -e event -f "pid == $pid"

> 
> > The "ent.pid" turns into "common_pid" in the field, leaving "pid" free to use.
> > Other trace events (like sched_waking) record a pid field that is not the same
> > as the pid of the executing task.  
> 
> Yes, we thought about this alternative as well.
> 
> > The "ent.pid" should always be the pid of the task that executed the event.  
> 
> Why? For the case here we just execute a work item in the background for 
> an userspace process.
> 
> Tracing the pid of the worker pool which executes it doesn't seem to 
> make to much sense.

Maybe not for you, but it does for me. All trace events show what
happened when it happened and who executed it. I like to see what
worker threads are executing. I may filter on the worker thread, and by
changing the ent.pid, I wont see what it is doing.

That said, I think I may add a feature to a trace evnt for a special filter
to say, "test field to the set_event_pid", and if it exists in that
file to include that event in the filtered trace. This would include
sched_waking trace events as well.

That way "trace-cmd record -P $pid" will still work for your case.

-- Steve
Christian König Aug. 12, 2020, 3:33 p.m. UTC | #4
Am 12.08.20 um 17:19 schrieb Steven Rostedt:
> On Wed, 12 Aug 2020 16:36:36 +0200
> Christian König <ckoenig.leichtzumerken@gmail.com> wrote:
>
>> Am 12.08.20 um 16:17 schrieb Steven Rostedt:
>>> On Fri, Aug 07, 2020 at 03:36:58PM +0200, Christian König wrote:
>>>> Trace something useful instead of the pid of a kernel thread here.
>>>>
>>>> Signed-off-by: Christian König <christian.koenig@amd.com>
>>>> ---
>>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 1 +
>>>>    1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
>>>> index 5da20fc166d9..07f99ef69d91 100644
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
>>>> @@ -228,6 +228,7 @@ TRACE_EVENT(amdgpu_vm_grab_id,
>>>>    			     ),
>>>>    
>>>>    	    TP_fast_assign(
>>>> +			   __entry->ent.pid = vm->task_info.pid;
>>> If the ent.pid is not the pid you are interested in for this trace event, just
>>> add a "pid" field to the trace event and place it there. Do not modify the
>>> generic pid that is recorded, as we would like that to be consistent for all
>>> trace events.
>> The problem my userspace guys have is that this doesn't work with
>> "trace-cmd -P $pid".
>>
>> But I think I can teach them how filters work :)
> Yep, trace-cmd record -e event -f "pid == $pid"
>
>>> The "ent.pid" turns into "common_pid" in the field, leaving "pid" free to use.
>>> Other trace events (like sched_waking) record a pid field that is not the same
>>> as the pid of the executing task.
>> Yes, we thought about this alternative as well.
>>
>>> The "ent.pid" should always be the pid of the task that executed the event.
>> Why? For the case here we just execute a work item in the background for
>> an userspace process.
>>
>> Tracing the pid of the worker pool which executes it doesn't seem to
>> make to much sense.
> Maybe not for you, but it does for me. All trace events show what
> happened when it happened and who executed it. I like to see what
> worker threads are executing. I may filter on the worker thread, and by
> changing the ent.pid, I wont see what it is doing.

That's enough explanation for me. Going with the separate pid field then.

Thanks,
Christian.

>
> That said, I think I may add a feature to a trace evnt for a special filter
> to say, "test field to the set_event_pid", and if it exists in that
> file to include that event in the filtered trace. This would include
> sched_waking trace events as well.
>
> That way "trace-cmd record -P $pid" will still work for your case.
>
> -- Steve
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
index 5da20fc166d9..07f99ef69d91 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
@@ -228,6 +228,7 @@  TRACE_EVENT(amdgpu_vm_grab_id,
 			     ),
 
 	    TP_fast_assign(
+			   __entry->ent.pid = vm->task_info.pid;
 			   __entry->pasid = vm->pasid;
 			   __assign_str(ring, ring->name)
 			   __entry->vmid = job->vmid;