From patchwork Wed Jul 18 09:45:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10531953 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 93EC3602CA for ; Wed, 18 Jul 2018 09:45:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80F5C28FBC for ; Wed, 18 Jul 2018 09:45:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7511928FCD; Wed, 18 Jul 2018 09:45:32 +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.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 2674328FBC for ; Wed, 18 Jul 2018 09:45:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 84A9F6E986; Wed, 18 Jul 2018 09:45:28 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CB7B89C7F for ; Wed, 18 Jul 2018 09:45:25 +0000 (UTC) Received: by mail-wm0-x22e.google.com with SMTP id s14-v6so2182241wmc.1 for ; Wed, 18 Jul 2018 02:45:25 -0700 (PDT) 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=8YJpp8IBfC3OsSQyTWQP/BhDvatFoMLwbU9BrEc/Eqs=; b=e69d5PCldId1W/pIlITAHhYotwfSzCH8w9U4LiMPok8XFsmdXTLj4ika293dTpiv5Y 5wvBX0Xwv2O4lsodxsReWlwjObHZC8q6qdewcfswBQWu5Wy+Au5NNy9muto+fUSD7a5l 8F/MvFr5NBfSRqHo+Qtg4jWuUKW4/oEC0VGi2JJJN2wt02Oca4rpj/UuCSqh0jjRbodc jBQ7+DLkI/Z3/ai6SXmUP0aZgzYbYps4tHsPujEqBCxB7iuovee1VXPvb84knjUc0QY0 twqC2gjV9B3Q8uiVOnOtPqnbFlJDbyWjcxrpPQwN4W5ygGWEXYmludRGfk6JPXpHIYL+ VXxw== X-Gm-Message-State: AOUpUlFDfPc2157JT9b5NTSQ73QGr7FRMUuCDKDHWJv0JfSA7piOgjQw G9UBpPcd+xHmCNpzRzKXGzui2A== X-Google-Smtp-Source: AAOMgpfkYiXI+nhnU4Pk7NAF9g9gd5XFUHmCY9HIeM5tAnej8RcCqqYKjxEKF40H7inN8a2QadjC2w== X-Received: by 2002:a1c:81c5:: with SMTP id c188-v6mr1040088wmd.122.1531907123758; Wed, 18 Jul 2018 02:45:23 -0700 (PDT) Received: from localhost.localdomain ([95.146.151.144]) by smtp.gmail.com with ESMTPSA id q11-v6sm7919530wrp.58.2018.07.18.02.45.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 02:45:22 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Wed, 18 Jul 2018 10:45:09 +0100 Message-Id: <20180718094514.5903-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180718094514.5903-1-tvrtko.ursulin@linux.intel.com> References: <20180718094514.5903-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/8] trace.pl: Improve context colouring for large context id's 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 John reports that on a long runnning systems the huge disparity between kernel context and user context id's causes all interesting colours to be clustered too close together. Fix this by assigning colours to seen contexts instead of basing purely on context id's. Signed-off-by: Tvrtko Ursulin Suggested-by: John Harrison Cc: John Harrison Reviewed-by: John Harrison --- scripts/trace.pl | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/scripts/trace.pl b/scripts/trace.pl index b9188123ba65..b57922c24e16 100755 --- a/scripts/trace.pl +++ b/scripts/trace.pl @@ -322,7 +322,7 @@ sub sanitize_ctx { my ($ctx, $ring) = @_; - if (exists $ctxdb{$ctx}) { + if (exists $ctxdb{$ctx} and $ctxdb{$ctx} > 1) { return $ctx . '.' . $ctxdb{$ctx}; } else { return $ctx; @@ -395,6 +395,8 @@ while (<>) { $ctxdb{$orig_ctx}++; $ctx = sanitize_ctx($orig_ctx, $ring); $key = db_key($ring, $ctx, $seqno); + } else { + $ctxdb{$orig_ctx} = 1; } $queue{$key} = $time; @@ -562,7 +564,7 @@ foreach my $key (@sorted_keys) { my $last_ts = 0; my $first_ts; -my ($min_ctx, $max_ctx); +my $min_ctx; foreach my $key (@sorted_keys) { my $ring = $db{$key}->{'ring'}; @@ -574,8 +576,6 @@ foreach my $key (@sorted_keys) { $last_ts = $end if $end > $last_ts; $min_ctx = $db{$key}->{'ctx'} if not defined $min_ctx or $db{$key}->{'ctx'} < $min_ctx; - $max_ctx = $db{$key}->{'ctx'} if not defined $max_ctx or - $db{$key}->{'ctx'} > $max_ctx; $db{$key}->{'context-complete-delay'} = $end - $notify; $db{$key}->{'execute-delay'} = $start - $db{$key}->{'submit'}; @@ -710,6 +710,21 @@ say sprintf('GPU: %.2f%% idle, %.2f%% busy', my $timeline_text = $colour_contexts ? 'Per context coloured shading like:' : 'Box shading like:'; +my %ctx_colours; + +sub generate_ctx_colours +{ + my $num_ctx = keys %ctxdb; + my $i = 0; + + foreach my $ctx (sort keys %ctxdb) { + $ctx_colours{$ctx} = int(360 / $num_ctx * $i++); + } +} + + +generate_ctx_colours() if $html and $colour_contexts; + my $queued_style = box_style($min_ctx, 'queue'); my $ready_style = box_style($min_ctx, 'ready'); my $execute_style = box_style($min_ctx, 'execute'); @@ -918,7 +933,7 @@ sub ctx_colour $l = 25; } - $val = int(360 / ($max_ctx - $min_ctx + 1)) * ($ctx - $min_ctx); + $val = $ctx_colours{$ctx}; } $l = int($l * $lfac);