From patchwork Tue Mar 6 12:43:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10261581 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 E343C602C8 for ; Tue, 6 Mar 2018 12:43:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D449228A57 for ; Tue, 6 Mar 2018 12:43:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C91CD28E43; Tue, 6 Mar 2018 12:43:37 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 6C66028A57 for ; Tue, 6 Mar 2018 12:43:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 923CE6E6C2; Tue, 6 Mar 2018 12:43:36 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x22d.google.com (mail-wr0-x22d.google.com [IPv6:2a00:1450:400c:c0c::22d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 271EB6E6A4 for ; Tue, 6 Mar 2018 12:43:35 +0000 (UTC) Received: by mail-wr0-x22d.google.com with SMTP id o8so9284637wra.1 for ; Tue, 06 Mar 2018 04:43:35 -0800 (PST) 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=2uJmzBvAgsiH1UAeH7qgILS9chlGbPCIIdUr/zfNjSg=; b=p0e6ks+xJR4ubASsJ80+KYni1slQ1HTtFWJF8b06pIZQ1fXsFaLrDuvhZzqA1Eb15U M5CkQnoKvaICuhdeK4xkMQByyCSIDN9oYdG3Lo4G1iQztBjQk2270dKiIDwqug6S4Psu GCDOwBUnuWMGEMyq00Y7Bj2ZnYEp4OrNp6+1grmGuTcsicNbinmRkTFX8ubhCPudiJeL MKLl2rm9rXQ3lNIbSuuWXvnwactfFVAcQgUqBYuPDiibBL6NaU+OARTmPKKEBulyI5Ci z7Dcz5G664LDHbO52SNDxz9pVYxQHtstjgkCPUgxKVrYBJwtIRPaz/IKDW/p0eL+LVkZ YiJA== 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=2uJmzBvAgsiH1UAeH7qgILS9chlGbPCIIdUr/zfNjSg=; b=VtzWHrLjVnjjmaD42yaMwS3BzbOe6o1boUy7HOJgYYEPdUiSXYjoLmRQSTu/QYB7QE k7HWW94JkiNrOXFezIY092Bf8/+ETDN3bdZsoyGiS1hSRdSNxlGfvf4XJJjfLlq3J1aA 3OFwVeD2lvug3oFc8Tajn7Xh93KKUL7CU1Ys/Vc7nPa5GJlDR91nsjYAv36rFjyXCPp6 OBKL0anRK+1XrdRVlbTPkui4uIEO9jqfQs3i2KK08WOm2oBMgd2A5fkFz/8M6jgmtKL0 wb/McD1p4R4Wg8uAtVVlksl2J2lh25+I8D0uTloMDddHnoYHiEkxFmfUlnWR0pFZoK7B Dxig== X-Gm-Message-State: AElRT7EhWdaWqLCvSpbMO5EST8sukEPf1py/S9sB2+5gwxQwzeMcYlzQ 2PFcxHWxfeKTIWj0QfkIlxJyOA== X-Google-Smtp-Source: AG47ELtdaM4U4F+ZmbIjL+3wGDYx6dJk3TJyBfPYy+1eXc62YvKhoeu+pINtmiKSok/AnYPxmqF0Lw== X-Received: by 10.223.164.158 with SMTP id g30mr190169wrb.62.1520340213796; Tue, 06 Mar 2018 04:43:33 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id v8sm3646560wmh.25.2018.03.06.04.43.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 04:43:33 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Tue, 6 Mar 2018 12:43:14 +0000 Message-Id: <20180306124315.30208-11-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180306124315.30208-1-tvrtko.ursulin@linux.intel.com> References: <20180306124315.30208-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 10/11] 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 ff61dea0768d..4d1da98daa0d 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;