All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] mmap22: Improve MAP_DROPPABLE test stability using mincore()
Date: Tue, 23 Sep 2025 13:07:32 +0200	[thread overview]
Message-ID: <20250923110732.GA9158@pevik> (raw)
In-Reply-To: <20250917075729.30093-1-liwang@redhat.com>

Hi Li,

> The current mmap22 test validates MAP_DROPPABLE by writing to the
> allocated memory and checking for zero-filled pages under memory
> pressure. However, this approach is unreliable because:

>   - Child process memory pressure (malloc + single writes) may not
>     reliably trigger cgroup memory reclaim.
>   - Checking memory content (alloc[i] == 0) is insufficient to
>     confirm kernel reclamation, as pages may remain resident but not
>     overwritten.
>   - Race conditions during child cleanup could leave residual cgroup
>     processes.

Thanks for the investigation.

> Error logs:

>    command: mmap22
>    tst_tmpdir.c:316: TINFO: Using /tmp/LTP_mmaxrtyKb as tmpdir (xfs filesystem)
>    tst_test.c:1953: TINFO: LTP version: 20250530
>    tst_kconfig.c:88: TINFO: Parsing kernel config '/lib/modules/6.12.0-130.1445_2041086229.el10.x86_64+rt/build/.config'
>    tst_test.c:1774: TINFO: Overall timeout per run is 0h 05m 54s
>    tst_test.c:1837: TINFO: Killed the leftover descendant processes
>    tst_test.c:1846: TINFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1
>    tst_test.c:1848: TBROK: Test killed! (timeout?)
>    tst_cgroup.c:1043: TBROK: unlinkat(5</sys/fs/cgroup/ltp>, 'test-92902', AT_REMOVEDIR): EBUSY (16)
>    ...

> This patch improves the test in the following ways:

>   * Use mincore() to precisely detect if MAP_DROPPABLE pages have
>     been reclaimed by the kernel.
>   * Replace the old child loop with a stronger memory pressure loop
>     (malloc + memset), ensuring cgroup limits are hit quickly.
>   * Use SAFE_KILL + SAFE_WAITPID for robust child cleanup.
nit: SAFE_KILL + SAFE_WAITPID were used before, the change you did is to check
with 'if (child > 0)' if it's meaningful to attempt to kill child.

>   * Extend runtime and add short sleeps to reduce busy looping and
>     stabilize test results.
>   * Record page size during setup for consistent use across functions.

> As a result, the test becomes more stable, deterministic, and easier
> to reproduce under different kernels and configurations.

+1

...
> +static void stress_child(void)
> +{
> +	for (;;) {
> +		char *buf = malloc(page_size);
nit: Please insert a blank line here to keep checkpatch.pl quiet.
mmap22.c:39: WARNING: Missing a blank line after declarations

> +		if (!buf)
> +			exit(1);
> +		memset(buf, 'B', page_size);
> +	}
> +}

...
> +	for (;;) {
> +		if (!tst_remaining_runtime()) {
> +			tst_res(TFAIL, "MAP_DROPPABLE did not drop pages within timeout");
> +			goto cleanup;
> +		}
> +
> +		if (mincore(alloc, ALLOC_SIZE, vec) == -1)
> +			tst_brk(TBROK | TERRNO, "mincore failed");
NOTE: we have SAFE_MINCORE() (can be fixed during merge).

The rest LGTM.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2025-09-23 11:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17  7:57 [LTP] [PATCH] mmap22: Improve MAP_DROPPABLE test stability using mincore() Li Wang via ltp
2025-09-23 11:07 ` Petr Vorel [this message]
2025-09-24  0:43   ` Li Wang via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250923110732.GA9158@pevik \
    --to=pvorel@suse.cz \
    --cc=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.