Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
023695d9 SE |
2 | #ifndef __CGROUP_H__ |
3 | #define __CGROUP_H__ | |
4 | ||
69e874db | 5 | #include <linux/compiler.h> |
79c5fe6d | 6 | #include <linux/refcount.h> |
d1277aa3 NK |
7 | #include <linux/rbtree.h> |
8 | #include "util/env.h" | |
f812d304 | 9 | |
023695d9 SE |
10 | struct option; |
11 | ||
3ca32f69 | 12 | struct cgroup { |
d1277aa3 NK |
13 | struct rb_node node; |
14 | u64 id; | |
15 | char *name; | |
16 | int fd; | |
17 | refcount_t refcnt; | |
023695d9 SE |
18 | }; |
19 | ||
023695d9 | 20 | extern int nr_cgroups; /* number of explicit cgroups defined */ |
944138f0 | 21 | extern bool cgrp_event_expanded; |
a53b6460 | 22 | |
fc9ffb9c | 23 | struct cgroup *cgroup__get(struct cgroup *cgroup); |
a53b6460 | 24 | void cgroup__put(struct cgroup *cgroup); |
3ca32f69 | 25 | |
63503dba | 26 | struct evlist; |
b214ba8c | 27 | struct rblist; |
69239ec8 | 28 | |
4fd06bd2 | 29 | struct cgroup *cgroup__new(const char *name, bool do_open); |
63503dba | 30 | struct cgroup *evlist__findnew_cgroup(struct evlist *evlist, const char *name); |
b214ba8c | 31 | int evlist__expand_cgroup(struct evlist *evlist, const char *cgroups, |
89fb1ca2 | 32 | struct rblist *metric_events, bool open_cgroup); |
69239ec8 | 33 | |
63503dba | 34 | void evlist__set_default_cgroup(struct evlist *evlist, struct cgroup *cgroup); |
483322dd | 35 | |
3938bad4 | 36 | int parse_cgroups(const struct option *opt, const char *str, int unset); |
023695d9 | 37 | |
d1277aa3 NK |
38 | struct cgroup *cgroup__findnew(struct perf_env *env, uint64_t id, |
39 | const char *path); | |
40 | struct cgroup *cgroup__find(struct perf_env *env, uint64_t id); | |
2bc12abc | 41 | struct cgroup *__cgroup__find(struct rb_root *root, uint64_t id); |
d1277aa3 NK |
42 | |
43 | void perf_env__purge_cgroups(struct perf_env *env); | |
44 | ||
69e874db NK |
45 | #ifdef HAVE_FILE_HANDLE |
46 | int read_cgroup_id(struct cgroup *cgrp); | |
47 | #else | |
48 | static inline int read_cgroup_id(struct cgroup *cgrp __maybe_unused) | |
49 | { | |
50 | return -1; | |
51 | } | |
52 | #endif /* HAVE_FILE_HANDLE */ | |
53 | ||
2bc12abc NK |
54 | /* read all cgroups in the system and save them in the rbtree */ |
55 | void read_all_cgroups(struct rb_root *root); | |
56 | ||
21bcc726 NK |
57 | int cgroup_is_v2(const char *subsys); |
58 | ||
023695d9 | 59 | #endif /* __CGROUP_H__ */ |