From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751695AbdLBEkb (ORCPT ); Fri, 1 Dec 2017 23:40:31 -0500 Received: from mga02.intel.com ([134.134.136.20]:35834 "EHLO mga02.intel.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751491AbdLBEka (ORCPT ); Fri, 1 Dec 2017 23:40:30 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,348,1508828400"; d="scan'208";a="1250966456" Subject: Re: [PATCH v5 03/12] perf util: Extend rbtree to support shadow stats To: Arnaldo Carvalho de Melo Cc: 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: <1512125856-22056-1-git-send-email-yao.jin@linux.intel.com> <1512125856-22056-4-git-send-email-yao.jin@linux.intel.com> <20171201141001.GW3298@kernel.org> From: "Jin, Yao" Message-ID: <4dc7fc2a-2c02-1e25-9899-42203e45af4a@linux.intel.com> Date: Sat, 2 Dec 2017 12:40:26 +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: <20171201141001.GW3298@kernel.org> 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 12/1/2017 10:10 PM, Arnaldo Carvalho de Melo wrote: > Em Fri, Dec 01, 2017 at 06:57:27PM +0800, Jin Yao escreveu: >> Previously the rbtree was used to link generic metrics. > > Try to make the one line subject more descriptive, I'm changing it to: > > perf stat: Extend rbtree to support per-thread shadow stats > > - Arnaldo > Yes, this new subject is better. Thanks Jin Yao >> This patches adds new 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. >> >> Signed-off-by: Jin Yao >> --- >> tools/perf/util/stat-shadow.c | 27 +++++++++++++++++++++++++++ >> 1 file changed, 27 insertions(+) >> >> diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c >> index 5853901..c53b80d 100644 >> --- a/tools/perf/util/stat-shadow.c >> +++ b/tools/perf/util/stat-shadow.c >> @@ -45,7 +45,10 @@ 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 +61,30 @@ static int saved_value_cmp(struct rb_node *rb_node, const void *entry) >> >> if (a->cpu != b->cpu) >> return a->cpu - b->cpu; >> + >> + /* >> + * Previously the rbtree was used to link generic metrics. >> + * The keys were evsel/cpu. Now the rbtree is extended to support >> + * per-thread shadow stats. For shadow stats case, the keys >> + * are cpu/type/ctx/stat (evsel is NULL). For generic metrics >> + * case, the keys are still evsel/cpu (type/ctx/stat are 0 or NULL). >> + */ >> + if (a->type != b->type) >> + return a->type - b->type; >> + >> + if (a->ctx != b->ctx) >> + return a->ctx - b->ctx; >> + >> + 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; >> + } >> + >> if (a->evsel == b->evsel) >> return 0; >> if ((char *)a->evsel < (char *)b->evsel) >> -- >> 2.7.4