Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __CGROUP_H__
0003 #define __CGROUP_H__
0004 
0005 #include <linux/compiler.h>
0006 #include <linux/refcount.h>
0007 #include <linux/rbtree.h>
0008 #include "util/env.h"
0009 
0010 struct option;
0011 
0012 struct cgroup {
0013     struct rb_node      node;
0014     u64         id;
0015     char            *name;
0016     int         fd;
0017     refcount_t      refcnt;
0018 };
0019 
0020 extern int nr_cgroups; /* number of explicit cgroups defined */
0021 extern bool cgrp_event_expanded;
0022 
0023 struct cgroup *cgroup__get(struct cgroup *cgroup);
0024 void cgroup__put(struct cgroup *cgroup);
0025 
0026 struct evlist;
0027 struct rblist;
0028 
0029 struct cgroup *evlist__findnew_cgroup(struct evlist *evlist, const char *name);
0030 int evlist__expand_cgroup(struct evlist *evlist, const char *cgroups,
0031               struct rblist *metric_events, bool open_cgroup);
0032 
0033 void evlist__set_default_cgroup(struct evlist *evlist, struct cgroup *cgroup);
0034 
0035 int parse_cgroups(const struct option *opt, const char *str, int unset);
0036 
0037 struct cgroup *cgroup__findnew(struct perf_env *env, uint64_t id,
0038                    const char *path);
0039 struct cgroup *cgroup__find(struct perf_env *env, uint64_t id);
0040 
0041 void perf_env__purge_cgroups(struct perf_env *env);
0042 
0043 #ifdef HAVE_FILE_HANDLE
0044 int read_cgroup_id(struct cgroup *cgrp);
0045 #else
0046 static inline int read_cgroup_id(struct cgroup *cgrp __maybe_unused)
0047 {
0048     return -1;
0049 }
0050 #endif  /* HAVE_FILE_HANDLE */
0051 
0052 int cgroup_is_v2(const char *subsys);
0053 
0054 #endif /* __CGROUP_H__ */