[LTP] [PATCH v2] syscalls/mlock05: add mlock test for locking and pre-faulting of memory

Filippo Storniolo fstornio@redhat.com
Thu May 2 11:12:42 CEST 2024


Hi Cyril, thank you for your review.

After some investigation, I realized the issue is caused by the
unreliability of the VmRSS field in /proc/$pid/status.
Documentation suggests to use /proc/$pid/smaps for reliable information.

This file contains information about each memory mapping, so it contains
multiple instances of the VmRss field (In this file is simply referred as
Rss).

I managed to run the test without any failures using a custom function.
What we need to do is to iterate through the memory mappings until we find
the one we need. We can use the memory address retrieved by mmap to locate
the desired one.

Once we find the mapping, we can then search the Rss field.

This is the output I had using this approach:

TPASS: Expect: (VmRSS=1048576) >= (MMAPLEN=1048576)
TPASS: VmLck == MMAPLEN (1048576)

Summary:
passed  20000
failed   0
broken   0
skipped  0
warnings 0

Do you think this can work as a solution or you prefer another way around?

F. Storniolo



On Mon, Apr 29, 2024 at 3:49 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > check VmRSS and VmLck variables from /proc/$pid/status.
> > VmRSS size should at least as big as the memory allocation.
> > VmLck size should be equal to the size of the memory allocation.
>
> Now the test looks good, however I managed to make it fail. The test
> fails if you run it with large enough -i paramater, for me running
> './mlock05 -i 10000' tend to produce failures at the end of the testrun:
>
> tst_test.c:1741: TINFO: LTP version: 20240129-192-geca801321
> tst_test.c:1625: TINFO: Timeout per run is 0h 00m 30s
> mlock05.c:49: TPASS: Expect: (VmRSS=1048576) >= (MMAPLEN=1048576)
> mlock05.c:52: TPASS: VmLck == MMAPLEN (1048576)
> ...
> mlock05.c:52: TPASS: VmLck == MMAPLEN (1048576)
> mlock05.c:49: TFAIL: Expect: (VmRSS=983040) >= (MMAPLEN=1048576)
> mlock05.c:52: TPASS: VmLck == MMAPLEN (1048576)
> mlock05.c:49: TFAIL: Expect: (VmRSS=983040) >= (MMAPLEN=1048576)
> mlock05.c:52: TPASS: VmLck == MMAPLEN (1048576)
>
> Summary:
> passed   18332
> failed   1668
> broken   0
> skipped  0
> warnings 0
> ...
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
>


More information about the ltp mailing list