diff mbox

[i-g-t] scripts/trace.pl: Rudimentary preemption support

Message ID 20171220102121.17914-1-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tvrtko Ursulin Dec. 20, 2017, 10:21 a.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Make the script survive preemption by simply forgetting the previous
request_in event happened.

Downside of the trivial approach is that the timeline will not show
the preemption event, but it will be as if the request only got
submitted to the hardware for the first time when it was submitted
the final time, the time it actually ran to completion.

Runnable time accounting will also be over-accounted.

To solve this properly heavier refactoring is needed, and some design
thought, but for the moment this at least makes the script not die.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: John Harrison <John.C.Harrison@intel.com>
---
 scripts/trace.pl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/scripts/trace.pl b/scripts/trace.pl
index 2628a41abfc4..879e02365f34 100755
--- a/scripts/trace.pl
+++ b/scripts/trace.pl
@@ -423,7 +423,9 @@  while (<>) {
 	} elsif ($tp_name eq 'i915:i915_gem_request_in:') {
 		my %req;
 
-		die if exists $db{$key};
+		# Duplicated req in is a sign of preemption - just forget it
+		# happened before.
+		delete $db{$key} if exists $db{$key};
 		die unless exists $queue{$key};
 		die unless exists $submit{$key};
 
@@ -443,7 +445,8 @@  while (<>) {
 	} elsif ($tp_name eq 'i915:i915_gem_request_out:') {
 		my $gkey = global_key($ring, $tp{'global'});
 
-		die unless exists $db{$key};
+# 		# Probable incomplete trace, not gathered with trace.pl --trace.
+		next unless exists $db{$key};
 		die unless exists $db{$key}->{'start'};
 		die if exists $db{$key}->{'end'};