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(); }
static void setup(void) { int memnode, ret; if (!is_numa(NULL, NH_MEMS, 1)) tst_brk(TCONF, "requires NUMA with at least 1 node"); overcommit = get_sys_tune("overcommit_memory"); set_sys_tune("overcommit_memory", 1, 1); mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW); cpuset_mounted = 1; /* * Some nodes do not contain memory, so use * get_allowed_nodes(NH_MEMS) to get a memory * node. This operation also applies to Non-NUMA * systems. */ ret = get_allowed_nodes(NH_MEMS, 1, &memnode); if (ret < 0) tst_brk(TBROK, "Failed to get a memory node " "using get_allowed_nodes()"); write_cpusets(memnode); }
void setup(void) { int ret, memnode; tst_require_root(); tst_sig(FORK, DEF_HANDLER, cleanup); TEST_PAUSE; if (!is_numa(NULL, NH_MEMS, 1)) tst_brkm(TCONF, NULL, "requires NUMA with at least 1 node"); overcommit = get_sys_tune("overcommit_memory"); set_sys_tune("overcommit_memory", 1, 1); mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW); mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW); write_memcg(); /* * Some nodes do not contain memory, so use * get_allowed_nodes(NH_MEMS) to get a memory * node. This operation also applies to Non-NUMA * systems. */ ret = get_allowed_nodes(NH_MEMS, 1, &memnode); if (ret < 0) tst_brkm(TBROK, cleanup, "Failed to get a memory node " "using get_allowed_nodes()"); write_cpusets(memnode); }
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(); }
void setup(void) { tst_require_root(); tst_sig(FORK, DEF_HANDLER, cleanup); TEST_PAUSE; if (!is_numa(NULL)) tst_brkm(TCONF, NULL, "The case need a NUMA system."); overcommit = get_sys_tune("overcommit_memory"); set_sys_tune("overcommit_memory", 1, 1); }
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); } }
void setup(void) { tst_require_root(NULL); if (access(PATH_THP, F_OK) == -1) tst_brkm(TCONF, NULL, "THP is not enabled"); if (!is_numa(NULL)) tst_brkm(TCONF, NULL, "The case need a NUMA system."); SAFE_FILE_SCANF(NULL, PATH_KHPD "scan_sleep_millisecs", "%d", &pre_thp_scan_sleep_millisecs); SAFE_FILE_PRINTF(NULL, PATH_KHPD "scan_sleep_millisecs", "0"); SAFE_FILE_SCANF(NULL, PATH_KHPD "alloc_sleep_millisecs", "%d", &pre_thp_alloc_sleep_millisecs); SAFE_FILE_PRINTF(NULL, PATH_KHPD "alloc_sleep_millisecs", "0"); SAFE_FILE_SCANF(NULL, PATH_THP "enabled", "%[^\n]", pre_thp_enabled); SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "always"); tst_sig(FORK, DEF_HANDLER, NULL); TEST_PAUSE; }