* [LTP] [PATCH 1/2] mem/min_free_kbytes: fix comment typo and whitespace alignment
@ 2026-07-10 9:14 Sachin Sant
2026-07-10 9:14 ` [LTP] [PATCH v3 2/2] mem/min_free_kbytes: refactor to use SAFE_FORK and simplify tune logic Sachin Sant
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sachin Sant @ 2026-07-10 9:14 UTC (permalink / raw)
To: ltp
Fix the typo '%2 MemTotal' -> '2% MemTotal' in the file header comment.
Remove spurious leading spaces from continuation lines in tst_res()
calls and remove unnecessary braces around a single-statement if body,
bringing the file in line with LTP coding style.
Signed-off-by: Sachin Sant <sachinp@linux.ibm.com>
---
testcases/kernel/mem/tunable/min_free_kbytes.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/mem/tunable/min_free_kbytes.c b/testcases/kernel/mem/tunable/min_free_kbytes.c
index bdc9126c2..b1d00e453 100644
--- a/testcases/kernel/mem/tunable/min_free_kbytes.c
+++ b/testcases/kernel/mem/tunable/min_free_kbytes.c
@@ -17,7 +17,7 @@
*
* 1. default min_free_kbytes with all ``overcommit_memory`` policy
* 2. 2x default value with all ``overcommit_memory`` policy
- * 3. 5% of MemFree or %2 MemTotal with all ``overcommit_memory`` policy
+ * 3. 5% of MemFree or 2% MemTotal with all ``overcommit_memory`` policy
*
* [References]
*
@@ -114,7 +114,7 @@ static void test_tune(unsigned long overcommit_policy)
if (overcommit_policy == 2) {
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
tst_res(TFAIL, "child unexpectedly failed: %s",
- tst_strstatus(status));
+ tst_strstatus(status));
} else if (overcommit_policy == 1) {
if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGKILL)
#ifdef TST_ABI32
@@ -122,20 +122,19 @@ static void test_tune(unsigned long overcommit_policy)
if (total_mem < 3145728UL)
#endif
tst_res(TFAIL, "child unexpectedly failed: %s",
- tst_strstatus(status));
+ tst_strstatus(status));
#ifdef TST_ABI32
/* in 32-bit system, a process allocate about 3Gb memory at most */
else
tst_res(TINFO, "Child can't allocate "
- ">3Gb memory in 32bit system");
+ ">3Gb memory in 32bit system");
}
#endif
} else {
if (WIFEXITED(status)) {
- if (WEXITSTATUS(status) != 0) {
+ if (WEXITSTATUS(status) != 0)
tst_res(TFAIL, "child unexpectedly failed: %s",
tst_strstatus(status));
- }
} else if (!WIFSIGNALED(status) ||
WTERMSIG(status) != SIGKILL) {
tst_res(TFAIL, "child unexpectedly failed: %s",
@@ -182,7 +181,7 @@ static void check_monitor(void)
if (memfree < tune) {
tst_res(TINFO, "MemFree is %lu kB, "
- "min_free_kbytes is %lu kB", memfree, tune);
+ "min_free_kbytes is %lu kB", memfree, tune);
tst_res(TFAIL, "MemFree < min_free_kbytes");
}
--
2.39.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread* [LTP] [PATCH v3 2/2] mem/min_free_kbytes: refactor to use SAFE_FORK and simplify tune logic 2026-07-10 9:14 [LTP] [PATCH 1/2] mem/min_free_kbytes: fix comment typo and whitespace alignment Sachin Sant @ 2026-07-10 9:14 ` Sachin Sant 2026-07-13 11:37 ` Andrea Cervesato via ltp 2026-07-10 11:58 ` [LTP] mem/min_free_kbytes: fix comment typo and whitespace alignment linuxtestproject.agent 2026-07-13 11:26 ` [LTP] [PATCH 1/2] " Andrea Cervesato via ltp 2 siblings, 1 reply; 5+ messages in thread From: Sachin Sant @ 2026-07-10 9:14 UTC (permalink / raw) To: ltp The test mixed old bare-fork patterns with the newer LTP API, making it hard to follow and easy to miscount pass/fail results. Extract the tune selection into set_min_free_kbytes(), replace raw fork() with SAFE_FORK() throughout, and drop the manual SAFE_WAITPID on the monitor child — the framework's tst_reap_children() handles it after test_all() returns. Suggested-by: Andrea Cervesato <andrea.cervesato@suse.com> Signed-off-by: Sachin Sant <sachinp@linux.ibm.com> --- v2 -> v3: - Extracted tune selection into a new set_min_free_kbytes() helper, replacing the open-coded if/else chain in test_tune(). - Replaced raw fork() with SAFE_FORK() in test_tune(); pid array collapsed to a single pid_t since each child is waited inline. - Dropped SAFE_WAITPID on the monitor child from min_free_kbytes_test(); tst_reap_children() called by the framework after test_all() returns handles it instead. - Replaced bare MIN() open-code in tune selection with the MIN() macro. - Dropped leftover TPASS/TFAIL from the parent's wait block; result reporting stays solely in check_monitor(). v1 -> v2: - Addressed review comments by moving TPASS/TFAIL reporting into check_monitor() in the child process. --- .../kernel/mem/tunable/min_free_kbytes.c | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/testcases/kernel/mem/tunable/min_free_kbytes.c b/testcases/kernel/mem/tunable/min_free_kbytes.c index b1d00e453..4f991025a 100644 --- a/testcases/kernel/mem/tunable/min_free_kbytes.c +++ b/testcases/kernel/mem/tunable/min_free_kbytes.c @@ -44,9 +44,30 @@ static int eatup_mem(unsigned long overcommit_policy); static void check_monitor(void); static void sighandler(int signo LTP_ATTRIBUTE_UNUSED); +static void set_min_free_kbytes(int i) +{ + unsigned long memfree, memtotal, tune; + + switch (i) { + case 0: + tune = default_tune; + break; + case 1: + tune = 2 * default_tune; + break; + default: + memfree = SAFE_READ_MEMINFO("MemFree:"); + memtotal = SAFE_READ_MEMINFO("MemTotal:"); + tune = MIN(memfree / 20, memtotal / 50); + break; + } + + TST_SYS_CONF_LONG_SET(PATH_VM_MIN_FREE_KBYTES, tune, 1); +} + static void min_free_kbytes_test(void) { - int pid, status; + pid_t pid; struct sigaction sa; sa.sa_handler = sighandler; @@ -56,7 +77,6 @@ static void min_free_kbytes_test(void) pid = SAFE_FORK(); if (pid == 0) { - /* startup the check monitor */ check_monitor(); exit(0); } @@ -66,50 +86,26 @@ static void min_free_kbytes_test(void) test_tune(1); SAFE_KILL(pid, SIGUSR1); - SAFE_WAITPID(pid, &status, WUNTRACED | WCONTINUED); - - if (WIFEXITED(status) && WEXITSTATUS(status) != 0) - tst_res(TFAIL, "check_monitor child exit with status: %s", - tst_strstatus(status)); - - tst_res(TPASS, "min_free_kbytes test pass"); } static void test_tune(unsigned long overcommit_policy) { int status; - int pid[3]; - int ret, i; - unsigned long tune, memfree, memtotal; + pid_t pid; + int i; TST_SYS_CONF_LONG_SET(PATH_VM_OVERCOMMIT_MEMORY, overcommit_policy, 1); for (i = 0; i < 3; i++) { - if (i == 0) - TST_SYS_CONF_LONG_SET(PATH_VM_MIN_FREE_KBYTES, default_tune, 1); - else if (i == 1) { - TST_SYS_CONF_LONG_SET(PATH_VM_MIN_FREE_KBYTES, 2 * default_tune, 1); - } else { - memfree = SAFE_READ_MEMINFO("MemFree:"); - memtotal = SAFE_READ_MEMINFO("MemTotal:"); - tune = memfree / 20; - if (tune > (memtotal / 50)) - tune = memtotal / 50; - - TST_SYS_CONF_LONG_SET(PATH_VM_MIN_FREE_KBYTES, tune, 1); - } + set_min_free_kbytes(i); fflush(stdout); - switch (pid[i] = fork()) { - case -1: - tst_brk(TBROK | TERRNO, "fork"); - break; - case 0: - ret = eatup_mem(overcommit_policy); - exit(ret); + pid = SAFE_FORK(); + if (pid == 0) { + exit(eatup_mem(overcommit_policy)); } - SAFE_WAITPID(pid[i], &status, WUNTRACED | WCONTINUED); + SAFE_WAITPID(pid, &status, WUNTRACED | WCONTINUED); if (overcommit_policy == 2) { if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) @@ -172,6 +168,7 @@ static int eatup_mem(unsigned long overcommit_policy) static void check_monitor(void) { + int violated = 0; unsigned long tune; unsigned long memfree; @@ -183,10 +180,14 @@ static void check_monitor(void) tst_res(TINFO, "MemFree is %lu kB, " "min_free_kbytes is %lu kB", memfree, tune); tst_res(TFAIL, "MemFree < min_free_kbytes"); + violated = 1; } sleep(2); } + + if (!violated) + tst_res(TPASS, "min_free_kbytes test pass"); } static void sighandler(int signo LTP_ATTRIBUTE_UNUSED) -- 2.39.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH v3 2/2] mem/min_free_kbytes: refactor to use SAFE_FORK and simplify tune logic 2026-07-10 9:14 ` [LTP] [PATCH v3 2/2] mem/min_free_kbytes: refactor to use SAFE_FORK and simplify tune logic Sachin Sant @ 2026-07-13 11:37 ` Andrea Cervesato via ltp 0 siblings, 0 replies; 5+ messages in thread From: Andrea Cervesato via ltp @ 2026-07-13 11:37 UTC (permalink / raw) To: Sachin Sant; +Cc: ltp LGTM, but next time please follow the patch-set convention of having [PATCH <version> <number>/<total>] <subject> The v3 1/2 is missing the right version tag and it's not linked to the second patch in this way. Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com> -- Andrea Cervesato SUSE QE Automation Engineer Linux andrea.cervesato@suse.com -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] mem/min_free_kbytes: fix comment typo and whitespace alignment 2026-07-10 9:14 [LTP] [PATCH 1/2] mem/min_free_kbytes: fix comment typo and whitespace alignment Sachin Sant 2026-07-10 9:14 ` [LTP] [PATCH v3 2/2] mem/min_free_kbytes: refactor to use SAFE_FORK and simplify tune logic Sachin Sant @ 2026-07-10 11:58 ` linuxtestproject.agent 2026-07-13 11:26 ` [LTP] [PATCH 1/2] " Andrea Cervesato via ltp 2 siblings, 0 replies; 5+ messages in thread From: linuxtestproject.agent @ 2026-07-10 11:58 UTC (permalink / raw) To: Sachin Sant; +Cc: ltp Hi Sachin, On Fri, 10 Jul 2026, Sachin Sant wrote: > mem/min_free_kbytes: fix comment typo and whitespace alignment Verdict - Reviewed --- Note: The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions. Regards, LTP AI Reviewer -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 1/2] mem/min_free_kbytes: fix comment typo and whitespace alignment 2026-07-10 9:14 [LTP] [PATCH 1/2] mem/min_free_kbytes: fix comment typo and whitespace alignment Sachin Sant 2026-07-10 9:14 ` [LTP] [PATCH v3 2/2] mem/min_free_kbytes: refactor to use SAFE_FORK and simplify tune logic Sachin Sant 2026-07-10 11:58 ` [LTP] mem/min_free_kbytes: fix comment typo and whitespace alignment linuxtestproject.agent @ 2026-07-13 11:26 ` Andrea Cervesato via ltp 2 siblings, 0 replies; 5+ messages in thread From: Andrea Cervesato via ltp @ 2026-07-13 11:26 UTC (permalink / raw) To: Sachin Sant; +Cc: ltp I guess this is needed to fix `make check` issues. Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com> -- Andrea Cervesato SUSE QE Automation Engineer Linux andrea.cervesato@suse.com -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-13 11:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-10 9:14 [LTP] [PATCH 1/2] mem/min_free_kbytes: fix comment typo and whitespace alignment Sachin Sant 2026-07-10 9:14 ` [LTP] [PATCH v3 2/2] mem/min_free_kbytes: refactor to use SAFE_FORK and simplify tune logic Sachin Sant 2026-07-13 11:37 ` Andrea Cervesato via ltp 2026-07-10 11:58 ` [LTP] mem/min_free_kbytes: fix comment typo and whitespace alignment linuxtestproject.agent 2026-07-13 11:26 ` [LTP] [PATCH 1/2] " Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox