^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __CGROUP_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __CGROUP_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/refcount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/rbtree.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "util/env.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) struct option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct cgroup {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct rb_node node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) u64 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) refcount_t refcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) extern int nr_cgroups; /* number of explicit cgroups defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct cgroup *cgroup__get(struct cgroup *cgroup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) void cgroup__put(struct cgroup *cgroup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct evlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct rblist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct cgroup *evlist__findnew_cgroup(struct evlist *evlist, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int evlist__expand_cgroup(struct evlist *evlist, const char *cgroups,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct rblist *metric_events, bool open_cgroup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void evlist__set_default_cgroup(struct evlist *evlist, struct cgroup *cgroup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int parse_cgroups(const struct option *opt, const char *str, int unset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct cgroup *cgroup__findnew(struct perf_env *env, uint64_t id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) const char *path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct cgroup *cgroup__find(struct perf_env *env, uint64_t id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) void perf_env__purge_cgroups(struct perf_env *env);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #endif /* __CGROUP_H__ */