[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1209590905.29759.38.camel@localhost.localdomain>
Date: Wed, 30 Apr 2008 14:28:25 -0700
From: Matt Helsley <matthltc@...ibm.com>
To: Linux-Kernel <linux-kernel@...r.kernel.org>
Cc: Cedric Le Goater <clg@...ibm.com>, Paul Menage <menage@...gle.com>,
Oren Laadan <orenl@...columbia.edu>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Pavel Machek <pavel@....cz>,
linux-pm@...ts.linux-foundation.org,
Linux Containers <containers@...ts.linux-foundation.org>
Subject: Re: [RFC][PATCH 3/5] Container Freezer: Implement freezer cgroup
subsystem
On Wed, 2008-04-23 at 23:47 -0700, Matt Helsley wrote:
<snip>
> +static ssize_t freezer_write(struct cgroup *cgroup,
> + struct cftype *cft,
> + struct file *file,
> + const char __user *userbuf,
> + size_t nbytes, loff_t *unused_ppos)
> +{
> + char *buffer;
> + int retval = 0;
> + enum freezer_state goal_state;
> +
> + if (nbytes >= PATH_MAX)
> + return -E2BIG;
> +
> + /* +1 for nul-terminator */
> + buffer = kmalloc(nbytes + 1, GFP_KERNEL);
> + if (buffer == NULL)
> + return -ENOMEM;
> +
> + if (copy_from_user(buffer, userbuf, nbytes)) {
> + retval = -EFAULT;
> + goto free_buffer;
> + }
> + buffer[nbytes] = 0; /* nul-terminate */
> + strstrip(buffer);
> + if (strcmp(buffer, "RUNNING") == 0)
> + goal_state = STATE_RUNNING;
> + else if (strcmp(buffer, "FROZEN") == 0)
> + goal_state = STATE_FROZEN;
> + else {
> + retval = -EIO;
> + goto free_buffer;
> + }
> +
> + cgroup_lock();
> +
> + if (cgroup_is_removed(cgroup)) {
> + retval = -ENODEV;
> + goto unlock;
> + }
I think this was copy/paste'd from cgroup_common_file_write() which
modifies the cgroup hierarchy. However this function does not modify the
cgroup hierarchy and we're not getting the cgroup from the task. So I
don't think cgroup_lock()/unlock() are needed here. Paul, do you agree?
> + retval = freezer_freeze(cgroup, goal_state);
> + if (retval == 0)
> + retval = nbytes;
> +unlock:
> + cgroup_unlock();
> +free_buffer:
> + kfree(buffer);
> + return retval;
> +}
Cheers,
-Matt Helsley
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists