* [LTP] [PATCH v3] mem/oom: avoid unexpected error when no memcg swap accounting
@ 2012-03-19 10:28 Zhouping Liu
2012-03-19 11:00 ` Wanlong Gao
2012-03-19 11:28 ` Caspar Zhang
0 siblings, 2 replies; 3+ messages in thread
From: Zhouping Liu @ 2012-03-19 10:28 UTC (permalink / raw)
To: Caspar Zhang, Wanlong Gao; +Cc: LTP List, Cai Qian
Since commit http://git.kernel.org/linus/a42c390cfa0c,
which added an option to control memcg swap, when kernel
neither set CGROUP_MEM_RES_CTLR_SWAP_ENABLED nor add
'swapaccount=1' kernel parameter, that indicates memcg swap
accounting is disabled, it will have no such file:
memory.memsw.*, then oom03 & oom04 cases will fail.
The patch fixed it: removed memsw cases when memcg swap
accounting is disabled, and added a TCONF:
tst_resm(TCONF,"memcg swap accounting is disabled");
Signed-off-by: Zhouping Liu <zliu@redhat.com>
Reviewed-by: Caspar Zhang <czhang@redhat.com>
v2 -> v3: added MEMCG_SW_LIMIT to instead of
'MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes"'
and updated TINFO to TCONF, which made more sense.
---
testcases/kernel/mem/include/mem.h | 1 +
testcases/kernel/mem/oom/oom03.c | 12 ++++++++++--
testcases/kernel/mem/oom/oom04.c | 25 ++++++++++++++++++++-----
3 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h
index 00bb139..4c568cd 100644
--- a/testcases/kernel/mem/include/mem.h
+++ b/testcases/kernel/mem/include/mem.h
@@ -50,6 +50,7 @@ void ksm_usage(void);
#define CPATH_NEW CPATH "/1"
#define MEMCG_PATH "/dev/cgroup"
#define MEMCG_PATH_NEW MEMCG_PATH "/1"
+#define MEMCG_SW_LIMIT MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes"
#if HAVE_SYS_EVENTFD_H
#define PATH_OOMCTRL MEMCG_PATH_NEW "/memory.oom_control"
#define PATH_EVTCTRL MEMCG_PATH_NEW "/cgroup.event_control"
diff --git a/testcases/kernel/mem/oom/oom03.c b/testcases/kernel/mem/oom/oom03.c
index b90d4d7..6de68b0 100644
--- a/testcases/kernel/mem/oom/oom03.c
+++ b/testcases/kernel/mem/oom/oom03.c
@@ -66,8 +66,16 @@ int main(int argc, char *argv[])
write_file(MEMCG_PATH_NEW "/memory.limit_in_bytes", mem);
testoom(0, 0, 0);
- write_file(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", mem);
- testoom(0, 1, 0);
+ if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
+ if (errno == ENOENT)
+ tst_resm(TCONF,
+ "memcg swap accounting is disabled");
+ else
+ tst_brkm(TBROK|TERRNO, cleanup, "access");
+ } else {
+ write_file(MEMCG_SW_LIMIT, mem);
+ testoom(0, 1, 0);
+ }
}
cleanup();
tst_exit();
diff --git a/testcases/kernel/mem/oom/oom04.c b/testcases/kernel/mem/oom/oom04.c
index fb35f96..00030b9 100644
--- a/testcases/kernel/mem/oom/oom04.c
+++ b/testcases/kernel/mem/oom/oom04.c
@@ -48,6 +48,7 @@ int main(int argc, char *argv[])
{
char *msg;
int lc;
+ int swap_acc_on = 1;
long nodes[MAXNODES];
char buf[BUFSIZ], mem[BUFSIZ];
@@ -73,19 +74,33 @@ int main(int argc, char *argv[])
snprintf(mem, BUFSIZ, "%ld", TESTMEM);
write_file(MEMCG_PATH_NEW "/memory.limit_in_bytes", mem);
+ if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
+ if (errno == ENOENT) {
+ tst_resm(TCONF,
+ "memcg swap accounting is disabled");
+ swap_acc_on = 0;
+ } else
+ tst_brkm(TBROK|TERRNO, cleanup, "access");
+ }
+
tst_resm(TINFO, "process mempolicy.");
testoom(1, 0, 1);
- write_file(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", mem);
- testoom(1, 1, 1);
+ if (swap_acc_on) {
+ write_file(MEMCG_SW_LIMIT, mem);
+ testoom(1, 1, 1);
+ }
tst_resm(TINFO, "process cpuset.");
- write_file(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", "-1");
+ if (swap_acc_on)
+ write_file(MEMCG_SW_LIMIT, "-1");
testoom(0, 0, 1);
- write_file(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", mem);
- testoom(0, 1, 1);
+ if (swap_acc_on) {
+ write_file(MEMCG_SW_LIMIT, mem);
+ testoom(0, 1, 1);
+ }
}
cleanup();
tst_exit();
--
1.7.7.6
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v3] mem/oom: avoid unexpected error when no memcg swap accounting
2012-03-19 10:28 [LTP] [PATCH v3] mem/oom: avoid unexpected error when no memcg swap accounting Zhouping Liu
@ 2012-03-19 11:00 ` Wanlong Gao
2012-03-19 11:28 ` Caspar Zhang
1 sibling, 0 replies; 3+ messages in thread
From: Wanlong Gao @ 2012-03-19 11:00 UTC (permalink / raw)
To: Zhouping Liu; +Cc: Cai Qian, LTP List
On 03/19/2012 06:28 PM, Zhouping Liu wrote:
> Since commit http://git.kernel.org/linus/a42c390cfa0c,
> which added an option to control memcg swap, when kernel
> neither set CGROUP_MEM_RES_CTLR_SWAP_ENABLED nor add
> 'swapaccount=1' kernel parameter, that indicates memcg swap
> accounting is disabled, it will have no such file:
> memory.memsw.*, then oom03 & oom04 cases will fail.
>
> The patch fixed it: removed memsw cases when memcg swap
> accounting is disabled, and added a TCONF:
> tst_resm(TCONF,"memcg swap accounting is disabled");
>
> Signed-off-by: Zhouping Liu <zliu@redhat.com>
> Reviewed-by: Caspar Zhang <czhang@redhat.com>
>
> v2 -> v3: added MEMCG_SW_LIMIT to instead of
> 'MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes"'
> and updated TINFO to TCONF, which made more sense.
> ---
> testcases/kernel/mem/include/mem.h | 1 +
> testcases/kernel/mem/oom/oom03.c | 12 ++++++++++--
> testcases/kernel/mem/oom/oom04.c | 25 ++++++++++++++++++++-----
> 3 files changed, 31 insertions(+), 7 deletions(-)
>
> diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h
> index 00bb139..4c568cd 100644
> --- a/testcases/kernel/mem/include/mem.h
> +++ b/testcases/kernel/mem/include/mem.h
> @@ -50,6 +50,7 @@ void ksm_usage(void);
> #define CPATH_NEW CPATH "/1"
> #define MEMCG_PATH "/dev/cgroup"
> #define MEMCG_PATH_NEW MEMCG_PATH "/1"
> +#define MEMCG_SW_LIMIT MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes"
> #if HAVE_SYS_EVENTFD_H
> #define PATH_OOMCTRL MEMCG_PATH_NEW "/memory.oom_control"
> #define PATH_EVTCTRL MEMCG_PATH_NEW "/cgroup.event_control"
> diff --git a/testcases/kernel/mem/oom/oom03.c b/testcases/kernel/mem/oom/oom03.c
> index b90d4d7..6de68b0 100644
> --- a/testcases/kernel/mem/oom/oom03.c
> +++ b/testcases/kernel/mem/oom/oom03.c
> @@ -66,8 +66,16 @@ int main(int argc, char *argv[])
> write_file(MEMCG_PATH_NEW "/memory.limit_in_bytes", mem);
> testoom(0, 0, 0);
>
> - write_file(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", mem);
> - testoom(0, 1, 0);
> + if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
> + if (errno == ENOENT)
> + tst_resm(TCONF,
> + "memcg swap accounting is disabled");
> + else
> + tst_brkm(TBROK|TERRNO, cleanup, "access");
> + } else {
> + write_file(MEMCG_SW_LIMIT, mem);
> + testoom(0, 1, 0);
> + }
> }
> cleanup();
> tst_exit();
> diff --git a/testcases/kernel/mem/oom/oom04.c b/testcases/kernel/mem/oom/oom04.c
> index fb35f96..00030b9 100644
> --- a/testcases/kernel/mem/oom/oom04.c
> +++ b/testcases/kernel/mem/oom/oom04.c
> @@ -48,6 +48,7 @@ int main(int argc, char *argv[])
> {
> char *msg;
> int lc;
> + int swap_acc_on = 1;
> long nodes[MAXNODES];
> char buf[BUFSIZ], mem[BUFSIZ];
>
> @@ -73,19 +74,33 @@ int main(int argc, char *argv[])
> snprintf(mem, BUFSIZ, "%ld", TESTMEM);
> write_file(MEMCG_PATH_NEW "/memory.limit_in_bytes", mem);
>
> + if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
> + if (errno == ENOENT) {
> + tst_resm(TCONF,
> + "memcg swap accounting is disabled");
> + swap_acc_on = 0;
> + } else
> + tst_brkm(TBROK|TERRNO, cleanup, "access");
Here also need a parentheses for "else" , but it's just as well.
Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Thanks,
Wanlong Gao
> + }
> +
> tst_resm(TINFO, "process mempolicy.");
> testoom(1, 0, 1);
>
> - write_file(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", mem);
> - testoom(1, 1, 1);
> + if (swap_acc_on) {
> + write_file(MEMCG_SW_LIMIT, mem);
> + testoom(1, 1, 1);
> + }
>
> tst_resm(TINFO, "process cpuset.");
>
> - write_file(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", "-1");
> + if (swap_acc_on)
> + write_file(MEMCG_SW_LIMIT, "-1");
> testoom(0, 0, 1);
>
> - write_file(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", mem);
> - testoom(0, 1, 1);
> + if (swap_acc_on) {
> + write_file(MEMCG_SW_LIMIT, mem);
> + testoom(0, 1, 1);
> + }
> }
> cleanup();
> tst_exit();
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v3] mem/oom: avoid unexpected error when no memcg swap accounting
2012-03-19 10:28 [LTP] [PATCH v3] mem/oom: avoid unexpected error when no memcg swap accounting Zhouping Liu
2012-03-19 11:00 ` Wanlong Gao
@ 2012-03-19 11:28 ` Caspar Zhang
1 sibling, 0 replies; 3+ messages in thread
From: Caspar Zhang @ 2012-03-19 11:28 UTC (permalink / raw)
To: Zhouping Liu; +Cc: LTP List, Cai Qian
On 03/19/2012 06:28 PM, Zhouping Liu wrote:
> Since commit http://git.kernel.org/linus/a42c390cfa0c,
> which added an option to control memcg swap, when kernel
> neither set CGROUP_MEM_RES_CTLR_SWAP_ENABLED nor add
> 'swapaccount=1' kernel parameter, that indicates memcg swap
> accounting is disabled, it will have no such file:
> memory.memsw.*, then oom03 & oom04 cases will fail.
>
> The patch fixed it: removed memsw cases when memcg swap
> accounting is disabled, and added a TCONF:
> tst_resm(TCONF,"memcg swap accounting is disabled");
>
> Signed-off-by: Zhouping Liu <zliu@redhat.com>
> Reviewed-by: Caspar Zhang <czhang@redhat.com>
>
...
> - write_file(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", mem);
> - testoom(0, 1, 1);
> + if (swap_acc_on) {
You should remove trailing whitespace.
Committed with this update.
Thanks,
Caspar
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-19 12:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-19 10:28 [LTP] [PATCH v3] mem/oom: avoid unexpected error when no memcg swap accounting Zhouping Liu
2012-03-19 11:00 ` Wanlong Gao
2012-03-19 11:28 ` Caspar Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox