Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1232071ybg; Tue, 2 Jun 2020 04:53:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj8vau2pSnZMTjSHrOmnixdXA7N2ZMZrpzN4H/1usRFR0crLkx6xBiPIfRknbh/ZyalKdn X-Received: by 2002:a17:906:4548:: with SMTP id s8mr13694936ejq.519.1591098834903; Tue, 02 Jun 2020 04:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591098834; cv=none; d=google.com; s=arc-20160816; b=MD9v+TOBp2NvAp40MbjjMn/y6zxRlgNPNVCbfPXyNFmxMXXhV0N5L8+KP12NNefT6A g4cDHwwlh5dwJr3EXCj5KVMZyEuxR97bG+IHZUjUOUFKKusN6vJW5PiaaucTZCdYv4il T/+D4ipxbH9dT1UBbms4cJomF2WWXucWj+oHctPkuHAdKGyIQ8CMPKCSnd7ZA/EKs/Nj E4kSctd7TWCeRYmgDRL07dV6iPpVWvyzDCvA1/Ojr88v3hTLGzOCm2cGp+NG7ppPl7Cl 4UVg17VHokyIP7210iHu88I70iWe0gSutWL31tticTlmGCWkJfhpL+C9v8WZlWteTnIg f7Gw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rRbk98AyMT83Uuy3XqCC2ORCrzLJz97QvOQfDzvk6Po=; b=xVZUl1Wdw+WcByDPjEfaZJVDrdNCsMfq2fptpO1WQU0+5Wqbob6SLPWo6Ix3tAF5Rl 9lRa9rQpz0bRfA1xVhgiZWGY3AtX+6rFcQgcumUo4ghKaW7MX8gLUzPiEgTw1pt24kRA icp6a/uJvneXOMUe+E8nWdmpUUGibxVSBYY4O/Ak7KO7tVt/w8h1kyK3Tuir8kNqxplf P2Qj+Sky3VA1il4RslsNYpIoxoOR5M2WlafYmXDv/kWILo3Wnn0R2N+NfHVtNcLCjzet wCyJCt+uLdTYrV2tbj56i9wud4pMmQkDAONx0kn3oOqEvcLT/ZeUrrRVL15+nPmu80Z7 LYcA== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r3si1343360eji.126.2020.06.02.04.53.31; Tue, 02 Jun 2020 04:53:54 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728128AbgFBLv1 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 2 Jun 2020 07:51:27 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:56737 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728070AbgFBLv0 (ORCPT ); Tue, 2 Jun 2020 07:51:26 -0400 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-366-hf1vTMizPbmP0VWUWxcakw-1; Tue, 02 Jun 2020 07:51:19 -0400 X-MC-Unique: hf1vTMizPbmP0VWUWxcakw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFFB080B713; Tue, 2 Jun 2020 11:51:17 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.195.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD2191001281; Tue, 2 Jun 2020 11:51:15 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Ian Rogers , Stephane Eranian , Andi Kleen Subject: [PATCH 07/13] perf tools: Add map to parse_events function Date: Tue, 2 Jun 2020 13:50:49 +0200 Message-Id: <20200602115055.1168446-8-jolsa@kernel.org> In-Reply-To: <20200602115055.1168446-1-jolsa@kernel.org> References: <20200602115055.1168446-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For testing purposes we need to pass our own map of events from parse_groups through metricgroup__add_metric. Signed-off-by: Jiri Olsa --- tools/perf/util/metricgroup.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index f3e761e14e66..72999aacfa37 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -597,17 +597,14 @@ static int __metricgroup__add_metric(struct list_head *group_list, static int metricgroup__add_metric(const char *metric, bool metric_no_group, struct strbuf *events, - struct list_head *group_list) + struct list_head *group_list, + struct pmu_events_map *map) { - struct pmu_events_map *map = perf_pmu__find_map(NULL); struct pmu_event *pe; struct egroup *eg; int i, ret; bool has_match = false; - if (!map) - return 0; - for (i = 0; ; i++) { pe = &map->table[i]; @@ -668,7 +665,8 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, static int metricgroup__add_metric_list(const char *list, bool metric_no_group, struct strbuf *events, - struct list_head *group_list) + struct list_head *group_list, + struct pmu_events_map *map) { char *llist, *nlist, *p; int ret = -EINVAL; @@ -683,7 +681,7 @@ static int metricgroup__add_metric_list(const char *list, bool metric_no_group, while ((p = strsep(&llist, ",")) != NULL) { ret = metricgroup__add_metric(p, metric_no_group, events, - group_list); + group_list, map); if (ret == -EINVAL) { fprintf(stderr, "Cannot find metric or group `%s'\n", p); @@ -713,7 +711,8 @@ static int parse_groups(struct evlist *perf_evlist, const char *str, bool metric_no_group, bool metric_no_merge, bool fake_pmu, - struct rblist *metric_events) + struct rblist *metric_events, + struct pmu_events_map *map) { struct parse_events_error parse_error; struct strbuf extra_events; @@ -723,7 +722,7 @@ static int parse_groups(struct evlist *perf_evlist, const char *str, if (metric_events->nr_entries == 0) metricgroup__rblist_init(metric_events); ret = metricgroup__add_metric_list(str, metric_no_group, - &extra_events, &group_list); + &extra_events, &group_list, map); if (ret) return ret; pr_debug("adding %s\n", extra_events.buf); @@ -748,9 +747,13 @@ int metricgroup__parse_groups(const struct option *opt, struct rblist *metric_events) { struct evlist *perf_evlist = *(struct evlist **)opt->value; + struct pmu_events_map *map = perf_pmu__find_map(NULL); + + if (!map) + return 0; return parse_groups(perf_evlist, str, metric_no_group, - metric_no_merge, false, metric_events); + metric_no_merge, false, metric_events, map); } bool metricgroup__has_metric(const char *metric) -- 2.25.4