public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] mem/lib: keep allocating memory until get an error in single process
@ 2016-06-20  9:53 Li Wang
  2016-06-20 10:43 ` Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Li Wang @ 2016-06-20  9:53 UTC (permalink / raw)
  To: ltp

We occasionally catch errors like:
oom03       0  TINFO  :  start OOM testing for KSM pages.
oom03       0  TINFO  :  expected victim is 3490.
oom03       6  TFAIL  :  mem.c:163: victim unexpectedly ended with retcode: 0, expected: 12
oom03       0  TINFO  :  set overcommit_memory to 0

It cames from the caller testoom(0, 1, ENOMEM, 1). The full reason is that
function child_alloc() go into single process mode, then successfully finish
the memory allocation and return 0.

In this patch, let's make it (in single mode) keep allocating memory with
an incresed length in order to avoid 0 returned.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/mem/lib/mem.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 3d853a3..c1f91ce 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -70,11 +70,17 @@ static void *child_alloc_thread(void *args)
 
 static void child_alloc(int testcase, int lite, int threads)
 {
-	int i;
+	int i, ret;
 	pthread_t *th;
 
 	if (lite) {
-		int ret = alloc_mem(TESTMEM + MB, testcase);
+		long length = TESTMEM + MB;
+
+		/* keep allocating until there's an error */
+		while (!ret) {
+			ret = alloc_mem(length, testcase);
+			length += MB;
+		}
 		exit(ret);
 	}
 
-- 
1.8.3.1


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

end of thread, other threads:[~2016-06-21  3:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-20  9:53 [LTP] [PATCH] mem/lib: keep allocating memory until get an error in single process Li Wang
2016-06-20 10:43 ` Jan Stancek
2016-06-20 11:34   ` Li Wang
2016-06-20 13:03     ` Jan Stancek
2016-06-21  3:26       ` Li Wang

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