From patchwork Sat Jan 20 01:51:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 10176199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 42FDD60386 for ; Sat, 20 Jan 2018 01:52:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34DC028762 for ; Sat, 20 Jan 2018 01:52:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 296EE2880C; Sat, 20 Jan 2018 01:52:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CB8A028762 for ; Sat, 20 Jan 2018 01:52:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EDA16EBCB; Sat, 20 Jan 2018 01:52:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 288236EBC6; Sat, 20 Jan 2018 01:52:02 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jan 2018 17:52:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,383,1511856000"; d="scan'208";a="23895494" Received: from mdroper-desk.fm.intel.com ([10.1.134.220]) by fmsmga001.fm.intel.com with ESMTP; 19 Jan 2018 17:52:01 -0800 From: Matt Roper To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, cgroups@vger.kernel.org Subject: [PATCH RFC 4/9] cgroup: Export task_cgroup_from_root() and cgroup_mutex for drivers Date: Fri, 19 Jan 2018 17:51:36 -0800 Message-Id: <20180120015141.10118-5-matthew.d.roper@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180120015141.10118-1-matthew.d.roper@intel.com> References: <20180120015141.10118-1-matthew.d.roper@intel.com> Cc: Tejun Heo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Drivers that handle processes on a per-cgroup basis need to be able to lookup the cgroup that a process belongs to. Cc: Tejun Heo Cc: cgroups@vger.kernel.org Signed-off-by: Matt Roper --- include/linux/cgroup.h | 5 ++++- kernel/cgroup/cgroup-internal.h | 3 --- kernel/cgroup/cgroup.c | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 1c1758ac1a97..1b93fb018bfc 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -103,6 +103,8 @@ struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry, struct cgroup *cgroup_get_from_path(const char *path); struct cgroup *cgroup_get_from_fd(int fd); +struct cgroup *task_cgroup_from_root(struct task_struct *task, + struct cgroup_root *root); int cgroup_attach_task_all(struct task_struct *from, struct task_struct *); int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from); @@ -432,7 +434,6 @@ static inline void cgroup_put(struct cgroup *cgrp) * as locks used during the cgroup_subsys::attach() methods. */ #ifdef CONFIG_PROVE_RCU -extern struct mutex cgroup_mutex; extern spinlock_t css_set_lock; #define task_css_set_check(task, __c) \ rcu_dereference_check((task)->cgroups, \ @@ -444,6 +445,8 @@ extern spinlock_t css_set_lock; rcu_dereference((task)->cgroups) #endif +extern struct mutex cgroup_mutex; + /** * task_css_check - obtain css for (task, subsys) w/ extra access conds * @task: the target task diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h index 7338083ee3bc..5471f8fe8c2d 100644 --- a/kernel/cgroup/cgroup-internal.h +++ b/kernel/cgroup/cgroup-internal.h @@ -99,7 +99,6 @@ struct cgroup_sb_opts { bool none; }; -extern struct mutex cgroup_mutex; extern spinlock_t css_set_lock; extern struct cgroup_subsys *cgroup_subsys[]; extern struct list_head cgroup_roots; @@ -160,8 +159,6 @@ bool cgroup_is_thread_root(struct cgroup *cgrp); bool cgroup_is_threaded(struct cgroup *cgrp); struct cgroup_root *cgroup_root_from_kf(struct kernfs_root *kf_root); -struct cgroup *task_cgroup_from_root(struct task_struct *task, - struct cgroup_root *root); struct cgroup *cgroup_kn_lock_live(struct kernfs_node *kn, bool drain_offline); void cgroup_kn_unlock(struct kernfs_node *kn); int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen, diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 6069191653f8..0a0093a36a7f 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -69,8 +69,9 @@ * css_set_lock protects task->cgroups pointer, the list of css_set * objects, and the chain of tasks off each css_set. * - * These locks are exported if CONFIG_PROVE_RCU so that accessors in - * cgroup.h can use them for lockdep annotations. + * cgroup_mutex is always exported so that it may be taken by non-controller + * drivers. css_set_lock is exported if CONFIG_PROVE_RCU so that accessors in + * cgroup.h can use it for lockdep annotations. */ DEFINE_MUTEX(cgroup_mutex); DEFINE_SPINLOCK(css_set_lock); @@ -84,8 +85,8 @@ DEFINE_SPINLOCK(css_set_lock); BLOCKING_NOTIFIER_HEAD(cgroup_destroy_notifier_list); EXPORT_SYMBOL_GPL(cgroup_destroy_notifier_list); -#ifdef CONFIG_PROVE_RCU EXPORT_SYMBOL_GPL(cgroup_mutex); +#ifdef CONFIG_PROVE_RCU EXPORT_SYMBOL_GPL(css_set_lock); #endif @@ -1367,6 +1368,7 @@ struct cgroup *task_cgroup_from_root(struct task_struct *task, */ return cset_cgroup_from_root(task_css_set(task), root); } +EXPORT_SYMBOL(task_cgroup_from_root); /* * A task must hold cgroup_mutex to modify cgroups.