From: Caspar Z. <su...@li...> - 2012-04-01 07:46:29
|
The branch, master, has been updated via 4f267b6fd11749c91211c9dbfc706cf46919650b (commit) from 4611a5fc40dfcfd738dd73d8aa1c1c37cd4f012d (commit) - Log ----------------------------------------------------------------- commit 4f267b6fd11749c91211c9dbfc706cf46919650b Author: Zhouping Liu <zl...@re...> Date: Fri Mar 30 22:29:58 2012 +0800 mm/tunable: fix unexpected error log in min_free_kbytes when overcommit_memory=0, mmap() will be destroyed in two below scenario: 1) MAP_FAILED with ENOMEM, 2) oom_killer kill it. without the patch, it just catched oom_killer scenario, the patch fixed it. Signed-off-by: Zhouping Liu <zl...@re...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/mem/tunable/min_free_kbytes.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/testcases/kernel/mem/tunable/min_free_kbytes.c b/testcases/kernel/mem/tunable/min_free_kbytes.c index a69e129..00ead04 100644 --- a/testcases/kernel/mem/tunable/min_free_kbytes.c +++ b/testcases/kernel/mem/tunable/min_free_kbytes.c @@ -92,7 +92,6 @@ int main(int argc, char *argv[]) exit(0); } - for (lc = 0; TEST_LOOPING(lc); lc++) { Tst_count = 0; @@ -101,7 +100,6 @@ int main(int argc, char *argv[]) test_tune(1); } - if (kill(pid, SIGUSR1) == -1) tst_brkm(TBROK|TERRNO, cleanup, "kill %d", pid); if (waitpid(pid, &status, WUNTRACED|WCONTINUED) == -1) @@ -150,10 +148,21 @@ static void test_tune(unsigned long overcommit_policy) if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) tst_resm(TFAIL, "child unexpectedly failed: %d", status); - } else { + } else if (overcommit_policy == 1) { if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGKILL) tst_resm(TFAIL, "child unexpectedly failed: %d", status); + } else { + if (WIFEXITED(status)) { + if (WEXITSTATUS(status) != 0) { + tst_resm(TFAIL, "child unexpectedly " + "failed: %d", status); + } + } else if (!WIFSIGNALED(status) || + WTERMSIG(status) != SIGKILL) { + tst_resm(TFAIL, + "child unexpectedly failed: %d", status); + } } } } @@ -178,7 +187,7 @@ static int eatup_mem(unsigned long overcommit_policy) addrs[i] = mmap(NULL, MAP_SIZE, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); if (addrs[i] == MAP_FAILED) { - if (overcommit_policy != 2 || errno != ENOMEM) { + if (overcommit_policy != 1 && errno != ENOMEM) { perror("mmap"); ret = -1; } hooks/post-receive -- ltp |