<div dir="ltr"><div><div>Hi,<br><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 17, 2015 at 11:10 AM, Li Wang <span dir="ltr"><<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Wed, Sep 16, 2015 at 8:12 PM, Jan Stancek <span dir="ltr"><<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br>
<br>
<br>
<br>
----- Original Message -----<br>
> From: "Li Wang" <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>><br>
> To: <a href="mailto:ltp@lists.linux.it" target="_blank">ltp@lists.linux.it</a><br>
> Sent: Wednesday, 16 September, 2015 11:55:32 AM<br>
> Subject: [LTP] [PATCH v2] lib/mem.c: handle the case oom0{3, 5} exit with 'EAGAIN' situation<br>
><br>
> v1 --> v2<br>
> 1. limited the number of loops<br>
> 2. added the usleep(300) to wait resource freed<br>
><br>
> Sometimes oom0{3,5} failed as the following results:<br>
><br>
> oom05 0 TINFO : start OOM testing for mlocked pages.<br>
> oom05 0 TINFO : expected victim is 3371.<br>
> oom05 0 TINFO : thread (3fff788ff1c0), allocating 3221225472 bytes.<br>
> ...<br>
> oom05 5 TFAIL : mem.c:153: victim unexpectedly ended with retcode:<br>
> 11, expected: 12<br>
><br>
> In the OOM test, that tries to consume all memory. But the test doesn't retry<br>
> to mlock, it simply<br>
> exits with errno returned by mlock. At the moment testcase is expecting<br>
> either ENOMEM or getting<br>
> killed by kernel.<br>
><br>
> Here do retry the function if mlock() fail with 'EAGAIN' errno.<br>
><br>
> Signed-off-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>><br>
> ---<br>
> testcases/kernel/mem/lib/mem.c | 12 ++++++++++--<br>
> 1 file changed, 10 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c<br>
> index 8fe4bf0..b8a55e2 100644<br>
> --- a/testcases/kernel/mem/lib/mem.c<br>
> +++ b/testcases/kernel/mem/lib/mem.c<br>
> @@ -30,6 +30,7 @@ static int alloc_mem(long int length, int testcase)<br>
> {<br>
> char *s;<br>
> long i, pagesz = getpagesize();<br>
> + int loop = 10;<br>
><br>
> tst_resm(TINFO, "thread (%lx), allocating %ld bytes.",<br>
> (unsigned long) pthread_self(), length);<br>
> @@ -39,8 +40,15 @@ static int alloc_mem(long int length, int testcase)<br>
> if (s == MAP_FAILED)<br>
> return errno;<br>
><br>
> - if (testcase == MLOCK && mlock(s, length) == -1)<br>
> - return errno;<br>
> + if (testcase == MLOCK) {<br>
> + while (mlock(s, length) == -1 && loop > 0) {<br>
> + if (EAGAIN != errno)<br>
> + return errno;<br>
> + usleep(300);<br>
<br>
</div></div>usleep is in microseconds, so this wouldn't give system much time.<br></blockquote></div></div></div></div></div></blockquote><div><br>Sorry, Ping.<br><br>Would you mind if I sent V3 with usleep(300000)? or any other advice?<br></div></div><br clear="all"><br>-- <br><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Regards,<br></div>Li Wang<br></div><div>Email: <a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a><br></div></div></div></div></div></div>
</div></div></div></div>