Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libperf evsel: Factor perf_evsel__exit out of perf_evsel__delete

This allows the perf_evsel__exit to be called when the struct
perf_evsel is embedded inside another struct, such as struct evsel in
perf.

Reviewed-by: Thomas Falcon <thomas.falcon@intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250719030517.1990983-8-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
9a711ef3 6d765f5f

+7 -1
+6 -1
tools/lib/perf/evsel.c
··· 40 40 return evsel; 41 41 } 42 42 43 - void perf_evsel__delete(struct perf_evsel *evsel) 43 + void perf_evsel__exit(struct perf_evsel *evsel) 44 44 { 45 45 assert(evsel->fd == NULL); /* If not fds were not closed. */ 46 46 assert(evsel->mmap == NULL); /* If not munmap wasn't called. */ ··· 48 48 perf_cpu_map__put(evsel->cpus); 49 49 perf_cpu_map__put(evsel->pmu_cpus); 50 50 perf_thread_map__put(evsel->threads); 51 + } 52 + 53 + void perf_evsel__delete(struct perf_evsel *evsel) 54 + { 55 + perf_evsel__exit(evsel); 51 56 free(evsel); 52 57 } 53 58
+1
tools/lib/perf/include/internal/evsel.h
··· 133 133 134 134 void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr, 135 135 int idx); 136 + void perf_evsel__exit(struct perf_evsel *evsel); 136 137 int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 137 138 void perf_evsel__close_fd(struct perf_evsel *evsel); 138 139 void perf_evsel__free_fd(struct perf_evsel *evsel);