Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp261671ybg; Tue, 28 Jul 2020 05:31:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMUUv6BBnZwCoxIhhiEWNmxO82M0wcH2K562By0xrRRphWnfPKTz7ZRH2ASkWg1EcZ1nWo X-Received: by 2002:a17:907:1059:: with SMTP id oy25mr26915834ejb.90.1595939497731; Tue, 28 Jul 2020 05:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595939497; cv=none; d=google.com; s=arc-20160816; b=Saq404RnSnhgc9Y+nlX5GCirhfmEKQKY+muF5j3YyZQzehMNjxqxI8c3iHybHwMxKF 9IZvvH+uapP9lOD8/YUchXiL4lMODGVYOkBVjNKKm6JW+2zhQhC9erOK7RaklcYULn1E EDmAXtK7pj5dQsppymc9O3GYSITwSjU+AjnBNloAdcwcOoi6mMYZRYcPq+WknMAfVZuT wHZKg3A8PVHc2RryK7Fr/S5ADyOejx5/8VubgdZeKbXjRNVQolq500RCOwj6dg3rVuUX BHUecZUPQqB0+xIKA83B6QfWHPku+MteaDASSoDgSIfKELHhe3QJWHJ3akw9XbQjYpFW 8lRA== 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=zQcshhc5vbUAG07kNhMxK1UwnB/nBAU4QB8UfaFPc/I=; b=X7Fi10BDIA0k1PVsdG37ebPHI30v2WV8yzKJtYDYvX9EOb0GJrsBnKb2L2I0LP6aHt pLf9adOIaG8R1mZRAbfps0AqTnPtM8CyWtjwUsljtpogNLraOQdqGSvGPOE7SP5mnID1 SjWXVsB9N3fh6f1/A4vMzgjEAsL81Kz442+TVMksJu10Fr9m4MD8cduoDh9idEhkyboP 2vn4/lmaDUd7f9A+bcr1N4Jen4rLhDUMUqrwV0xFRhvFBJRzvvMUFof97+YHuV8a4xMP YD9PrwE6hQqoibfXDp6oBnzBvbyX4HHPiLGTDhGVIj4TzYsz4udPvi6H+rKxM8ZFmarQ P0Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lK9ciowh; 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 r5si7254781edh.198.2020.07.28.05.31.15; Tue, 28 Jul 2020 05:31:37 -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=@kernel.org header.s=default header.b=lK9ciowh; 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 S1729470AbgG1M3n (ORCPT + 99 others); Tue, 28 Jul 2020 08:29:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:43674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729127AbgG1M3m (ORCPT ); Tue, 28 Jul 2020 08:29:42 -0400 Received: from quaco.ghostprotocols.net (179.176.1.55.dynamic.adsl.gvt.net.br [179.176.1.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 01DA7206D4; Tue, 28 Jul 2020 12:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595939382; bh=VB/LWQGIJZs4oQUb9P6Md/HK1rt96WyNZ5+T3ag5OG0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lK9ciowhYnf9gFnbqyXxWqX3cFfbLVxH4hXaJkE5E8aViWMnBbtaW/7imqiDe8/9B qcxQwODFAWnVPOiKRoi3VPXCg+ldAFgmRlKtW5BXBu2GVAEAIUBou6aQpcVIIjeM0a 3z4oZXfgh6YKGK0p0/B2GsWcnYTzjr75cufeaMC8= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 22480404B1; Tue, 28 Jul 2020 09:29:40 -0300 (-03) Date: Tue, 28 Jul 2020 09:29:40 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Jiri Olsa , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Andi Kleen , Kajol Jain , John Garry , "Paul A. Clarke" , Stephane Eranian Subject: Re: [PATCH 05/19] perf metric: Add macros for iterating map events Message-ID: <20200728122940.GL40195@kernel.org> References: <20200719181320.785305-1-jolsa@kernel.org> <20200719181320.785305-6-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sun, Jul 19, 2020 at 02:46:12PM -0700, Ian Rogers escreveu: > On Sun, Jul 19, 2020 at 11:13 AM Jiri Olsa wrote: > > > > Adding following macros to iterate events and metric: > > map_for_each_event(__pe, __idx, __map) > > - iterates over all pmu_events_map events > > map_for_each_metric(__pe, __idx, __map, __metric) > > - iterates over all metrics that match __metric argument > > > > and use it in metricgroup__add_metric function. Macros > > will be be used from other places in following changes. > > > > Signed-off-by: Jiri Olsa > > Acked-by: Ian Rogers Thanks, applied. - Arnaldo > Thanks! > Ian > > > --- > > tools/perf/util/metricgroup.c | 77 ++++++++++++++++++----------------- > > 1 file changed, 40 insertions(+), 37 deletions(-) > > > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > > index df0356ec120d..b37008fc253c 100644 > > --- a/tools/perf/util/metricgroup.c > > +++ b/tools/perf/util/metricgroup.c > > @@ -614,6 +614,17 @@ static int __metricgroup__add_metric(struct list_head *group_list, > > return 0; > > } > > > > +#define map_for_each_event(__pe, __idx, __map) \ > > + for (__idx = 0, __pe = &__map->table[__idx]; \ > > + __pe->name || __pe->metric_group || __pe->metric_name; \ > > + __pe = &__map->table[++__idx]) > > + > > +#define map_for_each_metric(__pe, __idx, __map, __metric) \ > > + map_for_each_event(__pe, __idx, __map) \ > > + if (__pe->metric_expr && \ > > + (match_metric(__pe->metric_group, __metric) || \ > > + match_metric(__pe->metric_name, __metric))) > > + > > static int metricgroup__add_metric(const char *metric, bool metric_no_group, > > struct strbuf *events, > > struct list_head *group_list, > > @@ -624,49 +635,41 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, > > int i, ret; > > bool has_match = false; > > > > - for (i = 0; ; i++) { > > - pe = &map->table[i]; > > - > > - if (!pe->name && !pe->metric_group && !pe->metric_name) { > > - /* End of pmu events. */ > > - if (!has_match) > > - return -EINVAL; > > - break; > > - } > > - if (!pe->metric_expr) > > - continue; > > - if (match_metric(pe->metric_group, metric) || > > - match_metric(pe->metric_name, metric)) { > > - has_match = true; > > - pr_debug("metric expr %s for %s\n", pe->metric_expr, pe->metric_name); > > - > > - if (!strstr(pe->metric_expr, "?")) { > > - ret = __metricgroup__add_metric(group_list, > > - pe, > > - metric_no_group, > > - 1); > > - if (ret) > > - return ret; > > - } else { > > - int j, count; > > + map_for_each_metric(pe, i, map, metric) { > > + pr_debug("metric expr %s for %s\n", pe->metric_expr, pe->metric_name); > > + has_match = true; > > + > > + if (!strstr(pe->metric_expr, "?")) { > > + ret = __metricgroup__add_metric(group_list, > > + pe, > > + metric_no_group, > > + 1); > > + if (ret) > > + return ret; > > + } else { > > + int j, count; > > > > - count = arch_get_runtimeparam(); > > + count = arch_get_runtimeparam(); > > > > - /* This loop is added to create multiple > > - * events depend on count value and add > > - * those events to group_list. > > - */ > > + /* This loop is added to create multiple > > + * events depend on count value and add > > + * those events to group_list. > > + */ > > > > - for (j = 0; j < count; j++) { > > - ret = __metricgroup__add_metric( > > - group_list, pe, > > - metric_no_group, j); > > - if (ret) > > - return ret; > > - } > > + for (j = 0; j < count; j++) { > > + ret = __metricgroup__add_metric( > > + group_list, pe, > > + metric_no_group, j); > > + if (ret) > > + return ret; > > } > > } > > } > > + > > + /* End of pmu events. */ > > + if (!has_match) > > + return -EINVAL; > > + > > list_for_each_entry(eg, group_list, nd) { > > if (events->len > 0) > > strbuf_addf(events, ","); > > -- > > 2.25.4 > > -- - Arnaldo