[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fVXgKc0r+fup0+2-JOAtJERAsPq61MZh_f7HYTk2XqObg@mail.gmail.com>
Date: Wed, 14 Feb 2024 15:50:17 -0800
From: Ian Rogers <irogers@...gle.com>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>, Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>, Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
linux-perf-users@...r.kernel.org
Subject: Re: [PATCH 1/4] libperf evlist: Update group info in perf_evlist__remove()
On Mon, Feb 12, 2024 at 11:52 PM Namhyung Kim <namhyung@...nel.org> wrote:
>
> When an event in a group is removed, it should update the group status
> including the pointer to leader and number of member events.
>
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>
Should we worry about evlist's all_cpus that could also be stale now?
Thanks,
Ian
> ---
> tools/lib/perf/evlist.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
> index 058e3ff10f9b..befdb062fa1d 100644
> --- a/tools/lib/perf/evlist.c
> +++ b/tools/lib/perf/evlist.c
> @@ -102,8 +102,29 @@ void perf_evlist__add(struct perf_evlist *evlist,
> void perf_evlist__remove(struct perf_evlist *evlist,
> struct perf_evsel *evsel)
> {
> + struct perf_evsel *leader = evsel->leader;
> +
> list_del_init(&evsel->node);
> evlist->nr_entries -= 1;
> +
> + /* return stand-alone event */
> + if (leader == evsel && leader->nr_members < 2)
> + return;
> +
> + if (leader == evsel) {
> + struct perf_evsel *member;
> +
> + /* select the next event as a new leader */
> + leader = member = perf_evlist__next(evlist, evsel);
> +
> + /* update members to see the new leader */
> + while (member && member->leader == evsel) {
> + member->leader = leader;
> + member = perf_evlist__next(evlist, member);
> + }
> + }
> +
> + leader->nr_members = evsel->leader->nr_members - 1;
> }
>
> struct perf_evlist *perf_evlist__new(void)
> --
> 2.43.0.687.g38aa6559b0-goog
>
Powered by blists - more mailing lists