From patchwork Mon Apr 23 09:52:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10356529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA3ED60225 for ; Mon, 23 Apr 2018 09:53:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA07528A03 for ; Mon, 23 Apr 2018 09:53:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEE2A28A0B; Mon, 23 Apr 2018 09:53:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 60DEA28A03 for ; Mon, 23 Apr 2018 09:53:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D06BF6E1AA; Mon, 23 Apr 2018 09:53:18 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x233.google.com (mail-wr0-x233.google.com [IPv6:2a00:1450:400c:c0c::233]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE7DB6E18B for ; Mon, 23 Apr 2018 09:53:09 +0000 (UTC) Received: by mail-wr0-x233.google.com with SMTP id z73-v6so39456816wrb.0 for ; Mon, 23 Apr 2018 02:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SNOml+5V0ooGwXcAXWpNFqnQbiqxs4W4Ya1nAQZBJS0=; b=VaPiIwoUk/NyoR4SmIO6MZkvcktnche/gVIfS6GzqtK23HzhLUhzNIBpcNSljZ3nXd git47aiA7biNt8IROoBx9eFvozW3QeaKzu4juiarw/sT2J61T9zhf0TTEDHaiTq9+WeX aY5+U4noXVNm75sq4Z50/o0oKNC5FPsMAX1ecsm9SkGgGBwMWzxRzRZYwW5m47pl8VM7 hCTR8znFxbNLUJOx1kW4CrdhO8CSnIzNT+ugZsH4vFmUGO0+kw2s5Gwbf6pQJr5vfWKt dx0dHQPfRAMK89zHCPYDxXL+XvT3hWb3g5KVXKgQw3TN185rJYwj2QR6rKd+eYJAfcjT M1hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SNOml+5V0ooGwXcAXWpNFqnQbiqxs4W4Ya1nAQZBJS0=; b=Lcrra7hjPgeoN5G7d94uX3KVQD3qr6blH/CG4kGZ8RDW3uJ7PAedJ05Rt5BaKntH2z qJ/7+O45SXXG3DC8iiZ7QELWUZbKOYaELoQE3EHJPCUJR/+zFv3aM14c4JCmDgSZ3dIE D/REiObvqcjD0Q6ZjBZaVSH9aFexLEOCsqHCPZu9wCuLikqE2ai33QOw23nQEQF0Fm3D q68vNATs1rPeNb4qRmuM5nTsnFcvVJ/81/0vIJIokcmxTiEy8qS02bBoCh2RP4sG5SlJ tqta/EDZIjArUf2/Nyf4NolCzrezzsjdrGUXSG5qFb2iKeYx7FcnJ8BJUiS0E9mquM+0 Yzog== X-Gm-Message-State: ALQs6tBOCo0DjsQBhti7ijxFspePGQMSZ4gf1YWlaF0f+PHtTFyHFoah PjBHs57/kVG3MQ9wIoES4b7niA== X-Google-Smtp-Source: AIpwx4/9IkD9KKrjPno7lp4JJS6RmrX7yC3D18Hz+TM2+KzIIlTwKMQ2jfbfDDo58BxH9YY1jbzong== X-Received: by 2002:adf:9205:: with SMTP id 5-v6mr16959676wrj.282.1524477188373; Mon, 23 Apr 2018 02:53:08 -0700 (PDT) Received: from localhost.localdomain ([95.146.151.144]) by smtp.gmail.com with ESMTPSA id j76sm20918590wmf.33.2018.04.23.02.53.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 02:53:07 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Mon, 23 Apr 2018 10:52:37 +0100 Message-Id: <20180423095238.29238-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180423095238.29238-1-tvrtko.ursulin@linux.intel.com> References: <20180423095238.29238-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/4] trace.pl: Fix incomplete request handling X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Incomplete requests (no notify, no context complete) have to be corrected by looking at the engine timeline, and not the sorted-by-start-time view as was previously used. Per-engine timelines are generated on demand and cached for later use. v2: Find end of current context on the engine timeline instead of just using the next request for adjusting the incomplete start time. Signed-off-by: Tvrtko Ursulin Cc: John Harrison --- scripts/trace.pl | 86 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/scripts/trace.pl b/scripts/trace.pl index eb5a36b91a5c..b48f43225fc1 100755 --- a/scripts/trace.pl +++ b/scripts/trace.pl @@ -26,6 +26,8 @@ use strict; use warnings; use 5.010; +use List::Util; + my $gid = 0; my (%db, %queue, %submit, %notify, %rings, %ctxdb, %ringmap, %reqwait); my @freqs; @@ -516,29 +518,71 @@ foreach my $key (keys %db) { } } -# Fix up incompletes my $key_count = scalar(keys %db); -foreach my $key (keys %db) { - next unless exists $db{$key}->{'incomplete'}; - # End the incomplete batch at the time next one starts - my $ring = $db{$key}->{'ring'}; - my $ctx = $db{$key}->{'ctx'}; - my $seqno = $db{$key}->{'seqno'}; - my $next_key; - my $i = 1; +my %engine_timelines; + +sub sortEngine { + my $as = $db{$a}->{'global'}; + my $bs = $db{$b}->{'global'}; + my $val; + + $val = $as <=> $bs; + + die if $val == 0; + + return $val; +} + +sub get_engine_timeline { + my ($ring) = @_; + my @timeline; + + return $engine_timelines{$ring} if exists $engine_timelines{$ring}; + + @timeline = grep { $db{$_}->{'ring'} == $ring } keys %db; + # FIXME seqno restart + @timeline = sort sortEngine @timeline; + + $engine_timelines{$ring} = \@timeline; + + return \@timeline; +} + +# Fix up incompletes by ending them when the last request of a coalesced group +# ends. Start by filtering out the incomplete requests. +my @incompletes = sort grep { exists $db{$_}->{'incomplete'} } keys %db; + +foreach my $key (@incompletes) { + my $timeline; + my $last_key; my $end; + my $i; - do { - $next_key = db_key($ring, $ctx, $seqno + $i); - $i++; - } until ((exists $db{$next_key} and not exists $db{$next_key}->{'incomplete'}) - or $i > $key_count); # ugly stop hack + # Find the next request on the engine timeline. + $timeline = get_engine_timeline($db{$key}->{'ring'}); + $i = List::Util::first { ${$timeline}[$_] eq $key } 0..$#{$timeline}; + + while ($i < $#{$timeline}) { + my $next; + + $i = $i + 1; + $next = ${$timeline}[$i]; + + next if exists $db{$next}->{'incomplete'}; - if (exists $db{$next_key}) { - $end = $db{$next_key}->{'end'}; + $last_key = $next; + last; + } + + if (defined $last_key) { + if ($db{$key}->{'ctx'} eq $db{$last_key}->{'ctx'}) { + $end = $db{$last_key}->{'end'}; + } else { + $end = $db{$last_key}->{'start'}; + } } else { - # No info at all, fake it: + # No next submission, fake it. $end = $db{$key}->{'start'} + 999; } @@ -546,10 +590,6 @@ foreach my $key (keys %db) { $db{$key}->{'end'} = $end; } -# GPU time accounting -my (%running, %runnable, %queued, %batch_avg, %batch_total_avg, %batch_count); -my (%submit_avg, %execute_avg, %ctxsave_avg); - sub sortStart { my $as = $db{$a}->{'start'}; my $bs = $db{$b}->{'start'}; @@ -597,6 +637,10 @@ foreach my $key (@sorted_keys) { @sorted_keys = sort sortStart keys %db if $re_sort; +# GPU time accounting +my (%running, %runnable, %queued, %batch_avg, %batch_total_avg, %batch_count); +my (%submit_avg, %execute_avg, %ctxsave_avg); + my $last_ts = 0; my $first_ts; my ($min_ctx, $max_ctx);