Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp135364ybh; Mon, 20 Jul 2020 12:17:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy45CLdDPRX5fvgfB633gAlleq2NGg+RFu8aQXIOy1tXSD37oJnSW7YVPKn/y/6F0I0bYFa X-Received: by 2002:a17:906:1414:: with SMTP id p20mr21772994ejc.247.1595272661591; Mon, 20 Jul 2020 12:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595272661; cv=none; d=google.com; s=arc-20160816; b=dA6tJpYuJtG15lgxoWIH4c3AGiCxHZUMRp/D53q9tcVhx5NMwP8BOaflmKZN6bKzjq 0A2F6voWTILjncX1lmZU4RjrOF3M9d6ccmJjimh+cKUsRhAxXIpOY4Ac9HUBXKEGoN2w K91MlIxUq+D5B3uCeCxwmBfMKGKyhSioWecC6olHcoF08Cdh6CP+Q7UJFkPkODfYAWMh 19sd+5kVODYZ/z+3S8AXYX20pGaX/QXuMR4L/o4Nt/8kyp8EgccMIacsyN5TWBHhvEtc ez+7cmS89G6yeF2mzq5su42bTrjmSRaFoPEIpPGQtEeOiHW9Atm7YfagDHhJ5X5QoHtF qCjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=udwHk4yQs9a7okbIGNpumR6e7TTud7FzGXDS4QXVwVQ=; b=xKY7idjcRXRUTdrZkWaIT47wTZNJD6MEHOLKEPmdSa0w+pf+vxJ0AvhAx6m5CNGRlK /UR5pF5vaEyT/aw1SkOsKtcAkOVY/w8SjGfEmrMb9Sx5bliPwAUq+hD1c77sjQGG7Nrc VCdHi2E9DYT8dizSzSl4qK6aF5S0B15HWhc+rKBUMCGviAb3YpNQzHfI3TEg7OftvAA0 lidny8LwHxiDCYLV6BykL0CL1bZozYaIlNU1aaYYjY1W6JUBGPTp8UDDjtyxQ84zbaxQ sAPMPGldLGdufpSV4tGftoxJUYV6jhEgoKKzG2CBYQEKxLeAebBUslxdYbp6izRZVeR2 YDdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fApPH6HU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gl18si10586102ejb.588.2020.07.20.12.17.18; Mon, 20 Jul 2020 12:17:41 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fApPH6HU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729690AbgGTTQk (ORCPT + 99 others); Mon, 20 Jul 2020 15:16:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:54039 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726899AbgGTTQk (ORCPT ); Mon, 20 Jul 2020 15:16:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595272598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=udwHk4yQs9a7okbIGNpumR6e7TTud7FzGXDS4QXVwVQ=; b=fApPH6HUzbvR2+sEhUBzwOgbRzs3hZ9f6qvPvjEXEVIDEd0IhHXl/Nj3tIS0Eo5sMXEm7o qtqUwNuhVJmWtTToX6hovgoszV+3EtMaEiXQ+2aTee7oeFc0xxP1Y96wvvvkQRd+AVB612 7M/upcJeT3vrOy68vqX5Vt3bkeEdH1A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-389-egiFU7O3Opmkzy7FkJHPUA-1; Mon, 20 Jul 2020 15:16:33 -0400 X-MC-Unique: egiFU7O3Opmkzy7FkJHPUA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA65E18C63C1; Mon, 20 Jul 2020 19:16:29 +0000 (UTC) Received: from krava (unknown [10.40.194.11]) by smtp.corp.redhat.com (Postfix) with SMTP id 193E076114; Mon, 20 Jul 2020 19:16:25 +0000 (UTC) Date: Mon, 20 Jul 2020 21:16:25 +0200 From: Jiri Olsa To: kajoljain Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Andi Kleen , John Garry , "Paul A. Clarke" , Stephane Eranian , Ian Rogers Subject: Re: [PATCHv3 00/19] perf metric: Add support to reuse metric Message-ID: <20200720191625.GL760733@krava> References: <20200719181320.785305-1-jolsa@kernel.org> <20200720072237.GC760733@krava> <6cb72b48-5244-9faf-a9e5-67858c732b83@linux.ibm.com> <20200720081943.GE760733@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 20, 2020 at 02:32:40PM +0530, kajoljain wrote: > > > On 7/20/20 1:49 PM, Jiri Olsa wrote: > > On Mon, Jul 20, 2020 at 01:39:24PM +0530, kajoljain wrote: > > > > SNIP > > > >> This is with your perf/metric branch: > >> command# ./perf stat -M PowerBUS_Frequency -C 0 -I 1000 > >> assertion failed at util/metricgroup.c:709 > >> # time counts unit events > >> 1.000054545 7,807,505 hv_24x7/pm_pb_cyc,chip=0/ # 2.0 GHz PowerBUS_Frequency_0 > >> 1.000054545 7,807,485 hv_24x7/pm_pb_cyc,chip=1/ > >> 2.000232761 7,807,500 hv_24x7/pm_pb_cyc,chip=0/ # 2.0 GHz PowerBUS_Frequency_0 > >> 2.000232761 7,807,478 hv_24x7/pm_pb_cyc,chip=1/ > >> 3.000363762 7,799,665 hv_24x7/pm_pb_cyc,chip=0/ # 1.9 GHz PowerBUS_Frequency_0 > >> 3.000363762 7,807,502 hv_24x7/pm_pb_cyc,chip=1/ > >> ^C 3.259418599 2,022,150 hv_24x7/pm_pb_cyc,chip=0/ # 0.5 GHz PowerBUS_Frequency_0 > >> 3.259418599 2,022,164 hv_24x7/pm_pb_cyc,chip=1/ > >> > >> Performance counter stats for 'CPU(s) 0': > >> > >> 25,436,820 hv_24x7/pm_pb_cyc,chip=0/ # 6.4 GHz PowerBUS_Frequency_0 > >> 25,444,629 hv_24x7/pm_pb_cyc,chip=1/ > >> > >> 3.259505529 seconds time elapsed > > > > I found the bug, we are not adding runtime metrics as standalone ones, > > but as referenced metrics.. will fix and try to add test for that > > > > as for testing.. do I need some special ppc server to have support for this? > > Hi jiri, > We need power9 lpar machine and need to make sure `CONFIG_HV_PERF_CTRS` is > enabled. could you please try with following patch on top? thanks, jirka --- diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 6f179b9903a0..03aa4bd4a38b 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -820,11 +820,11 @@ static int add_metric(struct list_head *metric_list, struct expr_id *parent, struct expr_ids *ids); -static int resolve_metric(struct metric *m, - bool metric_no_group, - struct list_head *metric_list, - struct pmu_events_map *map, - struct expr_ids *ids) +static int __resolve_metric(struct metric *m, + bool metric_no_group, + struct list_head *metric_list, + struct pmu_events_map *map, + struct expr_ids *ids) { struct hashmap_entry *cur; size_t bkt; @@ -869,6 +869,23 @@ static int resolve_metric(struct metric *m, return 0; } +static int resolve_metric(bool metric_no_group, + struct list_head *metric_list, + struct pmu_events_map *map, + struct expr_ids *ids) +{ + struct metric *m; + int err; + + list_for_each_entry(m, metric_list, nd) { + err = __resolve_metric(m, metric_no_group, metric_list, map, ids); + if (err) + return err; + } + + return 0; +} + static int add_metric(struct list_head *metric_list, struct pmu_event *pe, bool metric_no_group, @@ -876,6 +893,7 @@ static int add_metric(struct list_head *metric_list, struct expr_id *parent, struct expr_ids *ids) { + struct metric *orig = *m; int ret = 0; pr_debug("metric expr %s for %s\n", pe->metric_expr, pe->metric_name); @@ -892,7 +910,7 @@ static int add_metric(struct list_head *metric_list, * those events to metric_list. */ - for (j = 0; j < count && !ret; j++) { + for (j = 0; j < count && !ret; j++, *m = orig) { ret = __add_metric(metric_list, pe, metric_no_group, j, m, parent, ids); } } @@ -907,8 +925,8 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, { struct expr_ids ids = { 0 }; + struct metric *m = NULL; struct pmu_event *pe; - struct metric *m; LIST_HEAD(list); int i, ret; bool has_match = false; @@ -925,7 +943,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, * Process any possible referenced metrics * included in the expression. */ - ret = resolve_metric(m, metric_no_group, + ret = resolve_metric(metric_no_group, &list, map, &ids); if (ret) return ret;