Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1276612
| Path | csiph.com!news.mixmin.net!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Tejun Heo <tj@kernel.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 3/8] cgroup: add function to get task's cgroup |
| Date | Tue, 24 Nov 2015 17:30:01 +0100 |
| Message-ID | <qyoDD-262-3@gated-at.bofh.it> (permalink) |
| References | <qvy6u-3b3-3@gated-at.bofh.it> <qvy6u-3b3-15@gated-at.bofh.it> |
| X-Original-To | serge@hallyn.com |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=A97wHhKDGqtHyvogJ+ju3u0QjuKS+6y1xqanHBZcZwo=; b=WPRhrJhd54lNg9h6IvaoFgeKeadmcjJcEpMS4kIIvO8HJ2SlAhSXwMKdFn22rL/RjJ eYyBucER9dwoDcSV9jOzZONo1LWfMZFZxPpzAN8bAqNfRdsIYDmcFaFe5eJP116aYpHq l9Q/9G2r45xlJKxXwSvTkao3rO4Isz2U1ymIyGJjpzq7PrvB+rOO3YqzHk0qe0A0ZozK VGRQRGEv1UJu7CCfLx1tTUhdsI2R55GzbLG3wcNqxuj6JIlhhN7xI/0OlAQMnMrChvHh LsZ28gfoLi5LQGUDC94ijcX8wmTXRaJYGl1u7UhYoilAbmjhY8SP88yp57n1014IDZlq OnCA== |
| X-Received | by 10.129.90.196 with SMTP id o187mr13995128ywb.222.1448382452772; Tue, 24 Nov 2015 08:27:32 -0800 (PST) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| User-Agent | Mutt/1.5.24 (2015-08-30) |
| 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 | 58 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linux-kernel@vger.kernel.org, adityakali@google.com, linux-api@vger.kernel.org, containers@lists.linux-foundation.org, cgroups@vger.kernel.org, lxc-devel@lists.linuxcontainers.org, akpm@linux-foundation.org, ebiederm@xmission.com, Li Zefan <lizefan@huawei.com> |
| X-Original-Date | Tue, 24 Nov 2015 11:27:28 -0500 |
| X-Original-Message-ID | <20151124162728.GN17033@mtj.duckdns.org> |
| X-Original-References | <1447703505-29672-1-git-send-email-serge@hallyn.com> <1447703505-29672-4-git-send-email-serge@hallyn.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1276612 |
Show key headers only | View raw
Hello,
On Mon, Nov 16, 2015 at 01:51:40PM -0600, serge@hallyn.com wrote:
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index 22e3754..29f0b02 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -326,6 +326,7 @@ static inline bool css_tryget_online(struct cgroup_subsys_state *css)
> return percpu_ref_tryget_live(&css->refcnt);
> return true;
> }
> +struct cgroup *get_task_cgroup(struct task_struct *task);
Please move this where other prototypes are.
> +/*
> + * get_task_cgroup - returns the cgroup of the task in the default cgroup
> + * hierarchy.
> + *
> + * @task: target task
> + * This function returns the @task's cgroup on the default cgroup hierarchy. The
> + * returned cgroup has its reference incremented (by calling cgroup_get()). So
> + * the caller must cgroup_put() the obtained reference once it is done with it.
> + */
> +struct cgroup *get_task_cgroup(struct task_struct *task)
> +{
> + struct cgroup *cgrp;
> +
> + mutex_lock(&cgroup_mutex);
> + spin_lock_bh(&css_set_lock);
> +
> + cgrp = task_cgroup_from_root(task, &cgrp_dfl_root);
> + cgroup_get(cgrp);
> +
> + spin_unlock_bh(&css_set_lock);
> + mutex_unlock(&cgroup_mutex);
> + return cgrp;
> +}
> +EXPORT_SYMBOL_GPL(get_task_cgroup);
So, exposing cgroup_mutex this way can lead to ugly lock dependency
issues as cgroup_mutex is expected to be outside of pretty much
everything. task_cgroup_path() does it but it has no users (should
prolly removed) and cgroup_attach_task_all() is pretty specific.
Hmmm... cc'ing Li (btw, please cc him and Johannes from the next
posting). Li, I don't think cset_cgroup_from_root() really needs
cgroup_mutex. css_set_lock seems to be enough. What do you think?
Thanks.
--
tejun
--
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 3/8] cgroup: add function to get task's cgroup serge@hallyn.com - 2015-11-16 21:00 +0100
Re: [PATCH 3/8] cgroup: add function to get task's cgroup Tejun Heo <tj@kernel.org> - 2015-11-24 17:30 +0100
Re: [PATCH 3/8] cgroup: add function to get task's cgroup Tejun Heo <tj@kernel.org> - 2015-11-24 18:00 +0100
csiph-web