void setup(void) { int memnode, ret; tst_require_root(NULL); tst_sig(FORK, DEF_HANDLER, cleanup); TEST_PAUSE; overcommit = get_sys_tune("overcommit_memory"); set_sys_tune("overcommit_memory", 1, 1); mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW); /* * 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, NULL, "Failed to get a memory node " "using get_allowed_nodes()"); write_cpusets(memnode); }
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[]) { int lc; int size = 128, num = 3, unit = 1; unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 }; unsigned int node; tst_parse_opts(argc, argv, ksm_options, ksm_usage); node = get_a_numa_node(tst_exit); set_node(nmask, node); setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; check_ksm_options(&size, &num, &unit); if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1) { if (errno != ENOSYS) tst_brkm(TBROK | TERRNO, cleanup, "set_mempolicy"); else tst_brkm(TCONF, cleanup, "set_mempolicy syscall is not " "implemented on your system."); } create_same_memory(size, num, unit); write_cpusets(node); create_same_memory(size, num, unit); } cleanup(); tst_exit(); }
void testoom(int mempolicy, int lite, int numa) { if (numa && !mempolicy) write_cpusets(); tst_resm(TINFO, "start normal OOM testing."); oom(NORMAL, mempolicy, lite); tst_resm(TINFO, "start OOM testing for mlocked pages."); oom(MLOCK, mempolicy, lite); if (access(PATH_KSM, F_OK) == -1) tst_brkm(TCONF, NULL, "KSM configuration is not enabled"); tst_resm(TINFO, "start OOM testing for KSM pages."); oom(KSM, mempolicy, lite); }
int main(int argc, char *argv[]) { int lc; char *msg; int size = 128, num = 3, unit = 1; unsigned long nnodes = 1; unsigned long nmask = 2; msg = parse_opts(argc, argv, ksm_options, ksm_usage); if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); 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; check_ksm_options(&size, &num, &unit); write_memcg(); if (set_mempolicy(MPOL_BIND, &nmask, MAXNODES) == -1) { if (errno != ENOSYS) tst_brkm(TBROK|TERRNO, cleanup, "set_mempolicy"); else tst_brkm(TCONF, cleanup, "set_mempolicy syscall is not implemented on your system."); } create_same_memory(size, num, unit); write_cpusets(); create_same_memory(size, num, unit); } cleanup(); tst_exit(); }