From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Andi Kleen <ak@linux.intel.com>, Jiri Olsa <jolsa@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
John Garry <john.garry@huawei.com>,
Kajol Jain <kjain@linux.ibm.com>,
"Paul A . Clarke" <pc@us.ibm.com>,
Riccardo Mancini <rickyman7@gmail.com>,
Kan Liang <kan.liang@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Vineet Singh <vineet.singh@intel.com>,
eranian@google.com
Subject: Re: [PATCH v3 1/2] perf evlist: Allow setting arbitrary leader
Date: Tue, 30 Nov 2021 16:27:45 -0300 [thread overview]
Message-ID: <YaZ7MUK7Ie4mHvTg@kernel.org> (raw)
In-Reply-To: <20211130174945.247604-1-irogers@google.com>
Em Tue, Nov 30, 2021 at 09:49:44AM -0800, Ian Rogers escreveu:
> The leader of a group is the first, but allow it to be an arbitrary
> list member so that for Intel topdown events slots may always be the
> group leader.
>
> v3. Switched list_entry to list_first_entry as suggested by Arnaldo
> Carvalho de Melo <acme@kernel.org>.
Thanks, applied both patches.
- Arnaldo
> Reviewed-by: Kajol Jain<kjain@linux.ibm.com>
> Acked-by: Jiri Olsa <jolsa@redhat.com>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/lib/perf/evlist.c | 15 +++++++++------
> tools/lib/perf/include/internal/evlist.h | 2 +-
> tools/perf/util/parse-events.c | 4 ++--
> 3 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
> index e37dfad31383..245acbc53bd3 100644
> --- a/tools/lib/perf/evlist.c
> +++ b/tools/lib/perf/evlist.c
> @@ -643,14 +643,14 @@ perf_evlist__next_mmap(struct perf_evlist *evlist, struct perf_mmap *map,
> return overwrite ? evlist->mmap_ovw_first : evlist->mmap_first;
> }
>
> -void __perf_evlist__set_leader(struct list_head *list)
> +void __perf_evlist__set_leader(struct list_head *list, struct perf_evsel *leader)
> {
> - struct perf_evsel *evsel, *leader;
> + struct perf_evsel *first, *last, *evsel;
>
> - leader = list_entry(list->next, struct perf_evsel, node);
> - evsel = list_entry(list->prev, struct perf_evsel, node);
> + first = list_first_entry(list, struct perf_evsel, node);
> + last = list_last_entry(list, struct perf_evsel, node);
>
> - leader->nr_members = evsel->idx - leader->idx + 1;
> + leader->nr_members = last->idx - first->idx + 1;
>
> __perf_evlist__for_each_entry(list, evsel)
> evsel->leader = leader;
> @@ -659,7 +659,10 @@ void __perf_evlist__set_leader(struct list_head *list)
> void perf_evlist__set_leader(struct perf_evlist *evlist)
> {
> if (evlist->nr_entries) {
> + struct perf_evsel *first = list_entry(evlist->entries.next,
> + struct perf_evsel, node);
> +
> evlist->nr_groups = evlist->nr_entries > 1 ? 1 : 0;
> - __perf_evlist__set_leader(&evlist->entries);
> + __perf_evlist__set_leader(&evlist->entries, first);
> }
> }
> diff --git a/tools/lib/perf/include/internal/evlist.h b/tools/lib/perf/include/internal/evlist.h
> index f366dbad6a88..6f74269a3ad4 100644
> --- a/tools/lib/perf/include/internal/evlist.h
> +++ b/tools/lib/perf/include/internal/evlist.h
> @@ -127,5 +127,5 @@ int perf_evlist__id_add_fd(struct perf_evlist *evlist,
>
> void perf_evlist__reset_id_hash(struct perf_evlist *evlist);
>
> -void __perf_evlist__set_leader(struct list_head *list);
> +void __perf_evlist__set_leader(struct list_head *list, struct perf_evsel *leader);
> #endif /* __LIBPERF_INTERNAL_EVLIST_H */
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 5bfb6f892489..c2935aca4b67 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -1834,8 +1834,8 @@ void parse_events__set_leader(char *name, struct list_head *list,
> if (parse_events__set_leader_for_uncore_aliase(name, list, parse_state))
> return;
>
> - __perf_evlist__set_leader(list);
> - leader = list_entry(list->next, struct evsel, core.node);
> + leader = list_first_entry(list, struct evsel, core.node);
> + __perf_evlist__set_leader(list, &leader->core);
> leader->group_name = name ? strdup(name) : NULL;
> }
>
> --
> 2.34.0.rc2.393.gf8c9666880-goog
--
- Arnaldo
prev parent reply other threads:[~2021-11-30 19:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-30 17:49 [PATCH v3 1/2] perf evlist: Allow setting arbitrary leader Ian Rogers
2021-11-30 17:49 ` [PATCH v3 2/2] perf parse-events: Architecture specific leader override Ian Rogers
2021-11-30 19:27 ` Arnaldo Carvalho de Melo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YaZ7MUK7Ie4mHvTg@kernel.org \
--to=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=john.garry@huawei.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=pc@us.ibm.com \
--cc=peterz@infradead.org \
--cc=rickyman7@gmail.com \
--cc=vineet.singh@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).