memcgoup: allow memory.failcnt to be reset
Subsystems (3)
PATCH 3/3 memcgoup: allow memory.failcnt to be reset
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*.
--- Documentation/controllers/memory.txt | 4 +++- mm/memcontrol.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletions(-)
Documentation/controllers/memory.txt +3 -1
@@ -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.
mm/memcontrol.c +15 -0
@@ -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, }, {
Signature · 1 line
1.5.4.rc3
Quoted 6 lines · On Tue, 11 Mar 2008 19:09:02 +0900 Li Zefan <[email protected]> wrote:
Allow memory.failcnt to be reset to 0:
echo 0 > memory.failcnt
And '0' is the only valid value.
Can't this be generic resource counter function ?
Thanks,
-Kame
Quoted 62 lines
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 <[email protected]>--- Documentation/controllers/memory.txt | 4 +++- mm/memcontrol.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletions(-)Documentation/controllers/memory.txt +3
-1@@ -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.mm/memcontrol.c +15
-0@@ -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, }, {Signature · 1 line
1.5.4.rc3
Quoted 11 lines · KAMEZAWA Hiroyuki
Quoted 6 lines · On Tue, 11 Mar 2008 19:09:02 +0900 Li Zefan <[email protected]> wrote:
Allow memory.failcnt to be reset to 0:
echo 0 > memory.failcnt
And '0' is the only valid value.
Can't this be generic resource counter function ?
I was about to suggest a generic cgroup option, since we do reset values even for the cpu accounting subsystem.
Signature · 10 lines
Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Balbir Singh
Quoted 7 lines · KAMEZAWA Hiroyuki
Quoted 4 lines · On Tue, 11 Mar 2008 19:09:02 +0900 Li Zefan <[email protected]> wrote:
Allow memory.failcnt to be reset to 0:
echo 0 > memory.failcnt
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
And '0' is the only valid value.
Can't this be generic resource counter function ?
I was about to suggest a generic cgroup option, since we do reset values even for the cpu accounting subsystem.
It won't help. You still have to write the write function, and you have to call some res_counter routines to reset the value, and maybe also do some other work.