From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Paul Menage <menage@google.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux Containers <containers@lists.linux-foundation.org>
Subject: Re: [PATCH] devcgroup: avoid using cgroup_lock
Date: Thu, 12 Mar 2009 13:19:12 -0500 [thread overview]
Message-ID: <20090312181912.GA20144@us.ibm.com> (raw)
In-Reply-To: <49B869BB.7030907@cn.fujitsu.com>
Quoting Li Zefan (lizf@cn.fujitsu.com):
> There is nothing special that has to be protected by cgroup_lock,
> so introduce devcgroup_mtuex for it's own use.
>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
> security/device_cgroup.c | 21 +++++++++++++--------
> 1 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/security/device_cgroup.c b/security/device_cgroup.c
> index 3aacd0f..5fda7df 100644
> --- a/security/device_cgroup.c
> +++ b/security/device_cgroup.c
> @@ -11,6 +11,7 @@
> #include <linux/uaccess.h>
> #include <linux/seq_file.h>
> #include <linux/rcupdate.h>
> +#include <linux/mutex.h>
>
> #define ACC_MKNOD 1
> #define ACC_READ 2
> @@ -21,9 +22,11 @@
> #define DEV_CHAR 2
> #define DEV_ALL 4 /* this represents all devices */
>
> +static DEFINE_MUTEX(devcgroup_mutex);
> +
> /*
> * whitelist locking rules:
> - * hold cgroup_lock() for update/read.
> + * hold devcgroup_mutex for update/read.
> * hold rcu_read_lock() for read.
> */
>
> @@ -67,7 +70,7 @@ static int devcgroup_can_attach(struct cgroup_subsys *ss,
> }
>
> /*
> - * called under cgroup_lock()
> + * called under devcgroup_mutex
> */
> static int dev_whitelist_copy(struct list_head *dest, struct list_head *orig)
> {
> @@ -92,7 +95,7 @@ free_and_exit:
>
> /* Stupid prototype - don't bother combining existing entries */
> /*
> - * called under cgroup_lock()
> + * called under devcgroup_mutex
> */
> static int dev_whitelist_add(struct dev_cgroup *dev_cgroup,
> struct dev_whitelist_item *wh)
> @@ -130,7 +133,7 @@ static void whitelist_item_free(struct rcu_head *rcu)
> }
>
> /*
> - * called under cgroup_lock()
> + * called under devcgroup_mutex
> */
> static void dev_whitelist_rm(struct dev_cgroup *dev_cgroup,
> struct dev_whitelist_item *wh)
> @@ -185,8 +188,10 @@ static struct cgroup_subsys_state *devcgroup_create(struct cgroup_subsys *ss,
> list_add(&wh->list, &dev_cgroup->whitelist);
> } else {
> parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup);
> + mutex_lock(&devcgroup_mutex);
> ret = dev_whitelist_copy(&dev_cgroup->whitelist,
> &parent_dev_cgroup->whitelist);
> + mutex_unlock(&devcgroup_mutex);
> if (ret) {
> kfree(dev_cgroup);
> return ERR_PTR(ret);
> @@ -273,7 +278,7 @@ static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft,
> * does the access granted to dev_cgroup c contain the access
> * requested in whitelist item refwh.
> * return 1 if yes, 0 if no.
> - * call with c->lock held
> + * call with devcgroup_mutex held
> */
> static int may_access_whitelist(struct dev_cgroup *c,
> struct dev_whitelist_item *refwh)
> @@ -426,11 +431,11 @@ static int devcgroup_access_write(struct cgroup *cgrp, struct cftype *cft,
> const char *buffer)
> {
> int retval;
> - if (!cgroup_lock_live_group(cgrp))
Does it matter that we no longer check for cgroup_is_removed()?
> - return -ENODEV;
> +
> + mutex_lock(&devcgroup_mutex);
> retval = devcgroup_update_access(cgroup_to_devcgroup(cgrp),
> cft->private, buffer);
> - cgroup_unlock();
> + mutex_unlock(&devcgroup_mutex);
> return retval;
> }
>
> --
> 1.5.4.rc3
next prev parent reply other threads:[~2009-03-12 18:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-12 1:47 [PATCH] devcgroup: avoid using cgroup_lock Li Zefan
2009-03-12 18:19 ` Serge E. Hallyn [this message]
2009-03-13 1:54 ` Li Zefan
2009-03-13 13:41 ` Serge E. Hallyn
2009-03-13 19:57 ` Serge E. Hallyn
[not found] ` <20090313195712.GA18439-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-15 4:41 ` Li Zefan
2009-03-15 4:41 ` Li Zefan
[not found] ` <20090313134139.GB32304-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-13 19:57 ` Serge E. Hallyn
[not found] ` <49B9BCC7.7090908-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-03-13 13:41 ` Serge E. Hallyn
[not found] ` <20090312181912.GA20144-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-13 1:54 ` Li Zefan
[not found] ` <49B869BB.7030907-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-03-12 18:19 ` Serge E. Hallyn
-- strict thread matches above, loose matches on Subject: below --
2009-03-12 1:47 Li Zefan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090312181912.GA20144@us.ibm.com \
--to=serue@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.