All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
To: Paul Menage <menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Balbir Singh
	<balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Cc: Linux Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: [PATCH 3/3] Use the res_counter_populate in memory controller
Date: Thu, 04 Oct 2007 13:21:37 +0400	[thread overview]
Message-ID: <4704B0A1.1000204@openvz.org> (raw)
In-Reply-To: <4704AFC9.4030606-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>

Note, that the controller code dealing with the cftype files
for resource counters becomes much shorter and won't have to 
be changed in the future.

Signed-off-by: Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>

---

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1b8bf24..2e62d24 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -519,28 +519,14 @@ static ssize_t mem_control_type_read(str
 
 static struct cftype mem_cgroup_files[] = {
 	{
-		.name = "usage_in_bytes",
-		.private = RES_USAGE,
-		.read = mem_cgroup_read,
-	},
-	{
-		.name = "limit_in_bytes",
-		.private = RES_LIMIT,
-		.write = mem_cgroup_write,
-		.read = mem_cgroup_read,
-	},
-	{
-		.name = "failcnt",
-		.private = RES_FAILCNT,
-		.read = mem_cgroup_read,
-	},
-	{
 		.name = "control_type",
 		.write = mem_control_type_write,
 		.read = mem_control_type_read,
 	},
 };
 
+static struct cftype mem_res_counter_files[RES_CFT_MAX];
+
 static struct mem_cgroup init_mem_cgroup;
 
 static struct cgroup_subsys_state *
@@ -574,6 +560,13 @@ static void mem_cgroup_destroy(struct cg
 static int mem_cgroup_populate(struct cgroup_subsys *ss,
 				struct cgroup *cont)
 {
+	int ret;
+
+	ret = res_counter_populate(ss, cont, mem_res_counter_files,
+			RES_UNITS_BYTES, mem_cgroup_read, mem_cgroup_write);
+	if (ret)
+		return ret;
+
 	return cgroup_add_files(cont, ss, mem_cgroup_files,
 					ARRAY_SIZE(mem_cgroup_files));
 }

  parent reply	other threads:[~2007-10-04  9:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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:18   ` [PATCH 1/3] Typedefs the read and write functions in cftype Pavel Emelyanov
     [not found]     ` <4704AFFF.4000000-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-10-04 15:18       ` Paul Menage
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 12:11       ` [Devel] " Kir Kolyshkin
     [not found]         ` <4704D88D.1010005-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-10-04 15:01           ` Paul Menage
2007-10-04 15:22       ` Paul Menage
2007-10-04  9:21   ` Pavel Emelyanov [this message]
  -- strict thread matches above, loose matches on Subject: below --
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:59   ` [PATCH 3/3] Use the res_counter_populate in memory controller 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=4704B0A1.1000204@openvz.org \
    --to=xemul-gefaqzzx7r8dnm+yrofe0a@public.gmane.org \
    --cc=balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=menage-hpIqsD4AKlfQT0dZR+AlfA@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.