int main(int argc, char *argv[]) { int lc; tst_parse_opts(argc, argv, NULL, NULL); #if __WORDSIZE == 32 tst_brkm(TCONF, NULL, "test is not designed for 32-bit system."); #endif setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; tst_resm(TINFO, "OOM on CPUSET..."); testoom(0, 0, ENOMEM, 1); if (is_numa(cleanup)) { /* * Under NUMA system, the migration of cpuset's memory * is in charge of cpuset.memory_migrate, we can write * 1 to cpuset.memory_migrate to enable the migration. */ write_cpuset_files(CPATH_NEW, "memory_migrate", "1"); tst_resm(TINFO, "OOM on CPUSET with mem migrate:"); testoom(0, 0, ENOMEM, 1); } } cleanup(); tst_exit(); }
int main(int argc, char *argv[]) { char *msg; int lc; msg = parse_opts(argc, argv, NULL, NULL); if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); #if __WORDSIZE == 32 tst_brkm(TCONF, NULL, "test is not designed for 32-bit system."); #endif setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { Tst_count = 0; tst_resm(TINFO, "process mempolicy."); testoom(1, 0, 1); tst_resm(TINFO, "process cpuset."); testoom(0, 0, 1); } cleanup(); tst_exit(); }
int main(int argc, char *argv[]) { int lc; tst_parse_opts(argc, argv, NULL, NULL); #if __WORDSIZE == 32 tst_brkm(TCONF, NULL, "test is not designed for 32-bit system."); #endif setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; tst_resm(TINFO, "OOM on MPOL_BIND mempolicy..."); testoom(MPOL_BIND, 0, ENOMEM, 1); tst_resm(TINFO, "OOM on MPOL_INTERLEAVE mempolicy..."); testoom(MPOL_INTERLEAVE, 0, ENOMEM, 1); tst_resm(TINFO, "OOM on MPOL_PREFERRED mempolicy..."); testoom(MPOL_PREFERRED, 0, ENOMEM, 1); } cleanup(); tst_exit(); }
int main(int argc, char *argv[]) { char *msg; int lc; int swap_acc_on = 1; msg = parse_opts(argc, argv, NULL, NULL); if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); #if __WORDSIZE == 32 tst_brkm(TCONF, NULL, "test is not designed for 32-bit system."); #endif setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; tst_resm(TINFO, "OOM on CPUSET & MEMCG..."); testoom(0, 0); /* * Under NUMA system, the migration of cpuset's memory * is in charge of cpuset.memory_migrate, we can write * 1 to cpuset.memory_migrate to enable the migration. */ if (is_numa(cleanup)) { write_cpuset_files(CPATH_NEW, "memory_migrate", "1"); tst_resm(TINFO, "OOM on CPUSET & MEMCG with " "cpuset.memory_migrate=1"); testoom(0, 0); } 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"); } if (swap_acc_on) { tst_resm(TINFO, "OOM on CPUSET & MEMCG with " "special memswap limitation:"); SAFE_FILE_PRINTF(cleanup, MEMCG_SW_LIMIT, "%ld", TESTMEM); testoom(0, 0); tst_resm(TINFO, "OOM on CPUSET & MEMCG with " "disabled memswap limitation:"); SAFE_FILE_PRINTF(cleanup, MEMCG_SW_LIMIT, "-1"); testoom(0, 0); } } cleanup(); tst_exit(); }
int main(int argc, char *argv[]) { char *msg; int lc; int swap_acc_on = 1; char buf[BUFSIZ], mem[BUFSIZ]; msg = parse_opts(argc, argv, NULL, NULL); if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); #if __WORDSIZE == 32 tst_brkm(TCONF, NULL, "test is not designed for 32-bit system."); #endif setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { Tst_count = 0; snprintf(buf, BUFSIZ, "%d", getpid()); write_file(MEMCG_PATH_NEW "/tasks", buf); 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); if (swap_acc_on) { write_file(MEMCG_SW_LIMIT, mem); testoom(1, 1, 1); } tst_resm(TINFO, "process cpuset."); if (swap_acc_on) write_file(MEMCG_SW_LIMIT, "-1"); testoom(0, 0, 1); if (swap_acc_on) { write_file(MEMCG_SW_LIMIT, mem); testoom(0, 1, 1); } } cleanup(); tst_exit(); }
int main(int argc, char *argv[]) { int lc; tst_parse_opts(argc, argv, NULL, NULL); #if __WORDSIZE == 32 tst_brkm(TCONF, NULL, "test is not designed for 32-bit system."); #endif setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; /* we expect mmap to fail before OOM is hit */ set_sys_tune("overcommit_memory", 2, 1); oom(OVERCOMMIT, 0, ENOMEM, 0); /* with overcommit_memory set to 0 or 1 there's no * guarantee that mmap fails before OOM */ set_sys_tune("overcommit_memory", 0, 1); oom(OVERCOMMIT, 0, ENOMEM, 1); set_sys_tune("overcommit_memory", 1, 1); testoom(0, 0, ENOMEM, 1); } cleanup(); tst_exit(); }
int main(int argc, char *argv[]) { const char *msg; int lc; msg = parse_opts(argc, argv, NULL, NULL); if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); #if __WORDSIZE == 32 tst_brkm(TCONF, NULL, "test is not designed for 32-bit system."); #endif setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; SAFE_FILE_PRINTF(cleanup, MEMCG_PATH_NEW "/tasks", "%d", getpid()); SAFE_FILE_PRINTF(cleanup, MEMCG_LIMIT, "%ld", TESTMEM); testoom(0, 0, ENOMEM, 1); 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 { SAFE_FILE_PRINTF(cleanup, MEMCG_SW_LIMIT, "%ld", TESTMEM); testoom(0, 1, ENOMEM, 1); } /* OOM for MEMCG with mempolicy */ if (is_numa(cleanup)) { tst_resm(TINFO, "OOM on MEMCG & mempolicy..."); testoom(MPOL_BIND, 0, ENOMEM, 1); testoom(MPOL_INTERLEAVE, 0, ENOMEM, 1); testoom(MPOL_PREFERRED, 0, ENOMEM, 1); } } cleanup(); tst_exit(); }
static void verify_oom(void) { #if __WORDSIZE == 32 tst_brk(TCONF, "test is not designed for 32-bit system."); #endif tst_res(TINFO, "OOM on CPUSET..."); testoom(0, 0, ENOMEM, 1); if (is_numa(NULL, NH_MEMS, 2)) { /* * Under NUMA system, the migration of cpuset's memory * is in charge of cpuset.memory_migrate, we can write * 1 to cpuset.memory_migrate to enable the migration. */ write_cpuset_files(CPATH_NEW, "memory_migrate", "1"); tst_res(TINFO, "OOM on CPUSET with mem migrate:"); testoom(0, 0, ENOMEM, 1); } }
int main(int argc, char *argv[]) { char *msg; int lc, fd; unsigned long nnodes = 1; char buf[BUFSIZ], mem[BUFSIZ]; if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); #if __WORDSIZE == 32 tst_brkm(TCONF, NULL, "test is not designed for 32-bit system."); #endif nnodes = count_numa(); if (count_numa() == 1) tst_brkm(TCONF, NULL, "required a NUMA system."); setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { Tst_count = 0; fd = open(SYSFS_OVER, O_WRONLY); if (fd == -1) tst_brkm(TBROK|TERRNO, cleanup, "open"); if (write(fd, "1", 1) != 1) tst_brkm(TBROK|TERRNO, cleanup, "write"); close(fd); fd = open(MEMCG_PATH_NEW "/memory.limit_in_bytes", O_WRONLY); if (fd == -1) tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf); sprintf(mem, "%ld", TESTMEM); if (write(fd, mem, strlen(mem)) != strlen(mem)) tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf); close(fd); fd = open(MEMCG_PATH_NEW "/tasks", O_WRONLY); if (fd == -1) tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf); snprintf(buf, BUFSIZ, "%d", getpid()); if (write(fd, buf, strlen(buf)) != strlen(buf)) tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf); close(fd); tst_resm(TINFO, "process mempolicy."); testoom(1, 0, 1); fd = open(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", O_WRONLY); if (fd == -1) tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf); if (write(fd, mem, strlen(mem)) != strlen(mem)) tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf); close(fd); testoom(1, 1, 1); tst_resm(TINFO, "process cpuset."); fd = open(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", O_WRONLY); if (fd == -1) tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf); sprintf(mem, "%ld", TESTMEM); if (write(fd, "-1", 2) != 2) tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf); close(fd); testoom(0, 0, 1); fd = open(MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes", O_WRONLY); if (fd == -1) tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf); if (write(fd, mem, strlen(mem)) != strlen(mem)) tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf); close(fd); testoom(0, 1, 1); } cleanup(); }