void testoom(int mempolicy, int lite, int retcode, int allow_sigkill) { int ksm_run_orig; set_global_mempolicy(mempolicy); tst_res(TINFO, "start normal OOM testing."); oom(NORMAL, lite, retcode, allow_sigkill); tst_res(TINFO, "start OOM testing for mlocked pages."); oom(MLOCK, lite, retcode, allow_sigkill); /* * Skip oom(KSM) if lite == 1, since limit_in_bytes may vary from * run to run, which isn't reliable for oom03 cgroup test. */ if (access(PATH_KSM, F_OK) == -1 || lite == 1) { tst_res(TINFO, "KSM is not configed or lite == 1, " "skip OOM test for KSM pags"); } else { tst_res(TINFO, "start OOM testing for KSM pages."); SAFE_FILE_SCANF(PATH_KSM "run", "%d", &ksm_run_orig); SAFE_FILE_PRINTF(PATH_KSM "run", "1"); oom(KSM, lite, retcode, allow_sigkill); SAFE_FILE_PRINTF(PATH_KSM "run", "%d", ksm_run_orig); } }
void testoom(int mempolicy, int lite, int retcode, int allow_sigkill) { set_global_mempolicy(mempolicy); tst_resm(TINFO, "start normal OOM testing."); oom(NORMAL, lite, retcode, allow_sigkill); tst_resm(TINFO, "start OOM testing for mlocked pages."); oom(MLOCK, lite, retcode, allow_sigkill); if (access(PATH_KSM, F_OK) == -1) { tst_resm(TINFO, "KSM configuration is not enabled, " "skip OOM test for KSM pags"); } else { tst_resm(TINFO, "start OOM testing for KSM pages."); oom(KSM, lite, retcode, allow_sigkill); } }
void testoom(int mempolicy, int lite, int retcode, int allow_sigkill) { int ksm_run_orig; set_global_mempolicy(mempolicy); tst_resm(TINFO, "start normal OOM testing."); oom(NORMAL, lite, retcode, allow_sigkill); tst_resm(TINFO, "start OOM testing for mlocked pages."); oom(MLOCK, lite, retcode, allow_sigkill); if (access(PATH_KSM, F_OK) == -1) { tst_resm(TINFO, "KSM configuration is not enabled, " "skip OOM test for KSM pags"); } else { tst_resm(TINFO, "start OOM testing for KSM pages."); SAFE_FILE_SCANF(cleanup, PATH_KSM "run", "%d", &ksm_run_orig); SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "1"); oom(KSM, lite, retcode, allow_sigkill); SAFE_FILE_PRINTF(cleanup,PATH_KSM "run", "%d", ksm_run_orig); } }
void test_transparent_hugepage(int nr_children, int nr_thps, int hg_aligned, int mempolicy) { unsigned long hugepagesize, memfree; int i, *pids, ret, status; if (mempolicy) set_global_mempolicy(mempolicy); memfree = read_meminfo("MemFree:"); tst_resm(TINFO, "The current MemFree is %luMB", memfree / KB); if (memfree < MB) tst_resm(TCONF, "Not enough memory for testing"); hugepagesize = read_meminfo("Hugepagesize:"); tst_resm(TINFO, "The current Hugepagesize is %luMB", hugepagesize / KB); pids = malloc(nr_children * sizeof(int)); if (pids == NULL) tst_brkm(TBROK | TERRNO, cleanup, "malloc"); for (i = 0; i < nr_children; i++) { switch (pids[i] = fork()) { case -1: tst_brkm(TBROK | TERRNO, cleanup, "fork"); case 0: ret = alloc_transparent_hugepages(nr_thps, hg_aligned); exit(ret); } } tst_resm(TINFO, "Stop all children..."); for (i = 0; i < nr_children; i++) { if (waitpid(pids[i], &status, WUNTRACED) == -1) tst_brkm(TBROK|TERRNO, cleanup, "waitpid"); if (!WIFSTOPPED(status)) tst_brkm(TBROK, cleanup, "child[%d] was not stoppted", pids[i]); } tst_resm(TINFO, "Start to scan all transparent hugepages..."); khugepaged_scan_done(); tst_resm(TINFO, "Start to verify transparent hugepage size..."); verify_thp_size(pids, nr_children, nr_thps); tst_resm(TINFO, "Wake up all children..."); for (i = 0; i < nr_children; i++) { if (kill(pids[i], SIGCONT) == -1) tst_brkm(TBROK | TERRNO, cleanup, "signal continue child[%d]", pids[i]); } /* wait all children finish their task */ for (i = 0; i < nr_children; i++) { if (waitpid(pids[i], &status, 0) == -1) tst_brkm(TBROK|TERRNO, cleanup, "waitpid %d", pids[i]); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) tst_resm(TFAIL, "the child[%d] unexpectedly failed:" " %d", pids[i], status); } }