From patchwork Tue May 8 17:31:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10386687 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 02708602C2 for ; Tue, 8 May 2018 17:31:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E46AA28F83 for ; Tue, 8 May 2018 17:31:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D935A28F98; Tue, 8 May 2018 17:31:51 +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 7A31928F83 for ; Tue, 8 May 2018 17:31:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4ADED6EB17; Tue, 8 May 2018 17:31:50 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x22a.google.com (mail-wr0-x22a.google.com [IPv6:2a00:1450:400c:c0c::22a]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD0E96EB0A for ; Tue, 8 May 2018 17:31:45 +0000 (UTC) Received: by mail-wr0-x22a.google.com with SMTP id i14-v6so29956629wre.2 for ; Tue, 08 May 2018 10:31:45 -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=Xj2WOx3UBeglmnbZyQPMfvRQV5lwOxRhH53h+o/EpDM=; b=veeUH65ISNCbQlRXke8QRSsCAPLR1SqHFdz6asyuLuAud84WUnpKZMWf2N9TmLu5qL bfDeRHsxbg9BqogaCWvIhedY7SCAaE2fMoE7GEIMG8k4vxqFP7Rw8aXv2WsX/ejrPz7n busG+5pCzGprQYovd7hpTklHFemGoxbNAtQ6KFNsFjo3yrkXJZoNZrjNMiWSjgyN+/gt Hi+eARyLiFpQvsmXQOQ6ML3Hw1Dr2S6ycamIJz9O4wWHRmP1BYjhx7Zb677k8AUA9Yiw I8puIjerk5PCospgbjgxxliIuoFac0g+9/ctWKdm2mvo5LxDSCcyDqHFZVFZddm1caFW o+1A== 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=Xj2WOx3UBeglmnbZyQPMfvRQV5lwOxRhH53h+o/EpDM=; b=ri2INSsqFy2neP8sSZJS4rswNQfmPxDT6q1yxiK8A7t4gIz4nJ4/2dsYGYWjtm06OE L44/kP3fdIE15bOZiKwDzxyxbBFMbtZvrcDFk3p0+bu7vZhI7iYGWldwZSQIpPUHNGZe 38RkSwOOBgvGqedvIfEpJakv90dN6qviIIoAhRNWAPXwUX9U1mGKRV5hoSmCwkdZPwb6 75EhfJlvs01piNZ05WYUwGfkhA/7/+bIBvVrt8vspBiLGvUoPC4wP2ZcTCV/kB75WPlb jxK9MVQK8Fvchv7lZ3kf81snrPU+M2vqAP+a22I3pAR1Rn1QEMn2MjZdJsJ2eDoC0+dv DXlA== X-Gm-Message-State: ALQs6tB/7gtKp/vgQr4w/aXrYCRKcKqo34zznNUA1gibH810wMY+1Qui c3eoDhVfaVodK8SJORNT/DtIhw== X-Google-Smtp-Source: AB8JxZq5iGNlQuq9GQ1GVGFHAt5HL0BAYZO0Sq313cqWeZpN++SmGgH2Q3QiK8njyeUEOM/ULbvygQ== X-Received: by 2002:adf:8004:: with SMTP id 4-v6mr31426010wrk.274.1525800704314; Tue, 08 May 2018 10:31:44 -0700 (PDT) Received: from localhost.localdomain ([95.146.151.144]) by smtp.gmail.com with ESMTPSA id n4sm15373101wmg.29.2018.05.08.10.31.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 10:31:43 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Tue, 8 May 2018 18:31:13 +0100 Message-Id: <20180508173115.24550-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180508173115.24550-1-tvrtko.ursulin@linux.intel.com> References: <20180508173115.24550-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 5/7] 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. v3: Improve scaling with large datasets by only walking each engine timeline once and some caching. (John Harrison) Signed-off-by: Tvrtko Ursulin Cc: John Harrison --- scripts/trace.pl | 102 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 27 deletions(-) diff --git a/scripts/trace.pl b/scripts/trace.pl index 696c18e8b1cf..0ec33cd37e4a 100755 --- a/scripts/trace.pl +++ b/scripts/trace.pl @@ -498,39 +498,83 @@ 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 $end; - - 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 +my %engine_timelines; - if (exists $db{$next_key}) { - $end = $db{$next_key}->{'end'}; - } else { - # No info at all, fake it: - $end = $db{$key}->{'start'} + 999; - } +sub sortEngine { + my $as = $db{$a}->{'global'}; + my $bs = $db{$b}->{'global'}; + my $val; - $db{$key}->{'notify'} = $end; - $db{$key}->{'end'} = $end; + $val = $as <=> $bs; + + die if $val == 0; + + return $val; } -# GPU time accounting -my (%running, %runnable, %queued, %batch_avg, %batch_total_avg, %batch_count); -my (%submit_avg, %execute_avg, %ctxsave_avg); +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. (Or first of a different context starts.) +foreach my $gid (sort keys %rings) { + my $ring = $ringmap{$rings{$gid}}; + my $timeline = get_engine_timeline($ring); + my $last_complete = -1; + my $complete; + + foreach my $pos (0..$#{$timeline}) { + my $key = @{$timeline}[$pos]; + my $end; + + next unless exists $db{$key}->{'incomplete'}; + + # Find first following complete request + if ($pos > $last_complete) { + my $next = $pos; + + undef $complete; + + while ($next < $#{$timeline}) { + my $next_key = ${$timeline}[++$next]; + + next if exists $db{$next_key}->{'incomplete'}; + + $last_complete = $next; + $complete = $next_key; + last; + } + } + + if (defined $complete) { + if ($db{$key}->{'ctx'} == $db{$complete}->{'ctx'}) { + $end = $db{$complete}->{'end'}; + } else { + $end = $db{$complete}->{'start'}; + } + } else { + # No next submission, fake it. + $end = $db{$key}->{'start'} + 999; + } + + $db{$key}->{'notify'} = $end; + $db{$key}->{'end'} = $end; + } +} sub sortStart { my $as = $db{$a}->{'start'}; @@ -579,6 +623,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);