lib/mem.c: handle mlock returning EAGAIN

Sometimes oom0{3,5} failed with following results:

oom05       0  TINFO  :  start OOM testing for mlocked pages.
oom05       0  TINFO  :  expected victim is 3371.
oom05       0  TINFO  :  thread (3fff788ff1c0), allocating 3221225472 bytes.
...
oom05       5  TFAIL  :  mem.c:153: victim unexpectedly ended with retcode: 11, expected: 12

In the OOM test, that tries to consume all memory, but it doesn't
retry to mlock, it simply exits with errno returned by mlock. At the
moment testcase is expecting either ENOMEM or getting killed by kernel.

Retry mlock() if it returns EAGAIN for limited number of attempts
(at the moment 10).

Signed-off-by: Li Wang <liwang@redhat.com>
Reviewed-by: Jan Stancek <jstancek@redhat.com>
1 file changed