Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1159786

[PATCH v13 3/5] cgroup, block: implement task_get_css()

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Aleksa Sarai <cyphar@cyphar.com>
Newsgroups linux.kernel
Subject [PATCH v13 3/5] cgroup, block: implement task_get_css()
Date Sat, 06 Jun 2015 02:10:02 +0200
Message-ID <py9Qu-8cW-3@gated-at.bofh.it> (permalink)
References <py9x7-7AM-3@gated-at.bofh.it>
X-Original-To tj@kernel.org, lizefan@huawei.com, mingo@redhat.com, peterz@infradead.org
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wKdjQl5TOYy2/UNTFW7Z4RVW3FIZEI9g4IUXNhbQKQ4=; b=g3K90QWRVm2KnRO7j4tUlasTxznpbUzcM5y1fB3RtIS4GR2gWJKI9EHXLpuiQgxwVZ iqPRL+AG7djK4BTBpSpndgID51r5JTx9WItOdQw6ZdyHfokCPCaRUCLWtVcpRYNvuRl9 OM/IhgFpt8iKUMUqwxifCUOPMNcykrIYPQ5+bkfT2Ck3iYecw4ttKdWfA1+3FJwTgxMW bmNk0JVT7qGv7xDMXyrdvAWizfRzPa+ARShZge6ziM+TFeTIViIZc9hOM9w9XakLI8Ym PihITL0HFz0wU0mZvAxUT/iwBr2M/44qLtO9P59sP6ZzoDgv76giLszgXxpWdPfb+XWw mkhw==
X-Gm-Message-State ALoCoQlluYNmFTK0WugDBJTDHqnozdM+xW1TGmvtykAQWAYTqeyRJtXiIYDAI6KSLHYo2KAh+KbR
X-Received by 10.70.138.8 with SMTP id qm8mr9678191pdb.96.1433548972922; Fri, 05 Jun 2015 17:02:52 -0700 (PDT)
X-Mailer git-send-email 2.4.2
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 57
Organization linux.* mail to news gateway
X-Original-Cc richard@nod.at, fweisbec@gmail.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
X-Original-Date Sat, 6 Jun 2015 10:02:16 +1000
X-Original-Message-ID <1433548938-32560-3-git-send-email-cyphar@cyphar.com>
X-Original-References <1433547736-11707-1-git-send-email-cyphar@cyphar.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1159786

Show key headers only | View raw


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


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