Skip to content

Commit

Permalink
i915-perf: add a new HW->process tracking mechanism
Browse files Browse the repository at this point in the history
Right now we rely on the hw_id value from the data generated by the
GPU to match the i915_request_add tracepoint hw_id.

But starting with Gfx12 products, i915 started to delay hw_id picking
until the i915_request_in tracepoint.

This adds a 2 hops search to build the connection from i915-perf to
i915_request_in to finally i915_request_add to find out the process
that submitted the workload.

Also don't look too far back (1 second right now).
  • Loading branch information
llandwerlin-intel authored and mikesart committed Jul 7, 2021
1 parent 0eeb7f8 commit 18fe54e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/gpuvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ uint32_t TraceLocationsRingCtxSeq::get_i915_ringno( const trace_event_t &event,
return ( uint32_t )-1;
}

uint32_t TraceLocationsRingCtxSeq::get_i915_seqno( const trace_event_t &event )
{
const char *seqno_str = get_event_field_val( event, "seqno", NULL );

if ( seqno_str )
return strtoul( seqno_str, NULL, 10 );

return ( uint32_t )-1;
}

uint32_t TraceLocationsRingCtxSeq::get_i915_hw_id( const trace_event_t &event)
{
if ( event.seqno )
Expand Down Expand Up @@ -2258,6 +2268,34 @@ void TraceEvents::init_i915_perf_event( trace_event_t &event )
{
const trace_event_t &req_event = m_events[ event.id - i ];

// If we can't find a request within a second before this event,
// give up.
if ( ( event.ts - req_event.ts ) >= NSECS_PER_SEC )
break;

if ( !strcmp ( req_event.name, "i915_request_in" ) &&
TraceLocationsRingCtxSeq::get_i915_hw_id( req_event ) == ( uint32_t )event.pid )
{
bool process_found = false;

for ( uint32_t j = 1; j <= req_event.id; j++ )
{
const uint32_t seqno = TraceLocationsRingCtxSeq::get_i915_seqno( req_event );
const trace_event_t &add_event = m_events[ req_event.id - j ];

if ( !strcmp ( add_event.name, "i915_request_add" ) &&
TraceLocationsRingCtxSeq::get_i915_seqno( add_event ) == seqno )
{
m_i915.perf_to_req_in.m_map[ event.id ] = add_event.id;
process_found = true;
break;
}
}

if (process_found)
break;
}

if ( !strcmp ( req_event.name, "i915_request_add" ) &&
TraceLocationsRingCtxSeq::get_i915_hw_id( req_event ) == ( uint32_t )event.pid )
{
Expand Down
1 change: 1 addition & 0 deletions src/gpuvis.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class TraceLocationsRingCtxSeq

static uint32_t get_i915_ringno( const trace_event_t &event, bool *is_class_instance = nullptr );
static uint32_t get_i915_hw_id( const trace_event_t &event);
static uint32_t get_i915_seqno( const trace_event_t &event );

public:
// Map of db_key to array of event locations.
Expand Down

0 comments on commit 18fe54e

Please sign in to comment.