Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932220AbbERO6F (ORCPT ); Mon, 18 May 2015 10:58:05 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:35985 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbbERO54 (ORCPT ); Mon, 18 May 2015 10:57:56 -0400 From: Aleksa Sarai To: tj@kernel.org, lizefan@huawei.com, mingo@redhat.com, peterz@infradead.org Cc: richard@nod.at, fweisbec@gmail.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Aleksa Sarai Subject: [PATCH v12 7/8] cgroup: add a tset_get_css macro Date: Tue, 19 May 2015 00:51:06 +1000 Message-Id: <1431960667-26593-8-git-send-email-cyphar@cyphar.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1431960667-26593-1-git-send-email-cyphar@cyphar.com> References: <1431960667-26593-1-git-send-email-cyphar@cyphar.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1526 Lines: 42 This adds a macro to get the css of a tset (using task_get_css()) by just grabbing a ref to the first item in the tset (since there is a guarantee that all tasks in a tset share a css). This is in preparation for implementing the pids cgroup subsystem. Signed-off-by: Aleksa Sarai --- include/linux/cgroup.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 886a883..773846d 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -639,6 +639,18 @@ struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset); for ((task) = cgroup_taskset_first((tset)); (task); \ (task) = cgroup_taskset_next((tset))) +/** + * tset_get_css - obtain and get css for (tset, subsys_id) + * @tset: target taskset + * @subsys_id: target subsystem id + * + * Since all of the tasks in a taskset are guaranteed to have the same css, it's + * safe to grab the ref of just the first task's css and treat it as though you + * have a ref on the taskset's "collective" css. + */ +#define tset_get_css(tset, subsys_id) \ + task_get_css(cgroup_taskset_first(tset), subsys_id) + /* * Control Group subsystem type. * See Documentation/cgroups/cgroups.txt for details -- 2.4.1 -- 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/