Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp219336ybg; Sun, 26 Jul 2020 02:20:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvfZG8d9Wee8l42B3iTxAeZSn8b8kORgcDMPVUx4pOr6ap0Cb/7HXtoQbhcTFZfn2OT3VG X-Received: by 2002:aa7:cb15:: with SMTP id s21mr1555162edt.175.1595755247445; Sun, 26 Jul 2020 02:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595755247; cv=none; d=google.com; s=arc-20160816; b=Fs8LYq7AYbwDbE9GKBDwzn67DtiApa9qQdd2SxrO72DQoqTxLEFRcQFlx6KMlSKw+f LE7ENbGO44iZPzNCn/b6YlCzAMsHi7vxpLLSSGUUCEZZ8UgcH73nyRek3VIV82mto0xv R8tFyZ2urzsdvZ4KlrcAA+qTFi5stPNyw+OAY6Ft8D46Q4Tpm6k/xy5nsIjAmKOzqR8N /04vUuE0mQNkYcueVhumGCOaNAlkw3bEnpNue9cx0RvWgHGovK8rhpSed+uomNyAAcX3 oPFI0WZ3hPx3jph9e0dSpPOr8CGPVY737Ee3EtsT3ah7P4wRo2rBW7Ib7lgL+0XDwdrc iMUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=JeLUBapXGXe6lZtdV6kvwGSvIiGVF1l91ctZOprb+Gg=; b=FbSu+7MCYg+jpGze5/UaZ2/q2N34IWvDbYVjWxXsf+fQTLhJiBTqTdTWN28xX4D8Ud i7MkdUN+QaX5XcYe8OjIjdN+mDMyo80fg2AungqKRnESCY9c5q1W0hvnkvbm96KK6hHK n2ZfYQ5b7/nVsmNw/qZllkQt0mwlYHrgWrCPwCza4dQnZyFNmc0FP6yPxD8l2RTPp756 9zSS2dw2uqu/pqVCFl5YsGbbKRD+AIQDTLi4ic+75RXCsPaV+C6o0MHIxebUiMOaI8Zg Qwzfk3yk+zaszGC1qJwQMfn/e/wmHlYvW1EOr7ocOuTCDcGREt8QaqoOhbQ5jWN5z67f kpzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g14si3735972ejw.376.2020.07.26.02.20.25; Sun, 26 Jul 2020 02:20:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbgGZJSv (ORCPT + 99 others); Sun, 26 Jul 2020 05:18:51 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54334 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725794AbgGZJSu (ORCPT ); Sun, 26 Jul 2020 05:18:50 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06Q91WxJ014667; Sun, 26 Jul 2020 05:18:43 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 32ggww5xh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 26 Jul 2020 05:18:43 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06Q98MJi029701; Sun, 26 Jul 2020 05:18:42 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 32ggww5xh4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 26 Jul 2020 05:18:42 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06Q9EYgw016449; Sun, 26 Jul 2020 09:18:42 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma02dal.us.ibm.com with ESMTP id 32gcy3k1gj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 26 Jul 2020 09:18:42 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06Q9If9I33292724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 26 Jul 2020 09:18:41 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8732F28058; Sun, 26 Jul 2020 09:18:41 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2347B2805A; Sun, 26 Jul 2020 09:18:37 +0000 (GMT) Received: from localhost.localdomain (unknown [9.199.34.120]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Sun, 26 Jul 2020 09:18:36 +0000 (GMT) Subject: Re: [PATCH 09/19] perf metric: Collect referenced metrics in struct metric_expr To: Jiri Olsa , Arnaldo Carvalho de Melo Cc: Ian Rogers , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Andi Kleen , John Garry , "Paul A. Clarke" , Stephane Eranian References: <20200719181320.785305-1-jolsa@kernel.org> <20200719181320.785305-10-jolsa@kernel.org> From: kajoljain Message-ID: <92070405-8993-decb-46e3-04189dddb1b6@linux.ibm.com> Date: Sun, 26 Jul 2020 14:48:35 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200719181320.785305-10-jolsa@kernel.org> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-26_02:2020-07-24,2020-07-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 mlxlogscore=999 phishscore=0 impostorscore=0 clxscore=1015 bulkscore=0 mlxscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007260064 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/19/20 11:43 PM, Jiri Olsa wrote: > Add referenced metrics into struct metric_expr object, > so they are accessible when computing the metric. > > Storing just name and expression itself, so the metric > can be resolved and computed. > > Acked-by: Ian Rogers > Signed-off-by: Jiri Olsa Reviewed-By : Kajol Jain Thanks, Kajol Jain > --- > tools/perf/util/metricgroup.c | 32 ++++++++++++++++++++++++++++++++ > tools/perf/util/metricgroup.h | 6 ++++++ > 2 files changed, 38 insertions(+) > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > index d1b2c1aa436f..bb5757b9419d 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -83,6 +83,7 @@ static void metric_event_delete(struct rblist *rblist __maybe_unused, > struct metric_expr *expr, *tmp; > > list_for_each_entry_safe(expr, tmp, &me->head, nd) { > + free(expr->metric_refs); > free(expr); > } > > @@ -248,6 +249,7 @@ static int metricgroup__setup_events(struct list_head *groups, > > list_for_each_entry (eg, groups, nd) { > struct evsel **metric_events; > + struct metric_ref *metric_refs = NULL; > > metric_events = calloc(sizeof(void *), > hashmap__size(&eg->pctx.ids) + 1); > @@ -279,6 +281,36 @@ static int metricgroup__setup_events(struct list_head *groups, > free(metric_events); > break; > } > + > + /* > + * Collect and store collected nested expressions > + * for metric processing. > + */ > + if (eg->metric_refs_cnt) { > + struct metric_ref_node *ref; > + > + metric_refs = zalloc(sizeof(struct metric_ref) * (eg->metric_refs_cnt + 1)); > + if (!metric_refs) { > + ret = -ENOMEM; > + free(metric_events); > + break; > + } > + > + i = 0; > + list_for_each_entry(ref, &eg->metric_refs, list) { > + /* > + * Intentionally passing just const char pointers, > + * originally from 'struct pmu_event' object. > + * We don't need to change them, so there's no > + * need to create our own copy. > + */ > + metric_refs[i].metric_name = ref->metric_name; > + metric_refs[i].metric_expr = ref->metric_expr; > + i++; > + } > + }; > + > + expr->metric_refs = metric_refs; > expr->metric_expr = eg->metric_expr; > expr->metric_name = eg->metric_name; > expr->metric_unit = eg->metric_unit; > diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h > index 8315bd1a7da4..62623a39cbec 100644 > --- a/tools/perf/util/metricgroup.h > +++ b/tools/perf/util/metricgroup.h > @@ -18,12 +18,18 @@ struct metric_event { > struct list_head head; /* list of metric_expr */ > }; > > +struct metric_ref { > + const char *metric_name; > + const char *metric_expr; > +}; > + > struct metric_expr { > struct list_head nd; > const char *metric_expr; > const char *metric_name; > const char *metric_unit; > struct evsel **metric_events; > + struct metric_ref *metric_refs; > int runtime; > }; > >