From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751499AbdKVCTQ (ORCPT ); Tue, 21 Nov 2017 21:19:16 -0500 Received: from [134.134.136.100] ([134.134.136.100]:37435 "EHLO mga07.intel.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751409AbdKVCTP (ORCPT ); Tue, 21 Nov 2017 21:19:15 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,435,1505804400"; d="scan'208";a="4577028" Subject: Re: [PATCH v1 3/9] perf util: Reconstruct rblist for supporting per-thread shadow stats To: Jiri Olsa Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com References: <1511189024-19908-1-git-send-email-yao.jin@linux.intel.com> <1511189024-19908-4-git-send-email-yao.jin@linux.intel.com> <20171121151727.GE20440@krava> From: "Jin, Yao" Message-ID: <7cd636db-443d-c214-1ec6-58f8cbe778a0@linux.intel.com> Date: Wed, 22 Nov 2017 10:19:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171121151727.GE20440@krava> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/21/2017 11:17 PM, Jiri Olsa wrote: > On Mon, Nov 20, 2017 at 10:43:38PM +0800, Jin Yao wrote: >> In current stat-shadow.c, the rblist deleting is ignored. >> >> The patch reconstructs the codes of rblist init/free, and adds >> the implementation to node_delete method of rblist. >> >> This patch also does: >> >> 1. Add the ctx/type/stat into rbtree keys because we will >> use this rbtree to maintain shadow metrics to replace original >> a couple of static arrays for supporting per-thread shadow stats. >> >> 2. Create a static runtime_stat variable 'rt_stat' which >> will log the shadow metrics by default. >> >> Signed-off-by: Jin Yao >> --- >> tools/perf/util/stat-shadow.c | 62 ++++++++++++++++++++++++++++++++++++++++--- >> tools/perf/util/stat.h | 2 ++ >> 2 files changed, 60 insertions(+), 4 deletions(-) >> >> diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c >> index 5853901..045e129 100644 >> --- a/tools/perf/util/stat-shadow.c >> +++ b/tools/perf/util/stat-shadow.c >> @@ -40,12 +40,16 @@ static struct stats runtime_aperf_stats[NUM_CTX][MAX_NR_CPUS]; >> static struct rblist runtime_saved_values; >> static bool have_frontend_stalled; >> >> +static struct runtime_stat rt_stat; >> struct stats walltime_nsecs_stats; >> >> struct saved_value { >> struct rb_node rb_node; >> struct perf_evsel *evsel; >> + enum stat_type type; >> + int ctx; >> int cpu; >> + struct runtime_stat *stat; >> struct stats stats; >> }; >> >> @@ -58,6 +62,23 @@ static int saved_value_cmp(struct rb_node *rb_node, const void *entry) >> >> if (a->cpu != b->cpu) >> return a->cpu - b->cpu; >> + >> + if (a->type != b->type) >> + return a->type - b->type; >> + >> + if (a->ctx != b->ctx) >> + return a->ctx - b->ctx; >> + > > could you please comment in here on the cases where > evsel is defined and when not > > jirka > Thanks for reminding. I will add comments to describe the cases where and when the evsel is set or not. Thanks Jin Yao >> + if (a->evsel == NULL && b->evsel == NULL) { >> + if (a->stat == b->stat) >> + return 0; >> + >> + if ((char *)a->stat < (char *)b->stat) >> + return -1; >> + >> + return 1; >> + } >> + > > SNIP >