Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1159786
| From | Aleksa Sarai <cyphar@cyphar.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v13 3/5] cgroup, block: implement task_get_css() |
| Date | 2015-06-06 02:10 +0200 |
| Message-ID | <py9Qu-8cW-3@gated-at.bofh.it> (permalink) |
| References | <py9x7-7AM-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Tejun Heo <tj@kernel.org>
Implement task_get_css() which find and pins the css for the specified
task and subsys. As a task is always associated with an online css
for every subsystem except while the css_set update is propagating,
task_get_css() retries till css_tryget_online() succeeds.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
---
include/linux/cgroup.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 82319fb..a593e29 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -354,6 +354,31 @@ static inline struct cgroup_subsys_state *task_css(struct task_struct *task,
}
/**
+ * 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
* @subsys_id: the target subsystem ID
--
2.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v13 0/5] cgroup: add PIDs subsystem Aleksa Sarai <cyphar@cyphar.com> - 2015-06-06 01:50 +0200
[PATCH v13 3/5] cgroup, block: implement task_get_css() Aleksa Sarai <cyphar@cyphar.com> - 2015-06-06 02:10 +0200
[PATCH v13 5/5] cgroup: implement the PIDs subsystem Aleksa Sarai <cyphar@cyphar.com> - 2015-06-06 02:10 +0200
Re: [PATCH v13 5/5] cgroup: implement the PIDs subsystem Tejun Heo <tj@kernel.org> - 2015-06-09 07:00 +0200
[PATCH v13 1/5] cgroup: use bitmask to filter for_each_subsys Aleksa Sarai <cyphar@cyphar.com> - 2015-06-06 02:10 +0200
[PATCH v13 2/5] cgroup: replace explicit ss_mask checking with for_each_subsys_which Aleksa Sarai <cyphar@cyphar.com> - 2015-06-06 02:10 +0200
[PATCH v13 4/5] cgroup: allow a cgroup subsystem to reject a fork Aleksa Sarai <cyphar@cyphar.com> - 2015-06-06 02:10 +0200
Re: [PATCH v13 4/5] cgroup: allow a cgroup subsystem to reject a fork Tejun Heo <tj@kernel.org> - 2015-06-09 06:50 +0200
Re: [PATCH v13 4/5] cgroup: allow a cgroup subsystem to reject a fork Aleksa Sarai <cyphar@cyphar.com> - 2015-06-09 09:30 +0200
Re: [PATCH v13 4/5] cgroup: allow a cgroup subsystem to reject a fork Tejun Heo <tj@kernel.org> - 2015-06-09 09:30 +0200
csiph-web