From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751502AbdKUPRc (ORCPT ); Tue, 21 Nov 2017 10:17:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59234 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751145AbdKUPRa (ORCPT ); Tue, 21 Nov 2017 10:17:30 -0500 Date: Tue, 21 Nov 2017 16:17:27 +0100 From: Jiri Olsa To: Jin Yao 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 Subject: Re: [PATCH v1 3/9] perf util: Reconstruct rblist for supporting per-thread shadow stats Message-ID: <20171121151727.GE20440@krava> References: <1511189024-19908-1-git-send-email-yao.jin@linux.intel.com> <1511189024-19908-4-git-send-email-yao.jin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1511189024-19908-4-git-send-email-yao.jin@linux.intel.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 21 Nov 2017 15:17:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > + 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