18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __CGROUP_H__ 38c2ecf20Sopenharmony_ci#define __CGROUP_H__ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/refcount.h> 68c2ecf20Sopenharmony_ci#include <linux/rbtree.h> 78c2ecf20Sopenharmony_ci#include "util/env.h" 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct option; 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistruct cgroup { 128c2ecf20Sopenharmony_ci struct rb_node node; 138c2ecf20Sopenharmony_ci u64 id; 148c2ecf20Sopenharmony_ci char *name; 158c2ecf20Sopenharmony_ci int fd; 168c2ecf20Sopenharmony_ci refcount_t refcnt; 178c2ecf20Sopenharmony_ci}; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ciextern int nr_cgroups; /* number of explicit cgroups defined */ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistruct cgroup *cgroup__get(struct cgroup *cgroup); 228c2ecf20Sopenharmony_civoid cgroup__put(struct cgroup *cgroup); 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistruct evlist; 258c2ecf20Sopenharmony_cistruct rblist; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistruct cgroup *evlist__findnew_cgroup(struct evlist *evlist, const char *name); 288c2ecf20Sopenharmony_ciint evlist__expand_cgroup(struct evlist *evlist, const char *cgroups, 298c2ecf20Sopenharmony_ci struct rblist *metric_events, bool open_cgroup); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_civoid evlist__set_default_cgroup(struct evlist *evlist, struct cgroup *cgroup); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciint parse_cgroups(const struct option *opt, const char *str, int unset); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct cgroup *cgroup__findnew(struct perf_env *env, uint64_t id, 368c2ecf20Sopenharmony_ci const char *path); 378c2ecf20Sopenharmony_cistruct cgroup *cgroup__find(struct perf_env *env, uint64_t id); 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_civoid perf_env__purge_cgroups(struct perf_env *env); 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#endif /* __CGROUP_H__ */ 42