linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Paul Menage <menage@google.com>,
	Pavel Emelianov <xemul@openvz.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org, Linux Containers <containers@lists.osdl.org>
Subject: [PATCH 3/3] memcgoup: allow memory.failcnt to be reset
Date: Tue, 11 Mar 2008 19:09:02 +0900	[thread overview]
Message-ID: <47D65A3E.100@cn.fujitsu.com> (raw)

Allow memory.failcnt to be reset to 0:

        echo 0 > memory.failcnt

And '0' is the only valid value.

This is useful when testing or observing the memory resource
controller. Without this function, one will have to remember
the previous failcnt to decide whether memory reclaim has
happened *again*.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 Documentation/controllers/memory.txt |    4 +++-
 mm/memcontrol.c                      |   15 +++++++++++++++
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/Documentation/controllers/memory.txt b/Documentation/controllers/memory.txt
index 866b9cd..28f80e3 100644
--- a/Documentation/controllers/memory.txt
+++ b/Documentation/controllers/memory.txt
@@ -194,7 +194,9 @@ this file after a write to guarantee the value committed by the kernel.
 4096
 
 The memory.failcnt field gives the number of times that the cgroup limit was
-exceeded.
+exceeded. It can be reset.
+
+# echo 0 > memory.failcnt
 
 The memory.stat file gives accounting information. Now, the number of
 caches, RSS and Active pages/Inactive pages are shown.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6145031..fd26dc2 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -883,6 +883,20 @@ static int mem_force_empty_write(struct cgroup *cont, struct cftype *cft,
 	return ret;
 }
 
+static int mem_failcnt_write(struct cgroup *cont, struct cftype *cft,
+			     u64 val)
+{
+	struct res_counter *counter;
+
+	if (val != 0)
+		return -EINVAL;
+
+	counter = &mem_cgroup_from_cont(cont)->res;
+	res_counter_write_u64(counter, cft->private, 0);
+
+	return 0;
+}
+
 static const struct mem_cgroup_stat_desc {
 	const char *msg;
 	u64 unit;
@@ -934,6 +948,7 @@ static struct cftype mem_cgroup_files[] = {
 	{
 		.name = "failcnt",
 		.private = RES_FAILCNT,
+		.write_u64 = mem_failcnt_write,
 		.read_u64 = mem_cgroup_read,
 	},
 	{
-- 
1.5.4.rc3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2008-03-11 10:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-11 10:09 Li Zefan [this message]
2008-03-11 10:16 ` [PATCH 3/3] memcgoup: allow memory.failcnt to be reset KAMEZAWA Hiroyuki
2008-03-11 10:14   ` Balbir Singh
2008-03-13 23:37     ` Li Zefan

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=47D65A3E.100@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=containers@lists.osdl.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=menage@google.com \
    --cc=xemul@openvz.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 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).