@@ -97,6 +97,8 @@ extern struct css_set init_css_set;
bool css_has_online_children(struct cgroup_subsys_state *css);
struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss);
+struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgroup,
+ struct cgroup_subsys *ss);
struct cgroup_subsys_state *cgroup_e_css(struct cgroup *cgroup,
struct cgroup_subsys *ss);
struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgroup,
@@ -926,6 +926,8 @@ struct perf_cgroup {
struct perf_cgroup_info __percpu *info;
};
+extern struct perf_cgroup *cgroup_tryget_perf_cgroup(struct cgroup *cgrp);
+
/*
* Must ensure cgroup is pinned (css_get) before calling
* this function. In other words, we cannot call this function
@@ -495,8 +495,8 @@ static struct cgroup_subsys_state *cgroup_css(struct cgroup *cgrp,
* Find and get @cgrp's css associated with @ss. If the css doesn't exist
* or is offline, %NULL is returned.
*/
-static struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgrp,
- struct cgroup_subsys *ss)
+struct cgroup_subsys_state *cgroup_tryget_css(struct cgroup *cgrp,
+ struct cgroup_subsys *ss)
{
struct cgroup_subsys_state *css;
@@ -941,6 +941,18 @@ static int perf_cgroup_ensure_storage(struct perf_event *event,
return ret;
}
+struct perf_cgroup *cgroup_tryget_perf_cgroup(struct cgroup *cgrp)
+{
+ struct cgroup_subsys_state *css;
+
+ css = cgroup_tryget_css(cgrp, &perf_event_cgrp_subsys);
+
+ if (!css)
+ return NULL;
+
+ return container_of(css, struct perf_cgroup, css);
+}
+
static inline int perf_cgroup_connect(int fd, struct perf_event *event,
struct perf_event_attr *attr,
struct perf_event *group_leader)
@@ -1080,6 +1092,11 @@ static inline void perf_cgroup_sched_in(struct task_struct *prev,
{
}
+struct perf_cgroup *cgroup_tryget_perf_cgroup(struct cgroup *cgrp)
+{
+ return NULL;
+}
+
static inline int perf_cgroup_connect(pid_t pid, struct perf_event *event,
struct perf_event_attr *attr,
struct perf_event *group_leader)
This provides the ability to allocate cgroup specific perf_event by bpf-cgroup in later patch Change-Id: I13aa7f3dfc2883ba3663c0b94744a6169504bbd8 Signed-off-by: Kenny Ho <Kenny.Ho@amd.com> --- include/linux/cgroup.h | 2 ++ include/linux/perf_event.h | 2 ++ kernel/cgroup/cgroup.c | 4 ++-- kernel/events/core.c | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-)