summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup_freezer.c11
-rw-r--r--kernel/cpuset.c11
-rw-r--r--kernel/sched/core.c8
-rw-r--r--kernel/sched/cpuacct.c11
4 files changed, 27 insertions, 14 deletions
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index 9d3f61566fec..1db686e47a22 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -45,16 +45,19 @@ struct freezer {
spinlock_t lock;
};
+static inline struct freezer *css_freezer(struct cgroup_subsys_state *css)
+{
+ return css ? container_of(css, struct freezer, css) : NULL;
+}
+
static inline struct freezer *cgroup_freezer(struct cgroup *cgroup)
{
- return container_of(cgroup_css(cgroup, freezer_subsys_id),
- struct freezer, css);
+ return css_freezer(cgroup_css(cgroup, freezer_subsys_id));
}
static inline struct freezer *task_freezer(struct task_struct *task)
{
- return container_of(task_css(task, freezer_subsys_id),
- struct freezer, css);
+ return css_freezer(task_css(task, freezer_subsys_id));
}
static struct freezer *parent_freezer(struct freezer *freezer)
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index f7371341d42a..6e9cbdde25bd 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -114,18 +114,21 @@ struct cpuset {
int relax_domain_level;
};
+static inline struct cpuset *css_cs(struct cgroup_subsys_state *css)
+{
+ return css ? container_of(css, struct cpuset, css) : NULL;
+}
+
/* Retrieve the cpuset for a cgroup */
static inline struct cpuset *cgroup_cs(struct cgroup *cgrp)
{
- return container_of(cgroup_css(cgrp, cpuset_subsys_id),
- struct cpuset, css);
+ return css_cs(cgroup_css(cgrp, cpuset_subsys_id));
}
/* Retrieve the cpuset for a task */
static inline struct cpuset *task_cs(struct task_struct *task)
{
- return container_of(task_css(task, cpuset_subsys_id),
- struct cpuset, css);
+ return css_cs(task_css(task, cpuset_subsys_id));
}
static inline struct cpuset *parent_cs(struct cpuset *cs)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 323d907eac1a..5bccb0277129 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7083,11 +7083,15 @@ int sched_rt_handler(struct ctl_table *table, int write,
#ifdef CONFIG_CGROUP_SCHED
+static inline struct task_group *css_tg(struct cgroup_subsys_state *css)
+{
+ return css ? container_of(css, struct task_group, css) : NULL;
+}
+
/* return corresponding task_group object of a cgroup */
static inline struct task_group *cgroup_tg(struct cgroup *cgrp)
{
- return container_of(cgroup_css(cgrp, cpu_cgroup_subsys_id),
- struct task_group, css);
+ return css_tg(cgroup_css(cgrp, cpu_cgroup_subsys_id));
}
static struct cgroup_subsys_state *cpu_cgroup_css_alloc(struct cgroup *cgrp)
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 4a210faaab77..8ccfa10cc89f 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -33,18 +33,21 @@ struct cpuacct {
struct kernel_cpustat __percpu *cpustat;
};
+static inline struct cpuacct *css_ca(struct cgroup_subsys_state *css)
+{
+ return css ? container_of(css, struct cpuacct, css) : NULL;
+}
+
/* return cpu accounting group corresponding to this container */
static inline struct cpuacct *cgroup_ca(struct cgroup *cgrp)
{
- return container_of(cgroup_css(cgrp, cpuacct_subsys_id),
- struct cpuacct, css);
+ return css_ca(cgroup_css(cgrp, cpuacct_subsys_id));
}
/* return cpu accounting group to which this task belongs */
static inline struct cpuacct *task_ca(struct task_struct *tsk)
{
- return container_of(task_css(tsk, cpuacct_subsys_id),
- struct cpuacct, css);
+ return css_ca(task_css(tsk, cpuacct_subsys_id));
}
static inline struct cpuacct *__parent_ca(struct cpuacct *ca)