mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy'
NUMA mechanism can be interpreted as 'memory policy', there are
several mempolicys, such as MPOL_BIND, MPOL_INTERLEAVE,
MPOL_PREFERRED etc, not only MPOL_BIND, so the patch extended OOM
on NUMA system, added MPOL_INTERLEAVE and MPOL_PREFERRED mempolicy.
And the patch also moved 'set_mempolicy()' from child process, and
made it executed inside testoom() func, which is easy to control.
Signed-off-by: Zhouping Liu <zliu@redhat.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
diff --git a/testcases/kernel/mem/oom/oom02.c b/testcases/kernel/mem/oom/oom02.c
index abd8aa2..31ec73f 100644
--- a/testcases/kernel/mem/oom/oom02.c
+++ b/testcases/kernel/mem/oom/oom02.c
@@ -1,5 +1,5 @@
/*
- * Out Of Memory (OOM) for NUMA
+ * Out Of Memory (OOM) for mempolicy - need NUMA system support
*
* The program is designed to cope with unpredictable like amount and
* system physical memory, swap size and other VMM technology like KSM,
@@ -44,6 +44,8 @@
#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
&& HAVE_MPOL_CONSTANTS
+#include <numaif.h>
+
int main(int argc, char *argv[])
{
char *msg;
@@ -62,11 +64,14 @@
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
- tst_resm(TINFO, "process mempolicy.");
- testoom(1, 0, 1);
+ tst_resm(TINFO, "OOM on MPOL_BIND mempolicy...");
+ testoom(MPOL_BIND, 0, 1);
- tst_resm(TINFO, "process cpuset.");
- testoom(0, 0, 1);
+ tst_resm(TINFO, "OOM on MPOL_INTERLEAVE mempolicy...");
+ testoom(MPOL_INTERLEAVE, 0, 1);
+
+ tst_resm(TINFO, "OOM on MPOL_PREFERRED mempolicy...");
+ testoom(MPOL_PREFERRED, 0, 1);
}
cleanup();
tst_exit();
@@ -78,15 +83,16 @@
tst_sig(FORK, DEF_HANDLER, cleanup);
TEST_PAUSE;
+ /* Judge a NUMA system through get_a_numa_node */
+ get_a_numa_node(NULL);
+
overcommit = get_sys_tune("overcommit_memory");
set_sys_tune("overcommit_memory", 1, 1);
- mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
}
void cleanup(void)
{
set_sys_tune("overcommit_memory", overcommit, 0);
- umount_mem(CPATH, CPATH_NEW);
TEST_CLEANUP;
}