From: Ben Blum <bblum@andrew.cmu.edu>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: linux-kernel@vger.kernel.org,
containers@lists.linux-foundation.org, akpm@linux-foundation.org,
Paul Menage <menage@google.com>,
bblum@andrew.cmu.edu
Subject: Re: [RFC] [PATCH 1/5] cgroups: revamp subsys array
Date: Thu, 10 Dec 2009 01:13:32 -0500 [thread overview]
Message-ID: <20091210061332.GC11893@andrew.cmu.edu> (raw)
In-Reply-To: <4B208E7D.8020306@cn.fujitsu.com>
On Thu, Dec 10, 2009 at 02:00:29PM +0800, Li Zefan wrote:
> Yes, but it doesn't mean we should use rw lock or rw semaphore is
> preferable than plain mutex.
>
> - the read side of subsys_mutex is mainly at mount/remount/umount,
> the write side is in cgroup_load_subsys() and cgroup_unload_subsys().
> None is in critical path.
>
> - In most callsites, cgroup_mutex is held just after acquiring
> subsys_mutex.
>
> So what does it gain us to use this rw_sem?
>
> >> And why not just use cgroup_mutex to protect the subsys[] array?
> >> The adding and spreading of subsys_mutex looks ugly to me.
> >
> > The reasoning for this is that there are various chunks of code that
> > need to be protected by a mutex guarding subsys[] that aren't already
> > under cgroup_mutex - like parse_cgroupfs_options, or the first stage
> > of cgroup_load_subsys. Do you think those critical sections are small
> > enough that sacrificing reentrancy for simplicity of code is worth it?
> >
>
> Except parse_cgroupfs_options() which is called without cgroup_mutex
> held, in all other callsites, cgroup_mutex is held right after acquiring
> subsys_mutex.
>
> So yes, I don't think use cgroup_mutex will harm scalibility.
>
> In contrast, this subsys_mutex is quite ugly and deadlock-prone.
to be fair the deadlock case would still be as much to worry about
if we were protecting subsys[] with cgroup_mutex instead.
> For example, see this:
>
> static int cgroup_remount(struct super_block *sb, int *flags, char *data)
> {
> ...
> lock_kernel();
> mutex_lock(&cgrp->dentry->d_inode->i_mutex);
> down_read(&subsys_mutex);
> mutex_lock(&cgroup_mutex);
> ...
> }
>
> Four locks here!
>
>
if we really don't care about performance in those places, it doesn't
really gain anything. when I presented the previous patch series, one
guy (at google) asked me if anything could be done about the "big ugly
cgroup_mutex" and that he wished most of cgroups could be less all under
one single lock. so, I wrote this with that in mind...
anyway, I think the best solution here is - whichever lock ends up being
used for this - have parse_cgroupfs_options and rebind_subsystems each
take the lock when they are called and drop before returning, instead of
having their calling functions hold the lock between calls. division of
labour would be that parse_cgroupfs_options takes the module refcounts,
and that rebind_subsystems drops them.
next prev parent reply other threads:[~2009-12-10 6:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-04 8:53 [RFC] [PATCH 0/5] cgroups: support for module-loadable subsystems Ben Blum
2009-12-04 8:55 ` [RFC] [PATCH 1/5] cgroups: revamp subsys array Ben Blum
2009-12-08 7:38 ` Li Zefan
2009-12-09 5:50 ` Ben Blum
2009-12-09 6:07 ` Li Zefan
2009-12-09 6:09 ` Li Zefan
2009-12-09 8:27 ` Ben Blum
2009-12-10 3:18 ` Li Zefan
2009-12-10 5:19 ` Ben Blum
2009-12-10 6:00 ` Li Zefan
2009-12-10 6:13 ` Ben Blum [this message]
2009-12-09 8:36 ` Ben Blum
2009-12-04 8:56 ` [RFC] [PATCH 2/5] cgroups: subsystem module loading interface Ben Blum
2009-12-04 8:57 ` [RFC] [PATCH 3/5] cgroups: net_cls as module Ben Blum
2009-12-08 6:07 ` Li Zefan
2009-12-04 8:58 ` [RFC] [PATCH 4/5] cgroups: subsystem module unloading Ben Blum
2009-12-04 8:58 ` [RFC] [PATCH 5/5] cgroups: subsystem dependencies Ben Blum
2009-12-08 6:11 ` Li Zefan
2009-12-09 1:08 ` Ben Blum
2009-12-09 1:40 ` 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=20091210061332.GC11893@andrew.cmu.edu \
--to=bblum@andrew.cmu.edu \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox