public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] mm/tunable: fix unexpected error log in min_free_kbytes
@ 2012-03-30 14:29 Zhouping Liu
  2012-04-01  7:51 ` Caspar Zhang
  0 siblings, 1 reply; 2+ messages in thread
From: Zhouping Liu @ 2012-03-30 14:29 UTC (permalink / raw)
  To: LTP List

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]


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 <zliu@redhat.com>
---
 testcases/kernel/mem/tunable/min_free_kbytes.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-mm-tunable-fix-unexpected-error-log-in-min_free_kbyt.patch --]
[-- Type: text/x-patch; name="0001-mm-tunable-fix-unexpected-error-log-in-min_free_kbyt.patch", Size: 1672 bytes --]

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;
 			}

[-- Attachment #3: Type: text/plain, Size: 191 bytes --]

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-01  7:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-30 14:29 [LTP] [PATCH] mm/tunable: fix unexpected error log in min_free_kbytes Zhouping Liu
2012-04-01  7:51 ` Caspar Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox