if (evsel->max_events != ULONG_MAX && ++evsel->nr_events_printed == evsel->max_events) {
evsel__disable(evsel);
- perf_evsel__close(evsel);
+ evsel__close(evsel);
}
}
}
return err;
}
+
+void perf_evsel__close_fd(struct perf_evsel *evsel)
+{
+ int cpu, thread;
+
+ for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++)
+ for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) {
+ close(FD(evsel, cpu, thread));
+ FD(evsel, cpu, thread) = -1;
+ }
+}
+
+void perf_evsel__free_fd(struct perf_evsel *evsel)
+{
+ xyarray__delete(evsel->fd);
+ evsel->fd = NULL;
+}
+
+void perf_evsel__close(struct perf_evsel *evsel)
+{
+ if (evsel->fd == NULL)
+ return;
+
+ perf_evsel__close_fd(evsel);
+ perf_evsel__free_fd(evsel);
+}
};
int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
+void perf_evsel__close_fd(struct perf_evsel *evsel);
+void perf_evsel__free_fd(struct perf_evsel *evsel);
#endif /* __LIBPERF_INTERNAL_EVSEL_H */
LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel);
LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
struct perf_thread_map *threads);
+LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel);
#endif /* __LIBPERF_EVSEL_H */
perf_evsel__delete;
perf_evsel__init;
perf_evsel__open;
+ perf_evsel__close;
perf_evlist__new;
perf_evlist__delete;
perf_evlist__init;
perf_evsel__free_counts(evsel);
out_close_fd:
- perf_evsel__close_fd(evsel);
+ perf_evsel__close_fd(&evsel->core);
out_evsel_delete:
evsel__delete(evsel);
out_cpu_map_delete:
err = 0;
out_close_fd:
- perf_evsel__close_fd(evsel);
+ perf_evsel__close_fd(&evsel->core);
out_evsel_delete:
evsel__delete(evsel);
out_thread_map_delete:
#include <linux/err.h>
#include <linux/zalloc.h>
#include <perf/evlist.h>
+#include <perf/evsel.h>
#include <perf/cpumap.h>
#ifdef LACKS_SIGQUEUE_PROTOTYPE
struct evsel *evsel;
evlist__for_each_entry_reverse(evlist, evsel)
- perf_evsel__close(evsel);
+ evsel__close(evsel);
}
static int perf_evlist__create_syswide_maps(struct evlist *evlist)
is_open = false;
if (c2->leader == leader) {
if (is_open)
- perf_evsel__close(c2);
+ evsel__close(c2);
c2->leader = c2;
c2->core.nr_members = 0;
}
return 0;
}
-static void perf_evsel__free_fd(struct evsel *evsel)
-{
- xyarray__delete(evsel->core.fd);
- evsel->core.fd = NULL;
-}
-
static void perf_evsel__free_id(struct evsel *evsel)
{
xyarray__delete(evsel->sample_id);
}
}
-void perf_evsel__close_fd(struct evsel *evsel)
-{
- int cpu, thread;
-
- for (cpu = 0; cpu < xyarray__max_x(evsel->core.fd); cpu++)
- for (thread = 0; thread < xyarray__max_y(evsel->core.fd); ++thread) {
- close(FD(evsel, cpu, thread));
- FD(evsel, cpu, thread) = -1;
- }
-}
-
void perf_evsel__exit(struct evsel *evsel)
{
assert(list_empty(&evsel->core.node));
assert(evsel->evlist == NULL);
perf_evsel__free_counts(evsel);
- perf_evsel__free_fd(evsel);
+ perf_evsel__free_fd(&evsel->core);
perf_evsel__free_id(evsel);
perf_evsel__free_config_terms(evsel);
cgroup__put(evsel->cgrp);
return err;
}
-void perf_evsel__close(struct evsel *evsel)
+void evsel__close(struct evsel *evsel)
{
- if (evsel->core.fd == NULL)
- return;
-
- perf_evsel__close_fd(evsel);
- perf_evsel__free_fd(evsel);
+ perf_evsel__close(&evsel->core);
perf_evsel__free_id(evsel);
}
int perf_evsel__group_desc(struct evsel *evsel, char *buf, size_t size);
int perf_evsel__alloc_id(struct evsel *evsel, int ncpus, int nthreads);
-void perf_evsel__close_fd(struct evsel *evsel);
void __perf_evsel__set_sample_bit(struct evsel *evsel,
enum perf_event_sample_format bit);
struct perf_thread_map *threads);
int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
struct perf_thread_map *threads);
-void perf_evsel__close(struct evsel *evsel);
+void evsel__close(struct evsel *evsel);
struct perf_sample;