LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@openvz.org>
To: Paul Menage <menage@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linux Containers <containers@lists.osdl.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][DOCUMENTATION] Minimal controller code for a quick start
Date: Fri, 08 Feb 2008 11:09:09 +0300 [thread overview]
Message-ID: <47AC0E25.1060603@openvz.org> (raw)
In-Reply-To: <6599ad830802071245r321efddat89a17b091cb5db4b@mail.gmail.com>
Paul Menage wrote:
> On Feb 7, 2008 7:37 AM, Pavel Emelyanov <xemul@openvz.org> wrote:
>> The Documentation/cgroups.txt file contains the info on how
>> to write some controller for cgroups subsystem, but even with
>> this, one need to write quite a lot of code before developing
>> the core (or copy-n-paste it from some other place).
>
> Good idea.
>
>> +
>> +static ssize_t foo_bar_read(struct cgroup *cg, struct cftype *cft,
>> + struct file *file, char __user *userbuf,
>> + size_t nbytes, loff_t *ppos)
>> +{
>> + struct foo_cgroup *foo;
>> +
>> + foo = foo_from_cgroup(cg);
>> +
>> + /*
>> + * produce some output
>> + */
>> +
>> + return nbytes;
>> +}
>> +
>> +static ssize_t foo_bar_write(struct cgroup *cg, struct cftype *cft,
>> + struct file *file, const char __user *userbuf,
>> + size_t nbytes, loff_t *ppos)
>> +{
>> + struct foo_cgroup *foo;
>> +
>> + foo = foo_from_cgroup(cg);
>> +
>> + /*
>> + * read and tune the foo
>> + */
>> +
>> + return nbytes;
>> +}
>> +
>> +static struct cftype foo_files[] = {
>> + {
>> + .name = "bar",
>> + .read = foo_bar_read,
>> + .write = foo_bar_write,
>> + },
>> +};
>
> Can you structure this example so as to encourage people to use the
> more formatted read/write routines, such as read_int64 and
> write_int64?
And one more for ->read_strategy hints :) Well, I thought that
it should be the _minimal_ controller.
>> +
>> +static struct cgroup_subsys_state *foo_create(struct cgroup_subsys *cs,
>> + struct cgroup *cg)
>> +{
>> + struct foo_cgroup *foo;
>> +
>
> Maybe add a comment here that mentions that if your cgroup needs very
> early initialization, you can check for cg->parent being NULL, and
> return a statically-constructed structure here. (And set
> foo_subsys.early_init = 1)
Yet again - this is rather a special feature, that your controller
needs an early initialization - for a very minimal one this is not
required.
Maybe we can have two examples? One is the minimal one and the other
is an advanced one with ->attach callbacks, etc?
> Paul
>
next prev parent reply other threads:[~2008-02-08 8:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-07 15:37 Pavel Emelyanov
2008-02-07 20:28 ` Peter Zijlstra
2008-02-07 20:49 ` Paul Menage
2008-02-07 20:52 ` Peter Zijlstra
2008-02-07 20:50 ` Serge E. Hallyn
2008-02-07 20:45 ` Paul Menage
2008-02-08 8:09 ` Pavel Emelyanov [this message]
2008-02-07 20:47 ` Serge E. Hallyn
2008-02-08 9:28 ` Pavel Emelyanov
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=47AC0E25.1060603@openvz.org \
--to=xemul@openvz.org \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
--subject='Re: [PATCH][DOCUMENTATION] Minimal controller code for a quick start' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).