From nobody Sun Feb 8 08:42:23 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 291D0C77B75 for ; Tue, 23 May 2023 18:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238210AbjEWSiV (ORCPT ); Tue, 23 May 2023 14:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238202AbjEWSiL (ORCPT ); Tue, 23 May 2023 14:38:11 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A30AD1A8 for ; Tue, 23 May 2023 11:37:42 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba81b238ee8so78849276.0 for ; Tue, 23 May 2023 11:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684867061; x=1687459061; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=5EXNjvkTat2Mrjd9QzN+5oFCVBjhFpsk/0r+uHdavgk=; b=0xSaTKMrmKuk96Uegzb15Tdj9ZMszefyqLZVmD6gA3vc5YJWQR3xbYEfhWyP3gYKjw BNvFi5mFOshM+wXxq5agjUfCd9gTBiPncB0oAJ0AJklKn2mmva2sJ/ITsGvscQ/UCpIZ F+97qAIZDbFoPawhZtw5u3gS2Us8VgWdS0Kw+YSinYbL/e9cfzALiDV6yQ9Z7ZokNK+q toW4u+mRHkBb+8i0XG8m8lSdKWvebXE8AbggSWLNTEp5aqGMJIS2s3JuiMn5i2cslT3L ypWct5HXZN880H28c6AF/mPm+KZeG8SsOH/aWAR+tGKzWapNoH7Pa85bIY8GYjG3DGP3 bLHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684867061; x=1687459061; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5EXNjvkTat2Mrjd9QzN+5oFCVBjhFpsk/0r+uHdavgk=; b=NVddfrH/+Ym4MlCEkOwwaKJEEXrWXTb/6ulo4qzhZFYlCWcgWiZHtuGslPahclRBfl R2/j5oUGsoGJSjud3L/bi6Ae7TghF+UlWc27ct22AcuRgHvBKSmuxRcaWa9DaMiqz/9C LLcW+sknXqTnBqlFpmS2WYVWaAT12gi+IXrjEN1IxXrzwX1x3DVPHLkCzmEeY5fnGV59 9jsdyQSMiQwcb00rT6vE0npRCvMg1Zj+GeAh0mwJmrx+/zSdPiy49yfI/8aW6An2i18g 9Pi725bRyI5fjtOIVb7Bm41R3xWcoynWzJhfnmbjQDPD7MoxdbJItgsacIJSz0IZPYqp DYQw== X-Gm-Message-State: AC+VfDyL//tyxObLB3KBvszsQ4aNeELq6EkiO2oMokJN8rOCNs4gYhc/ EMQgsBA3pg6N5ewQvTwPaon01juVrtPV X-Google-Smtp-Source: ACHHUZ5CdkkGoEL4HvrMuSmiw17EFFzhIkpo6y6OMVWpI67zX/4MRIN+kc7EAZh3C+itNxV96vUdfOY2mWSJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:235b:5195:e7b8:a5c2]) (user=irogers job=sendgmr) by 2002:a05:6902:14f:b0:ba8:6148:4300 with SMTP id p15-20020a056902014f00b00ba861484300mr6219672ybh.6.1684867060821; Tue, 23 May 2023 11:37:40 -0700 (PDT) Date: Tue, 23 May 2023 11:36:19 -0700 In-Reply-To: <20230523183620.1147607-1-irogers@google.com> Message-Id: <20230523183620.1147607-2-irogers@google.com> Mime-Version: 1.0 References: <20230523183620.1147607-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v2 1/2] perf evsel: evsel__group_pmu_name fixes From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , Sandipan Das , James Clark , Dmitrii Dolgov <9erthalion6@gmail.com>, Changbin Du , Rob Herring , Xing Zhengjun , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previously the evsel__group_pmu_name would iterate the evsel's group, however, the list of evsels aren't yet sorted and so the loop may terminate prematurely. It is also not desirable to iterate the list of evsels during list_sort as the list may be broken. Precompute the group_pmu_name for the evsel before sorting, as part of the computation and only if necessary, iterate the whole list looking for group members so that being sorted isn't necessary. Move the group pmu name computation to parse-events.c given the closer dependency on the behavior of parse_events__sort_events_and_fix_groups. Fixes: 7abf0bccaaec ("perf evsel: Add function to compute group PMU name") Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 31 ++++----------- tools/perf/util/evsel.h | 2 +- tools/perf/util/parse-events.c | 70 ++++++++++++++++++++++++++++------ 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 2f5910b31fa9..3247773f9e24 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -290,6 +290,7 @@ void evsel__init(struct evsel *evsel, evsel->per_pkg_mask =3D NULL; evsel->collect_stat =3D false; evsel->pmu_name =3D NULL; + evsel->group_pmu_name =3D NULL; evsel->skippable =3D false; } =20 @@ -431,6 +432,11 @@ struct evsel *evsel__clone(struct evsel *orig) if (evsel->pmu_name =3D=3D NULL) goto out_err; } + if (orig->group_pmu_name) { + evsel->group_pmu_name =3D strdup(orig->group_pmu_name); + if (evsel->group_pmu_name =3D=3D NULL) + goto out_err; + } if (orig->filter) { evsel->filter =3D strdup(orig->filter); if (evsel->filter =3D=3D NULL) @@ -827,30 +833,6 @@ bool evsel__name_is(struct evsel *evsel, const char *n= ame) return !strcmp(evsel__name(evsel), name); } =20 -const char *evsel__group_pmu_name(const struct evsel *evsel) -{ - struct evsel *leader =3D evsel__leader(evsel); - struct evsel *pos; - - /* - * Software events may be in a group with other uncore PMU events. Use - * the pmu_name of the first non-software event to avoid breaking the - * software event out of the group. - * - * Aux event leaders, like intel_pt, expect a group with events from - * other PMUs, so substitute the AUX event's PMU in this case. - */ - if (evsel->core.attr.type =3D=3D PERF_TYPE_SOFTWARE || evsel__is_aux_even= t(leader)) { - /* Starting with the leader, find the first event with a named PMU. */ - for_each_group_evsel(pos, leader) { - if (pos->pmu_name) - return pos->pmu_name; - } - } - - return evsel->pmu_name ?: "cpu"; -} - const char *evsel__metric_id(const struct evsel *evsel) { if (evsel->metric_id) @@ -1536,6 +1518,7 @@ void evsel__exit(struct evsel *evsel) zfree(&evsel->group_name); zfree(&evsel->name); zfree(&evsel->pmu_name); + zfree(&evsel->group_pmu_name); zfree(&evsel->unit); zfree(&evsel->metric_id); evsel__zero_per_pkg(evsel); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index df8928745fc6..820771a649b2 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -72,6 +72,7 @@ struct evsel { char *name; char *group_name; const char *pmu_name; + const char *group_pmu_name; #ifdef HAVE_LIBTRACEEVENT struct tep_event *tp_format; #endif @@ -289,7 +290,6 @@ int arch_evsel__hw_name(struct evsel *evsel, char *bf, = size_t size); int __evsel__hw_cache_type_op_res_name(u8 type, u8 op, u8 result, char *bf= , size_t size); const char *evsel__name(struct evsel *evsel); bool evsel__name_is(struct evsel *evsel, const char *name); -const char *evsel__group_pmu_name(const struct evsel *evsel); const char *evsel__metric_id(const struct evsel *evsel); =20 static inline bool evsel__is_tool(const struct evsel *evsel) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 34ba840ae19a..9899953e91f0 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2125,6 +2125,42 @@ static int parse_events__with_hybrid_pmu(struct pars= e_events_state *parse_state, return ret; } =20 +static int evsel__compute_group_pmu_name(struct evsel *evsel, + const struct list_head *head) +{ + struct evsel *leader =3D evsel__leader(evsel); + struct evsel *pos; + const char *group_pmu_name =3D evsel->pmu_name ?: "cpu"; + + /* + * Software events may be in a group with other uncore PMU events. Use + * the pmu_name of the first non-software event to avoid breaking the + * software event out of the group. + * + * Aux event leaders, like intel_pt, expect a group with events from + * other PMUs, so substitute the AUX event's PMU in this case. + */ + if (evsel->core.attr.type =3D=3D PERF_TYPE_SOFTWARE || evsel__is_aux_even= t(leader)) { + /* + * Starting with the leader, find the first event with a named + * PMU. for_each_group_(member|evsel) isn't used as the list + * isn't yet sorted putting evsel's in the same group together. + */ + if (leader->pmu_name) { + group_pmu_name =3D leader->pmu_name; + } else if (leader->core.nr_members > 1) { + list_for_each_entry(pos, head, core.node) { + if (evsel__leader(pos) =3D=3D leader && pos->pmu_name) { + group_pmu_name =3D pos->pmu_name; + break; + } + } + } + } + evsel->group_pmu_name =3D strdup(group_pmu_name); + return evsel->group_pmu_name ? 0 : -ENOMEM; +} + __weak int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *r= hs) { /* Order by insertion index. */ @@ -2144,7 +2180,11 @@ static int evlist__cmp(void *state, const struct lis= t_head *l, const struct list =20 /* * First sort by grouping/leader. Read the leader idx only if the evsel - * is part of a group, as -1 indicates no group. + * is part of a group, by default ungrouped events will be sorted + * relative to grouped events based on where the first ungrouped event + * occurs. If both events don't have a group we want to fall-through to + * the arch specific sorting, that can reorder and fix things like + * Intel's topdown events. */ if (lhs_core->leader !=3D lhs_core || lhs_core->nr_members > 1) { lhs_has_group =3D true; @@ -2160,8 +2200,8 @@ static int evlist__cmp(void *state, const struct list= _head *l, const struct list =20 /* Group by PMU if there is a group. Groups can't span PMUs. */ if (lhs_has_group && rhs_has_group) { - lhs_pmu_name =3D evsel__group_pmu_name(lhs); - rhs_pmu_name =3D evsel__group_pmu_name(rhs); + lhs_pmu_name =3D lhs->group_pmu_name; + rhs_pmu_name =3D rhs->group_pmu_name; ret =3D strcmp(lhs_pmu_name, rhs_pmu_name); if (ret) return ret; @@ -2171,13 +2211,14 @@ static int evlist__cmp(void *state, const struct li= st_head *l, const struct list return arch_evlist__cmp(lhs, rhs); } =20 -static bool parse_events__sort_events_and_fix_groups(struct list_head *lis= t) +static int parse_events__sort_events_and_fix_groups(struct list_head *list) { int idx =3D 0, unsorted_idx =3D -1; struct evsel *pos, *cur_leader =3D NULL; struct perf_evsel *cur_leaders_grp =3D NULL; bool idx_changed =3D false; int orig_num_leaders =3D 0, num_leaders =3D 0; + int ret; =20 /* * Compute index to insert ungrouped events at. Place them where the @@ -2186,6 +2227,10 @@ static bool parse_events__sort_events_and_fix_groups= (struct list_head *list) list_for_each_entry(pos, list, core.node) { const struct evsel *pos_leader =3D evsel__leader(pos); =20 + ret =3D evsel__compute_group_pmu_name(pos, list); + if (ret) + return ret; + if (pos =3D=3D pos_leader) orig_num_leaders++; =20 @@ -2210,7 +2255,7 @@ static bool parse_events__sort_events_and_fix_groups(= struct list_head *list) idx =3D 0; list_for_each_entry(pos, list, core.node) { const struct evsel *pos_leader =3D evsel__leader(pos); - const char *pos_pmu_name =3D evsel__group_pmu_name(pos); + const char *pos_pmu_name =3D pos->group_pmu_name; const char *cur_leader_pmu_name, *pos_leader_pmu_name; bool force_grouped =3D arch_evsel__must_be_in_group(pos); =20 @@ -2227,7 +2272,7 @@ static bool parse_events__sort_events_and_fix_groups(= struct list_head *list) if (!cur_leader) cur_leader =3D pos; =20 - cur_leader_pmu_name =3D evsel__group_pmu_name(cur_leader); + cur_leader_pmu_name =3D cur_leader->group_pmu_name; if ((cur_leaders_grp !=3D pos->core.leader && !force_grouped) || strcmp(cur_leader_pmu_name, pos_pmu_name)) { /* Event is for a different group/PMU than last. */ @@ -2239,7 +2284,7 @@ static bool parse_events__sort_events_and_fix_groups(= struct list_head *list) */ cur_leaders_grp =3D pos->core.leader; } - pos_leader_pmu_name =3D evsel__group_pmu_name(pos_leader); + pos_leader_pmu_name =3D pos_leader->group_pmu_name; if (strcmp(pos_leader_pmu_name, pos_pmu_name) || force_grouped) { /* * Event's PMU differs from its leader's. Groups can't @@ -2256,7 +2301,7 @@ static bool parse_events__sort_events_and_fix_groups(= struct list_head *list) num_leaders++; pos_leader->core.nr_members++; } - return idx_changed || num_leaders !=3D orig_num_leaders; + return (idx_changed || num_leaders !=3D orig_num_leaders) ? 1 : 0; } =20 int __parse_events(struct evlist *evlist, const char *str, @@ -2271,7 +2316,7 @@ int __parse_events(struct evlist *evlist, const char = *str, .stoken =3D PE_START_EVENTS, .fake_pmu =3D fake_pmu, }; - int ret; + int ret, ret2; =20 ret =3D parse_events__scanner(str, &parse_state); perf_pmu__parse_cleanup(); @@ -2281,8 +2326,11 @@ int __parse_events(struct evlist *evlist, const char= *str, return -1; } =20 - if (parse_events__sort_events_and_fix_groups(&parse_state.list) && - warn_if_reordered && !parse_state.wild_card_pmus) + ret2 =3D parse_events__sort_events_and_fix_groups(&parse_state.list); + if (ret2 < 0) + return ret; + + if (ret2 && warn_if_reordered && !parse_state.wild_card_pmus) pr_warning("WARNING: events were regrouped to match PMUs\n"); =20 /* --=20 2.40.1.698.g37aff9b760-goog From nobody Sun Feb 8 08:42:23 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA1C7C7EE23 for ; Tue, 23 May 2023 18:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237890AbjEWSiZ (ORCPT ); Tue, 23 May 2023 14:38:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238224AbjEWSiN (ORCPT ); Tue, 23 May 2023 14:38:13 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15811E66 for ; Tue, 23 May 2023 11:37:48 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1ae8a684f70so23644155ad.2 for ; Tue, 23 May 2023 11:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684867065; x=1687459065; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=kT8nh0a8qE7iApgG/WqGXKFWbJPIePlSK9niqbotYPE=; b=aTpW5smB5TQGvTi6WvjyPhcuRFe3gsUBAmXHCfFrOJukCc2WCwDjdSj06tUVnj0xPp +AwJ9LJ6GAwJJtOmqtxZ6sZetREqspqTjeOhQTX3NbsoLYT4TnVL0yUY70Fwi1Gq2AjA xqom3x6gBKPyJ7oRJ4reQ0X6Iq7zMqWUp6Gm3NZW3jiHHCvABt66ZonA0cy/zxqJ2hf8 Vnm4Cbq0UcBoAiTCmmKEDAnV8553Z///RH6nG56mWcL3f9Lg7eJW4X/QWbaoqOqVreO1 oHOg/GAbsLkGpRtD9F6T3GC61Y9XiU3OXDIWHQBQzEwvKn098cd94aeAYwXF3gZXiHhL +AKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684867065; x=1687459065; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kT8nh0a8qE7iApgG/WqGXKFWbJPIePlSK9niqbotYPE=; b=kGhjRVmZx7YbXBn0qfJvrnXFcvYLGMHB0GY+RJebOh0ovSGuwjaIDuPYcXEMys2uuL kcJBhsDltVk9nxfnMf18Sdn3oQ2SX3MlRs6P1MOvEpmtVZyhtj1Uvr0lBEJF/nyq5MxY LeoSx+3pYaqpFO0nkvAQ1wKbxTwuGZrKfQRGXDM9mU5e+C5lLhYri72GqzA/gKWoILwg 3SuAkC//H+51ciwj/pV5zl+dq4wnYvU2foJ9ZVLTDazybCeXci/aB+UqZ8uf0ngT0ouT kz9M2fi1y3Vjw5cCHcsq+7K41s1E23t1h04oVaghcjGBV8WXVqdwFy2F0Pr4GM3MgYyi 7jfg== X-Gm-Message-State: AC+VfDwQd6gLxhZzq21iar0L4rX0V+Ejk1WyRPgEj2xeb6bemWU/CB7s HpBNCHvlO5NFzCHtRrJfQ9Otygn7vV8a X-Google-Smtp-Source: ACHHUZ4PQFKtv729+iCwOEUgki+Ep3H2gS/hh1ENMY3MysqOnf+Gwmo96GodgAsnd6U7LzPdmk8gBPJmpRcJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:235b:5195:e7b8:a5c2]) (user=irogers job=sendgmr) by 2002:a17:902:eb11:b0:1a1:b318:2776 with SMTP id l17-20020a170902eb1100b001a1b3182776mr3599522plb.0.1684867065225; Tue, 23 May 2023 11:37:45 -0700 (PDT) Date: Tue, 23 May 2023 11:36:20 -0700 In-Reply-To: <20230523183620.1147607-1-irogers@google.com> Message-Id: <20230523183620.1147607-3-irogers@google.com> Mime-Version: 1.0 References: <20230523183620.1147607-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v2 2/2] perf evsel: for_each_group fixes From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , Sandipan Das , James Clark , Dmitrii Dolgov <9erthalion6@gmail.com>, Changbin Du , Rob Herring , Xing Zhengjun , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Address/memory sanitizer was reporting issues in evsel__group_pmu_name because the for_each_group_evsel loop didn't terminate when the head was reached, the head would then be cast and accessed as an evsel leading to invalid memory accesses. Fix for_each_group_member and for_each_group_evsel to terminate at the list head. Note, evsel__group_pmu_name no longer iterates the group, but the problem is present regardless. Fixes: 717e263fc354 ("perf report: Show group description when event group = is enabled") Signed-off-by: Ian Rogers --- tools/perf/util/evsel.h | 24 ++++++++++++++++-------- tools/perf/util/evsel_fprintf.c | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 820771a649b2..b3ed360194a1 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -462,16 +462,24 @@ static inline int evsel__group_idx(struct evsel *evse= l) } =20 /* Iterates group WITHOUT the leader. */ -#define for_each_group_member(_evsel, _leader) \ -for ((_evsel) =3D list_entry((_leader)->core.node.next, struct evsel, core= .node); \ - (_evsel) && (_evsel)->core.leader =3D=3D (&_leader->core); \ - (_evsel) =3D list_entry((_evsel)->core.node.next, struct evsel, core.= node)) +#define for_each_group_member_head(_evsel, _leader, _head) \ +for ((_evsel) =3D list_entry((_leader)->core.node.next, struct evsel, core= .node); \ + (_evsel) && &(_evsel)->core.node !=3D (_head) && \ + (_evsel)->core.leader =3D=3D &(_leader)->core; \ + (_evsel) =3D list_entry((_evsel)->core.node.next, struct evsel, core.node= )) + +#define for_each_group_member(_evsel, _leader) \ + for_each_group_member_head(_evsel, _leader, &(_leader)->evlist->core.entr= ies) =20 /* Iterates group WITH the leader. */ -#define for_each_group_evsel(_evsel, _leader) \ -for ((_evsel) =3D _leader; \ - (_evsel) && (_evsel)->core.leader =3D=3D (&_leader->core); \ - (_evsel) =3D list_entry((_evsel)->core.node.next, struct evsel, core.= node)) +#define for_each_group_evsel_head(_evsel, _leader, _head) \ +for ((_evsel) =3D _leader; \ + (_evsel) && &(_evsel)->core.node !=3D (_head) && \ + (_evsel)->core.leader =3D=3D &(_leader)->core; \ + (_evsel) =3D list_entry((_evsel)->core.node.next, struct evsel, core.node= )) + +#define for_each_group_evsel(_evsel, _leader) \ + for_each_group_evsel_head(_evsel, _leader, &(_leader)->evlist->core.entri= es) =20 static inline bool evsel__has_branch_callstack(const struct evsel *evsel) { diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprint= f.c index cc80ec554c0a..036a2171dc1c 100644 --- a/tools/perf/util/evsel_fprintf.c +++ b/tools/perf/util/evsel_fprintf.c @@ -2,6 +2,7 @@ #include #include #include +#include "util/evlist.h" #include "evsel.h" #include "util/evsel_fprintf.h" #include "util/event.h" --=20 2.40.1.698.g37aff9b760-goog