From patchwork Thu Jul 12 10:59:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10521459 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 868C6605DC for ; Thu, 12 Jul 2018 11:00:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7278E2925C for ; Thu, 12 Jul 2018 11:00:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66FFC29271; Thu, 12 Jul 2018 11:00:13 +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 14FED2926C for ; Thu, 12 Jul 2018 11:00:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 374806EF68; Thu, 12 Jul 2018 11:00:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FA646EF50 for ; Thu, 12 Jul 2018 11:00:08 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id z13-v6so5571332wma.5 for ; Thu, 12 Jul 2018 04:00:08 -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=y4IuZsNN012owgQe5LBck27X0OnkM+rqaNtCDZxqL9s=; b=owFzEBixCFAAJArci/RQJ51Mbipf7zPWQhDtFh2Q67RvLSOqYNMmPgdHs5pJ0+ecCT QpEe00bo7eGL8ogS0V90P90x7j86htkyF2PRkFxqXMSdqZxsr3QSuTT1HWFwvVlLBkit jcPrbB3773PHRq7FNr8JCSyy9MTRJ1Z2Eh3e9jsQTquK9PB2NMINXnpc7zaM75EqVTmf vQTPK9xqbjK/k1cQm1fazj47JcIGE1u/j5Emq0iBuQ/gFsPzcxfbcCesKcfYcIgPLhV1 sy4/I5owzprpS3IU/YAOkMddvqxdqJAse4PuB8J8BLNKVWlgPK7T5RyjkJ8skaiyqCcl iGoA== X-Gm-Message-State: AOUpUlEPRBSiBm8bLiZs6rBbC0E17tqjZqIJa3JEK+2MEWqTL64IbCP3 HfvQ+IRpclwhbXunhh7ezcngBw== X-Google-Smtp-Source: AAOMgpcdcGomapaxkZe28wXoen7JApM/txTembWcyT3jOT2AWjgRwD1hv2hMx6lV1+tWfMuBXpHCVg== X-Received: by 2002:a1c:c501:: with SMTP id v1-v6mr1131997wmf.112.1531393207162; Thu, 12 Jul 2018 04:00:07 -0700 (PDT) Received: from localhost.localdomain ([95.146.151.144]) by smtp.gmail.com with ESMTPSA id z5-v6sm23494585wrv.2.2018.07.12.04.00.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 04:00:06 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Thu, 12 Jul 2018 11:59:53 +0100 Message-Id: <20180712105958.12953-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180712105958.12953-1-tvrtko.ursulin@linux.intel.com> References: <20180712105958.12953-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 4/9] 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 56a4d4fd8bb2..7cafb3f52ba4 100755 --- a/scripts/trace.pl +++ b/scripts/trace.pl @@ -336,7 +336,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; @@ -425,6 +425,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; @@ -592,7 +594,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'}; @@ -604,8 +606,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'}; @@ -740,6 +740,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'); @@ -948,7 +963,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);