|
@@ -773,6 +773,31 @@ static inline struct cgroup_subsys_state *task_css(struct task_struct *task,
|
|
|
return task_css_check(task, subsys_id, false);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * task_get_css - find and get the css for (task, subsys)
|
|
|
+ * @task: the target task
|
|
|
+ * @subsys_id: the target subsystem ID
|
|
|
+ *
|
|
|
+ * Find the css for the (@task, @subsys_id) combination, increment a
|
|
|
+ * reference on and return it. This function is guaranteed to return a
|
|
|
+ * valid css.
|
|
|
+ */
|
|
|
+static inline struct cgroup_subsys_state *
|
|
|
+task_get_css(struct task_struct *task, int subsys_id)
|
|
|
+{
|
|
|
+ struct cgroup_subsys_state *css;
|
|
|
+
|
|
|
+ rcu_read_lock();
|
|
|
+ while (true) {
|
|
|
+ css = task_css(task, subsys_id);
|
|
|
+ if (likely(css_tryget_online(css)))
|
|
|
+ break;
|
|
|
+ cpu_relax();
|
|
|
+ }
|
|
|
+ rcu_read_unlock();
|
|
|
+ return css;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* task_css_is_root - test whether a task belongs to the root css
|
|
|
* @task: the target task
|