Linux Test Project
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5] min_free_kbytes: Handle transient memory drops in check_monitor
Date: Thu, 6 Aug 2026 12:31:46 +0200	[thread overview]
Message-ID: <20260806103146.GA838915@pevik> (raw)
In-Reply-To: <20260729053803.9823-1-wegao@suse.com>

Hi Wei,

> High memory pressure can cause MemFree to temporarily drop below the
> min_free_kbytes threshold before the kernel reclaimer can catch up.
> This results in intermittent test failures, observed on openQA aarch64
> virtual machines.

> Implement a 2-second grace period with high-accuracy 10ms fixed polling
> in check_monitor() to allow the kernel time to reclaim memory.

> Introduce a 10% tolerance (90% threshold) for the MemFree check.
> Measurements under extreme pressure show MemFree can dip as low as
> ~50% to ~70% of the target. While it typically recovers above 90%
> within one second, hitting the exact 100% watermark sometimes can take
> significantly longer. This tolerance prevents false positives during the
> slow recovery tail while still ensuring memory is maintained near the
> required level.

> Also, increase the monitor's idle polling frequency from 2s to 100ms
> to improve responsiveness during the test run.

+1

> Enhanced diagnostics are added to report the minimum memory level seen
> during the pressure period to aid in future calibration.

> +++ b/testcases/kernel/mem/tunable/min_free_kbytes.c
...
>  	while (!end) {
>  		memfree = SAFE_READ_MEMINFO("MemFree:");
>  		tune = TST_SYS_CONF_LONG_GET(PATH_VM_MIN_FREE_KBYTES);
> +		/*
> +		 * Allow 10% tolerance to account for transient states.
> +		 */
> +		threshold = tune * 9 / 10;

>  		if (memfree < tune) {
> -			tst_res(TINFO, "MemFree is %lu kB, "
> -				"min_free_kbytes is %lu kB", memfree, tune);
> -			tst_res(TFAIL, "MemFree < min_free_kbytes");
> -			violated = 1;
> +			min_memfree = memfree;
> +			/*
> +			 * Give it some time to reclaim. The kernel should keep
> +			 * MemFree above min_free_kbytes, but transient drops
> +			 * are possible under high pressure.
> +			 * Check every 10ms for up to 2 seconds for high accuracy.
> +			 */
> +			for (i = 10; i <= 2000; i += 10) {
> +				usleep(10000);
You used i for usleep() in v1 and v2 [1]. Since v3 [2] you keep using
usleep(10000), therefore we could have just simple loop (readability):

			for (i = 0; i < 200; i++) {

Otherwise LGTM, thanks! (I don't agree with AI that 90% threshold is
hiding bugs). Please repost, so that we have patch in the new patchwork instance
in patchwork.kernel.org (+ please create an user on that instance if you haven't
already done), because old patchwork don't receive emails any more.

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

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/20260527050843.14963-1-wegao@suse.com/
[2] https://lore.kernel.org/ltp/20260531134250.25279-1-wegao@suse.com/

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

  parent reply	other threads:[~2026-08-06 10:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27  5:08 [LTP] [PATCH v2] mem/min_free_kbytes: Add grace period for memory reclaim Wei Gao via ltp
2026-05-27  5:31 ` [LTP] " linuxtestproject.agent
2026-05-27 15:40 ` [LTP] [PATCH v2] " Cyril Hrubis
2026-05-29 16:07   ` Petr Vorel
2026-05-31 13:51     ` Wei Gao via ltp
2026-05-31 13:40 ` [LTP] [PATCH v3] min_free_kbytes: Handle transient memory drops in check_monitor Wei Gao via ltp
2026-06-01  6:42   ` [LTP] " linuxtestproject.agent
2026-06-02  1:00   ` [LTP] [PATCH v4] " Wei Gao via ltp
2026-06-02  4:02     ` [LTP] " linuxtestproject.agent
2026-06-02  7:46       ` Wei Gao via ltp
2026-06-02 16:07         ` Andrea Cervesato via ltp
2026-06-03  3:07           ` Wei Gao via ltp
2026-07-28 12:28             ` Andrea Cervesato via ltp
2026-07-28 13:09               ` Andrea Cervesato via ltp
2026-07-29  4:52                 ` Wei Gao via ltp
2026-07-29  5:37     ` [LTP] [PATCH v5] " Wei Gao via ltp
2026-07-29  5:52       ` [LTP] " linuxtestproject.agent
2026-08-01 10:04         ` Wei Gao via ltp
2026-08-06 10:31       ` Petr Vorel [this message]
2026-08-06 23:13       ` [LTP] [PATCH v6] " Wei Gao via ltp
2026-08-07  0:01         ` [LTP] " linuxtestproject.agent
2026-08-11  8:39           ` Andrea Cervesato via ltp
2026-08-11  8:39         ` [LTP] [PATCH v6] " Andrea Cervesato via ltp
2026-08-11  8:41         ` Andrea Cervesato 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=20260806103146.GA838915@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=wegao@suse.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox