[Devel] Re: [RFC][PATCH] another swap controller for cgroup

2008-05-13 Thread Paul Menage
On Tue, May 13, 2008 at 8:21 PM, YAMAMOTO Takashi <[EMAIL PROTECTED]> wrote: > > note that a failure can affect other subsystems which belong to > the same hierarchy as well, and, even worse, a back-out attempt can also > fail. > i'm afraid that we need to play some kind of transaction-commit g

[Devel] Re: [RFC][PATCH] another swap controller for cgroup

2008-05-13 Thread YAMAMOTO Takashi
> >>> + BUG_ON(mm == NULL); > >>> + BUG_ON(mm->swap_cgroup == NULL); > >>> + if (scg == NULL) { > >>> + /* > >>> + * see swap_cgroup_attach. > >>> + */ > >>> + smp_rmb(); > >>> + scg = mm->swap_cgroup; > >> With the mm->owner patches, we need not maintain a

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Paul Jackson
Andrew wrote: > As Matt observed, this is just a poorly-named variable. How about the following code for cgroup_file_write(): char buf[64]; /* avoid kmalloc() in small cases */ char *p;/* buf[] or kmalloc'd buffer */ ... if (nbytes < si

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Paul Menage
On Tue, May 13, 2008 at 6:30 PM, Li Zefan <[EMAIL PROTECTED]> wrote: > > It's a bit odd to me that cgroup_is_removed() is removed in > cgroup_file_write(), > but it's ressered here. > Fair point. It's probably better for me to be consistent. Paul ___

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Li Zefan
>> > @@ -1518,16 +1580,21 @@ static ssize_t cgroup_file_read(struct f >> > struct cftype *cft = __d_cft(file->f_dentry); >> > struct cgroup *cgrp = __d_cgrp(file->f_dentry->d_parent); >> > >> > - if (!cft || cgroup_is_removed(cgrp)) >> > + if (cgroup_is_removed(cgrp)) >>

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Paul Menage
On Tue, May 13, 2008 at 2:32 PM, Andrew Morton <[EMAIL PROTECTED]> wrote: > > But do we ever expect that cgroup_mutex will be taken with much > frequency, or held for much time? If it's only taken during, say, > configuration of a group or during a query of that configuration then > perhaps we

[Devel] Re: [RFC/PATCH 3/8]: CGroup Files: Move the release_agent file to use typed handlers

2008-05-13 Thread Paul Menage
On Tue, May 13, 2008 at 1:08 PM, Andrew Morton <[EMAIL PROTECTED]> wrote: > On Mon, 12 May 2008 23:37:10 -0700 > [EMAIL PROTECTED] wrote: > > > + agentbuf = kmalloc(PATH_MAX, GFP_KERNEL); > > + if (!agentbuf) > > + goto continue_free; > > +

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Andrew Morton
On Tue, 13 May 2008 14:17:29 -0700 "Paul Menage" <[EMAIL PROTECTED]> wrote: > On Tue, May 13, 2008 at 1:01 PM, Andrew Morton > <[EMAIL PROTECTED]> wrote: > > > > This, umm, doesn't seem to do much to make the kernel a simpler place. > > > > Do we expect to gain much from this? Hope so... What?

[Devel] Re: [RFC/PATCH 6/8]: CGroup Files: Remove cpuset_common_file_write()

2008-05-13 Thread Paul Menage
On Tue, May 13, 2008 at 1:11 PM, Andrew Morton <[EMAIL PROTECTED]> wrote: > On Mon, 12 May 2008 23:37:13 -0700 > [EMAIL PROTECTED] wrote: > > > @@ -1412,14 +1355,18 @@ static struct cftype files[] = { > > { > > .name = "cpus", > > .read = cpuset_common_file_re

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Paul Menage
On Tue, May 13, 2008 at 1:01 PM, Andrew Morton <[EMAIL PROTECTED]> wrote: > > This, umm, doesn't seem to do much to make the kernel a simpler place. > > Do we expect to gain much from this? Hope so... What? > The goal is to prevent cgroup_mutex becoming a BKL for cgroups, to make it easier for

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Paul Menage
On Tue, May 13, 2008 at 2:23 AM, Li Zefan <[EMAIL PROTECTED]> wrote: > > + > > +/** > > + * cgroup_file_lock(). Helper for cgroup read/write methods. > > + * @cgrp: the cgroup being acted on > > + * @cft: the control file being written to or read from > > + * *write: true if the access is

[Devel] Re: [RFC/PATCH 2/8]: CGroup Files: Add a cgroup write_string control file method

2008-05-13 Thread Paul Menage
On Tue, May 13, 2008 at 1:07 PM, Andrew Morton <[EMAIL PROTECTED]> wrote: > > > > + /* If non-zero, defines the maximum length of string that can > > + * be passed to write_string; defaults to 64 */ > > + int max_write_len; > > would size_t be a more appropriate type? > Probably

[Devel] Re: [RFC/PATCH 2/8]: CGroup Files: Add a cgroup write_string control file method

2008-05-13 Thread Matt Helsley
On Mon, 2008-05-12 at 23:37 -0700, [EMAIL PROTECTED] wrote: > plain text document attachment (cgroup_write_string.patch) > This patch adds a write_string() method for cgroups control files. The > semantics are that a buffer is copied from userspace to kernelspace > and the handler function invoked

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Andrew Morton
On Tue, 13 May 2008 13:38:58 -0700 Matthew Helsley <[EMAIL PROTECTED]> wrote: > > > + char static_buffer[64]; > > > I'm trying to work out what protects static_buffer? > > One of us must be having a brain cramp because it looks to me like the > buffer doesn't need protection -- it's on the stack.

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Matthew Helsley
On Tue, 2008-05-13 at 13:01 -0700, Andrew Morton wrote: > Fear, doubt and resistance! > > On Mon, 12 May 2008 23:37:08 -0700 > [EMAIL PROTECTED] wrote: > > > Different cgroup files have different stability requirements of the > > cgroups framework while the handler is running; currently most > >

[Devel] Re: [RFC/PATCH 6/8]: CGroup Files: Remove cpuset_common_file_write()

2008-05-13 Thread Andrew Morton
On Mon, 12 May 2008 23:37:13 -0700 [EMAIL PROTECTED] wrote: > @@ -1412,14 +1355,18 @@ static struct cftype files[] = { > { > .name = "cpus", > .read = cpuset_common_file_read, > - .write = cpuset_common_file_write, > + .write_string = updat

[Devel] Re: [RFC/PATCH 3/8]: CGroup Files: Move the release_agent file to use typed handlers

2008-05-13 Thread Andrew Morton
On Mon, 12 May 2008 23:37:10 -0700 [EMAIL PROTECTED] wrote: > + agentbuf = kmalloc(PATH_MAX, GFP_KERNEL); > + if (!agentbuf) > + goto continue_free; > + strcpy(agentbuf, cgrp->root->release_agent_path); Did we need to allocate all that memor

[Devel] Re: [RFC/PATCH 2/8]: CGroup Files: Add a cgroup write_string control file method

2008-05-13 Thread Andrew Morton
On Mon, 12 May 2008 23:37:09 -0700 [EMAIL PROTECTED] wrote: > This patch adds a write_string() method for cgroups control files. The > semantics are that a buffer is copied from userspace to kernelspace > and the handler function invoked on that buffer. Any control group > locking is done after t

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Andrew Morton
Fear, doubt and resistance! On Mon, 12 May 2008 23:37:08 -0700 [EMAIL PROTECTED] wrote: > Different cgroup files have different stability requirements of the > cgroups framework while the handler is running; currently most > subsystems that don't have their own internal synchronization just > ca

[Devel] Re: [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread Li Zefan
[EMAIL PROTECTED] wrote: > Different cgroup files have different stability requirements of the > cgroups framework while the handler is running; currently most > subsystems that don't have their own internal synchronization just > call cgroup_lock()/cgroup_unlock(), which takes the global cgroup_mu

[Devel] [RFC/PATCH 1/8]: CGroup Files: Add locking mode to cgroups control files

2008-05-13 Thread menage
Different cgroup files have different stability requirements of the cgroups framework while the handler is running; currently most subsystems that don't have their own internal synchronization just call cgroup_lock()/cgroup_unlock(), which takes the global cgroup_mutex. This patch introduces a ran

[Devel] [RFC/PATCH 3/8]: CGroup Files: Move the release_agent file to use typed handlers

2008-05-13 Thread menage
Adds cgroup_release_agent_write() and cgroup_release_agent_show() methods to handle writing/reading the path to a cgroup hierarchy's release agent. As a result, cgroup_common_file_read() is now unnecessary. As part of the change, a previously-tolerated race in cgroup_release_agent() is avoided by

[Devel] [RFC/PATCH 4/8]: CGroup Files: Move notify_on_release file to separate write handler

2008-05-13 Thread menage
This patch moves the write handler for the cgroups notify_on_release file into a separate handler. This handler requires no cgroups locking since it relies on atomic bitops for synchronization. Signed-off-by: Paul Menage <[EMAIL PROTECTED]> --- kernel/cgroup.c | 27 +++

[Devel] [RFC/PATCH 8/8]: CGroup Files: Convert res_counter_write() to be a cgroups write_string() handler

2008-05-13 Thread menage
Currently read_counter_write() is a raw file handler even though it's ultimately taking a number, since in some cases it wants to pre-process the string when converting it to a number. This patch converts res_counter_write() from a raw file handler to a write_string() handler; this allows some of

[Devel] [RFC/PATCH 5/8]: CGroup Files: Turn attach_task_by_pid directly into a cgroup write handler

2008-05-13 Thread menage
This patch changes attach_task_by_pid() to take a u64 rather than a string; as a result it can be called directly as a control groups write_u64 handler, and cgroup_common_file_write() can be removed. Signed-off-by: Paul Menage <[EMAIL PROTECTED]> --- kernel/cgroup.c | 67 ++

[Devel] [RFC/PATCH 7/8]: CGroup Files: Convert devcgroup_access_write() into a cgroup write_string() handler

2008-05-13 Thread menage
This patch converts devcgroup_access_write() from a raw file handler into a handler for the cgroup write_string() method. This allows some boilerplate copying/locking/checking to be removed and simplifies the cleanup path, since these functions are performed by the cgroups framework before calling

[Devel] [RFC/PATCH 6/8]: CGroup Files: Remove cpuset_common_file_write()

2008-05-13 Thread menage
This patch tweaks the signatures of the update_cpumask() and update_nodemask() functions so that they can be called directly as handlers for the new cgroups write_string() method. This allows cpuset_common_file_write() to be removed. Signed-off-by: Paul Menage <[EMAIL PROTECTED]> --- kernel/cpu

[Devel] [RFC/PATCH 0/8]: CGroup Files: Clean up locking and boilerplate

2008-05-13 Thread menage
Most of the remaining cgroup control files that implement raw file handlers (those where the userspace pointer/length/ppos are passed through unchanged by cgroups) appear to do so in order to have some control over the kind of locking that their handler uses. In particular, some handlers need to ca

[Devel] [RFC/PATCH 2/8]: CGroup Files: Add a cgroup write_string control file method

2008-05-13 Thread menage
This patch adds a write_string() method for cgroups control files. The semantics are that a buffer is copied from userspace to kernelspace and the handler function invoked on that buffer. Any control group locking is done after the copy from userspace has occurred. The buffer is guaranteed to be n