From: "Paul Menage" <menage@google.com>
To: "Li Zefan" <lizf@cn.fujitsu.com>
Cc: "Linux Containers" <containers@lists.linux-foundation.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Control Groups Roadmap ideas
Date: Thu, 10 Apr 2008 13:10:30 -0700 [thread overview]
Message-ID: <6599ad830804101310p297536aeld5931073598ec7e6@mail.gmail.com> (raw)
In-Reply-To: <47FC29BF.20701@cn.fujitsu.com>
On Tue, Apr 8, 2008 at 7:28 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>
> Sounds good, and I wrote a prototype in a quick:
Yes, that's pretty much what I was envisaging, thanks.
Paul
>
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index a6a6035..091bc21 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -254,6 +254,7 @@ struct cgroup_subsys {
> struct cgroup *cgrp);
> void (*post_clone)(struct cgroup_subsys *ss, struct cgroup *cgrp);
> void (*bind)(struct cgroup_subsys *ss, struct cgroup *root);
> + int (*can_mount)(struct cgroup_subsys *ss, unsigned long subsys_bits);
> int subsys_id;
> int active;
> int disabled;
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 62f1a52..3d43ff2 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -824,6 +824,25 @@ static int parse_cgroupfs_options(char *data,
> return 0;
> }
>
> +static int check_mount(unsigned long subsys_bits)
> +{
> + int i;
> + int ret;
> + struct cgroup_subsys *ss;
> +
> + for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
> + ss = subsys[i];
> +
> + if (test_bit(i, &subsys_bits) && ss->can_mount) {
> + ret = ss->can_mount(ss, subsys_bits);
> + if (ret)
> + return ret;
> + }
> + }
> +
> + return 0;
> +}
> +
> static int cgroup_remount(struct super_block *sb, int *flags, char *data)
> {
> int ret = 0;
> @@ -839,6 +858,10 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
> if (ret)
> goto out_unlock;
>
> + ret = check_mount(opts.subsys_bits);
> + if (ret)
> + goto out_unlock;
> +
> /* Don't allow flags to change at remount */
> if (opts.flags != root->flags) {
> ret = -EINVAL;
> @@ -959,6 +982,13 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
> return ret;
> }
>
> + ret = check_mount(opts.subsys_bits);
> + if (ret) {
> + if (opts.release_agent)
> + kfree(opts.release_agent);
> + return ret;
> + }
> +
> root = kzalloc(sizeof(*root), GFP_KERNEL);
> if (!root) {
> if (opts.release_agent)
> -------
>
> for the example about swap controller and memory controller:
>
> static int swap_cgroup_can_mount(struct cgroup_subsys *ss,
> unsigned long subsys_bits)
> {
> if (!test_bit(mem_cgroup_subsys_id, &subsys_bits))
> return -EINVAL;
> return 0;
> }
>
> 'mem_cgroup_subsys_id' is a member of enum cgroup_subsys_id defined in cgroup.h
>
next prev parent reply other threads:[~2008-04-10 20:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-08 21:14 Paul Menage
2008-04-09 2:28 ` Li Zefan
2008-04-10 20:10 ` Paul Menage [this message]
2008-04-11 14:48 ` Serge E. Hallyn
2008-04-12 5:10 ` Balbir Singh
2008-04-13 16:11 ` Serge E. Hallyn
2008-04-14 14:31 ` Balbir Singh
2008-04-14 5:24 ` Paul Menage
2008-04-14 14:11 ` Serge E. Hallyn
2008-04-14 15:03 ` Paul Menage
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=6599ad830804101310p297536aeld5931073598ec7e6@mail.gmail.com \
--to=menage@google.com \
--cc=containers@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.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
all inboxes | Powered by JetHome®