blob: 162906f3412ae3b42f322425da3a4d0b5fe52119 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __CGROUP_H__
3#define __CGROUP_H__
4
5#include <linux/refcount.h>
Olivier Deprez157378f2022-04-04 15:47:50 +02006#include <linux/rbtree.h>
7#include "util/env.h"
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00008
9struct option;
10
11struct cgroup {
Olivier Deprez157378f2022-04-04 15:47:50 +020012 struct rb_node node;
13 u64 id;
14 char *name;
15 int fd;
16 refcount_t refcnt;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000017};
18
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000019extern int nr_cgroups; /* number of explicit cgroups defined */
20
21struct cgroup *cgroup__get(struct cgroup *cgroup);
22void cgroup__put(struct cgroup *cgroup);
23
David Brazdil0f672f62019-12-10 10:32:29 +000024struct evlist;
Olivier Deprez157378f2022-04-04 15:47:50 +020025struct rblist;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000026
David Brazdil0f672f62019-12-10 10:32:29 +000027struct cgroup *evlist__findnew_cgroup(struct evlist *evlist, const char *name);
Olivier Deprez157378f2022-04-04 15:47:50 +020028int evlist__expand_cgroup(struct evlist *evlist, const char *cgroups,
29 struct rblist *metric_events, bool open_cgroup);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000030
David Brazdil0f672f62019-12-10 10:32:29 +000031void evlist__set_default_cgroup(struct evlist *evlist, struct cgroup *cgroup);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000032
33int parse_cgroups(const struct option *opt, const char *str, int unset);
34
Olivier Deprez157378f2022-04-04 15:47:50 +020035struct cgroup *cgroup__findnew(struct perf_env *env, uint64_t id,
36 const char *path);
37struct cgroup *cgroup__find(struct perf_env *env, uint64_t id);
38
39void perf_env__purge_cgroups(struct perf_env *env);
40
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000041#endif /* __CGROUP_H__ */