From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40F06C433DF for ; Wed, 29 Jul 2020 09:20:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BBA721883 for ; Wed, 29 Jul 2020 09:20:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596014411; bh=jB1hNwztxmtlfl9Zy49f7zbKJUQ8yfzjgpz1WnP4lfw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KupBdEjxLpAmjYdlRHF0/bwf8INjIMpLbpAtrV6KEAT40GHjPw75fV3vDoQMQjf0l RYx8o5MIgRzGsf5wLjRGyBOlXUXAkk5Eo1lt++XklRJchAJJofs/f1khFI4sZ/PEGJ 1U7mMWoROdIbTNwChO32mZnJi4Q86BTiATvWYGW8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728299AbgG2JUK convert rfc822-to-8bit (ORCPT ); Wed, 29 Jul 2020 05:20:10 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:38165 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728195AbgG2JUJ (ORCPT ); Wed, 29 Jul 2020 05:20:09 -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-171-8BytmW01OcWCfHyTO70nbQ-1; Wed, 29 Jul 2020 05:20:02 -0400 X-MC-Unique: 8BytmW01OcWCfHyTO70nbQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 02DBF10059A8; Wed, 29 Jul 2020 09:20:00 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.193.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 804E66931E; Wed, 29 Jul 2020 09:19:56 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Kajol Jain , Ian Rogers , Alexander Shishkin , Andi Kleen , John Garry , Michael Petlan , Namhyung Kim , Paul Clarke , Peter Zijlstra , Stephane Eranian , lkml , Ingo Molnar , Peter Zijlstra Subject: [PATCH 12/19] perf metric: Add events for the current list Date: Wed, 29 Jul 2020 11:19:01 +0200 Message-Id: <20200729091908.1378911-13-jolsa@kernel.org> In-Reply-To: <20200729091908.1378911-1-jolsa@kernel.org> References: <20200729091908.1378911-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 There's no need to iterate the whole list of groups, when adding new events. The currently created groups are the ones we want to add. Signed-off-by: Jiri Olsa Reviewed-by: Kajol Jain Acked-by: Ian Rogers Cc: Alexander Shishkin Cc: Andi Kleen Cc: John Garry Cc: Michael Petlan Cc: Namhyung Kim Cc: Paul Clarke Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lore.kernel.org/lkml/20200719181320.785305-13-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/metricgroup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index a9f101948e1f..caec3696e52b 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -813,6 +813,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, { struct pmu_event *pe; struct egroup *eg; + LIST_HEAD(list); int i, ret; bool has_match = false; @@ -820,7 +821,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, has_match = true; eg = NULL; - ret = add_metric(group_list, pe, metric_no_group, &eg); + ret = add_metric(&list, pe, metric_no_group, &eg); if (ret) return ret; @@ -829,7 +830,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, * included in the expression. */ ret = resolve_metric(eg, metric_no_group, - group_list, map); + &list, map); if (ret) return ret; } @@ -838,7 +839,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, if (!has_match) return -EINVAL; - list_for_each_entry(eg, group_list, nd) { + list_for_each_entry(eg, &list, nd) { if (events->len > 0) strbuf_addf(events, ","); @@ -850,6 +851,8 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, &eg->pctx); } } + + list_splice(&list, group_list); return 0; } -- 2.25.4