[LTP] [PATCH v1] mmapstress06: TCONF on systems without swap space
Petr Vorel
pvorel@suse.cz
Tue Apr 28 18:34:15 CEST 2026
Hi all,
> Hi all,
> > mmapstress06 is designed to stress the mfile_swap kernel primitive, which
Uh, I overlooked "mfile_swap kernel primitive". Then the approach would make
sense, but is it really true? mfile_swap does not exist any more, not even in a
git log. Test was added in January 2003, e.g. even before 2.6.
> > manages shared anonymous memory. On architectures with large pages (like
> > 64KB on ppc64le), the test's hardcoded request for 32769 pages results
> > in a ~2GB mapping. So in suse test system configured with 2GB of RAM and
> > no swap space, the test will fails with following information:
I'm not really sure. if that's caused by missing swap or would it work on
machine with RAM big enough which has swap disabled (I guess you retest with
e.g. 8 GB RAM). Otherwise I'd prefer prefer to deal with errno ENOMEM (12)
instead (as I pointed out previously).
Kind regards,
Petr
> > mmapstress06: errno = 12; large mmap failed
> > for this test to run, it needs a mmap space of
> > 32769 pages
> > The failure occurs because the 2GB request cannot be fulfilled within
> > the 2GB RAM limit without swap backing. Since the test specifically
> > intends to exercise swap-related logic (mfile_swap), it should be skipped
> > with TCONF when the system lacks swap space.
> > Signed-off-by: Wei Gao <wegao@suse.com>
> > ---
> > testcases/kernel/mem/mmapstress/mmapstress06.c | 8 ++++++++
...
> > + if (tst_available_swap() <= 0) {
> > + tst_resm(TCONF, "Test requires swap space to exercise mfile_swap logic");
> Why to require swap for the test instead of checking for ENOMEM later?
> > + tst_exit();
> nit: I'd use tst_brkm() although it has ugly "Remaining cases broken" message as
> it will be more obvious when doing rewrite.
> > + }
> How about this? (with cleanup of ugly printf).
> Kind regards,
> Petr
> +++ testcases/kernel/mem/mmapstress/mmapstress06.c
> @@ -89,10 +89,12 @@ int main(int argc, char *argv[])
> (mmapaddr, (ANON_GRAN_PAGES_MAX * NMFPTEPG + 1) * pagesize,
> PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, 0,
> 0) == (caddr_t) - 1) {
> - ERROR("large mmap failed");
> - printf("for this test to run, it needs a mmap space of\n");
> - printf("%d pages\n", (ANON_GRAN_PAGES_MAX * NMFPTEPG + 1));
> - return 1;
> + if (errno == ENOMEM) {
> + tst_brkm(TCONF, NULL, "not enough memory or swap for mmap() %d pages",
> + ANON_GRAN_PAGES_MAX * NMFPTEPG + 1);
> + }
> +
> + tst_brkm(TBROK | TERRNO, NULL, "mmap() failed");
> }
> (void)sleep(sleep_time);
> (void)time(&t);
More information about the ltp
mailing list