From: Balbir Singh <balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
Cc: Linux Containers
<containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>,
Paul Menage <menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH 2/3] Introduce the res_counter_populate() function
Date: Wed, 03 Oct 2007 23:32:29 +0530 [thread overview]
Message-ID: <4703D935.6090309@linux.vnet.ibm.com> (raw)
In-Reply-To: <470375B2.5090100-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
Pavel Emelyanov wrote:
>
> diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
> index 61363ce..8ee8316 100644
> --- a/include/linux/res_counter.h
> +++ b/include/linux/res_counter.h
> @@ -58,6 +58,9 @@ ssize_t res_counter_write(struct res_cou
> const char __user *buf, size_t nbytes, loff_t *pos,
> int (*write_strategy)(char *buf, unsigned long long *val));
>
> +int res_counter_populate(struct cgroup_subsys *ss, struct cgroup *cont,
> + struct cftype files[], cft_read read_fn, cft_write write_fn);
> +
> /*
> * the field descriptors. one for each member of res_counter
> */
> @@ -66,6 +69,8 @@ enum {
> RES_USAGE,
> RES_LIMIT,
> RES_FAILCNT,
> +
> + RES_CFT_MAX,
> };
>
This is good
> /*
> diff --git a/kernel/res_counter.c b/kernel/res_counter.c
> index d7f43cd..018eb2b 100644
> --- a/kernel/res_counter.c
> +++ b/kernel/res_counter.c
> @@ -10,9 +10,34 @@
> #include <linux/types.h>
> #include <linux/parser.h>
> #include <linux/fs.h>
> +#include <linux/cgroup.h>
> #include <linux/res_counter.h>
> #include <linux/uaccess.h>
>
> +int res_counter_populate(struct cgroup_subsys *ss, struct cgroup *cont,
> + struct cftype files[], cft_read read_fn, cft_write write_fn)
> +{
> + /*
> + * to be on the safe side
> + */
> + memset(files, 0, RES_CFT_MAX * sizeof(struct cftype));
> +
> + strcpy(files[RES_USAGE].name, "usage_in_bytes");
This needs to be controller pluggable
> + files[RES_USAGE].private = RES_USAGE;
> + files[RES_USAGE].read = read_fn;
> +
> + strcpy(files[RES_LIMIT].name, "limit_in_bytes");
This needs to be controller pluggable
> + files[RES_LIMIT].private = RES_LIMIT;
> + files[RES_LIMIT].read = read_fn;
> + files[RES_LIMIT].write = write_fn;
> +
> + strcpy(files[RES_FAILCNT].name, "failcnt");
> + files[RES_FAILCNT].private = RES_FAILCNT;
> + files[RES_FAILCNT].read = read_fn;
> +
> + return cgroup_add_files(cont, ss, files, RES_CFT_MAX);
> +}
> +
I've been thinking of writing a tool, that will generate all
the code necessary to write a controller under cgroups.
Another TODO (low priority).
> void res_counter_init(struct res_counter *counter)
> {
> spin_lock_init(&counter->lock);
>
> _______________________________________________
> Containers mailing list
> Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL
next prev parent reply other threads:[~2007-10-03 18:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-03 10:53 [PATCH 0/3] Consolidate cgroup files creation for resource counters Pavel Emelyanov
[not found] ` <470374A7.6030805-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-10-03 10:55 ` [PATCH 1/3] Typedefs the read and write functions in cftype Pavel Emelyanov
2007-10-03 10:57 ` [PATCH 2/3] Introduce the res_counter_populate() function Pavel Emelyanov
[not found] ` <470375B2.5090100-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-10-03 16:02 ` Paul Menage
[not found] ` <6599ad830710030902h71737aban4e7cf4e4d1e4d4d1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-10-04 6:40 ` Pavel Emelyanov
2007-10-03 18:02 ` Balbir Singh [this message]
2007-10-03 10:59 ` [PATCH 3/3] Use the res_counter_populate in memory controller Pavel Emelyanov
2007-10-03 17:59 ` [PATCH 0/3] Consolidate cgroup files creation for resource counters Balbir Singh
-- strict thread matches above, loose matches on Subject: below --
2007-10-04 9:18 [PATCH 0/3] Consolidate cgroup files creation for resource counters (v2) Pavel Emelyanov
[not found] ` <4704AFC9.4030606-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-10-04 9:20 ` [PATCH 2/3] Introduce the res_counter_populate() function Pavel Emelyanov
[not found] ` <4704B077.30502-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-10-04 15:22 ` 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=4703D935.6090309@linux.vnet.ibm.com \
--to=balbir-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.