Re: [PATCH v1 2/4] perf evsel: Missed close when probing hybrid core PMUs

From: Arnaldo Carvalho de Melo
Date: Mon Jun 16 2025 - 12:26:43 EST


On Mon, Jun 16, 2025 at 09:04:41AM -0700, Ian Rogers wrote:
> On Fri, Jun 13, 2025 at 5:41 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
> > Add missing close to avoid leaking perf events. In past perfs this
> > mattered little as the function was just used by perf list. As the
> > function is now used to detect hybrid PMUs leaking the perf event is
> > somewhat more painful.

> Given this leads to leaking perf events on hybrid systems it would be
> nice to land this 1 liner in the next v6.15 rc pull request fixes if
> possible.

Sure.

Just one nit: while looking at:

void evsel__close(struct evsel *evsel)
{
if (evsel__is_retire_lat(evsel))
evsel__tpebs_close(evsel);
perf_evsel__close(&evsel->core);
perf_evsel__free_id(&evsel->core);
}

And then:

void evsel__delete(struct evsel *evsel)
{
if (!evsel)
return;

evsel__exit(evsel);
free(evsel);
}

and:

void evsel__exit(struct evsel *evsel)
{
assert(list_empty(&evsel->core.node));
assert(evsel->evlist == NULL);
if (evsel__is_retire_lat(evsel))
evsel__tpebs_close(evsel);
<SNIP>

I think that tpebs_close could be done just at evsel__close(), no?

The way it works I think there is no problem with calling it now twice,
but it fits better in evsel__close().

- Arnaldo