syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail
PATCH 1/1 syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail
Move the runtime checks for minimal amount of memory or swap from the test setup to the tst_test structure.
--- testcases/kernel/syscalls/madvise/madvise06.c | 16 ++-------------- testcases/kernel/syscalls/madvise/madvise09.c | 7 +------ 2 files changed, 3 insertions(+), 20 deletions(-)
testcases/kernel/syscalls/madvise/madvise06.c +2 -14
@@ -95,20 +95,6 @@ static void setup(void)sync ();SAFE_FILE_PRINTF (drop_caches_fname,"3" ); -long long avail_mem =tst_available_mem (); -long long avail_swap =tst_available_swap (); -long long chunk_kb =2 *CHUNK_SZ /1024 ; - -if (avail_mem < chunk_kb) { -tst_brk (TCONF ,"System RAM is too small %llikB (%llikB needed)" , - avail_mem, chunk_kb); - } - -if (avail_swap < chunk_kb) { -tst_brk (TCONF ,"System swap is too small %llikB (%llikB needed)" , - avail_swap, chunk_kb); - } -check_path ("/proc/self/oom_score_adj" );SAFE_FILE_PRINTF ("/proc/self/oom_score_adj" ,"%d" ,-1000 );
@@ -243,6 +229,8 @@ static struct tst_test test = { TST_SR_SKIP_MISSING | TST_SR_TCONF_RO}, {} }, + .min_mem_avail = 2 * CHUNK_SZ / TST_MB, + .min_swap_avail = 2 * CHUNK_SZ / TST_MB, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .tags = (const struct tst_tag []) { {"linux-git" ,"55231e5c898c" },
testcases/kernel/syscalls/madvise/madvise09.c +1 -6
@@ -269,17 +269,11 @@ retry:static void setup (void ) { -long swap_total; -if (SAFE_CG_HAS (tst_cg,"memory.swap.max" )) swap_accounting_enabled =1 ;else tst_res (TINFO ,"Swap accounting is disabled" ); -SAFE_FILE_LINES_SCANF ("/proc/meminfo" ,"SwapTotal: %ld" , &swap_total); -if (swap_total <=0 ) -tst_brk (TCONF ,"MADV_FREE does not work without swap" ); - page_size =getpagesize (); }
@@ -288,5 +282,6 @@ static struct tst_test test = { .test_all = run, .needs_root = 1, .forks_child = 1, + .min_swap_avail = SWAP_LIMIT / TST_MB, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, };
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Cyril,
testcases/kernel/syscalls/madvise/madvise09.c retry:
Quoted 7 lines · Cyril Hrubis
syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail
testcases/kernel/syscalls/madvise/madvise09.c +1
-3-SAFE_FILE_LINES_SCANF ("/proc/meminfo" ,"SwapTotal: %ld" , &swap_total); -if (swap_total <=0 ) -tst_brk (TCONF ,"MADV_FREE does not work without swap" ); + .min_swap_avail = SWAP_LIMIT / TST_MB,
The commit message describes this as moving the existing runtime checks into the tst_test structure, but the madvise09 change is not an equivalent transformation.
The old code checked SwapTotal > 0, i.e. whether any swap is configured at all. The new .min_swap_avail check uses SwapFree and requires at least SWAP_LIMIT / TST_MB = 16 MB of available swap. This tightens the requirement in two ways: it looks at free swap rather than total, and it raises the threshold from "any swap" to 16 MB.
If this is intentional (which seems reasonable since the test does need swap space), could the commit message mention the semantic change for madvise09?
Verdict: Needs revision
---
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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 4 lines · Cyril Hrubis
Move the runtime checks for minimal amount of memory or swap from the test setup to the
tst_teststructure.Signed-off-by Cyril Hrubis <[email protected]>
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 6 lines
Quoted 4 lines
Move the runtime checks for minimal amount of memory or swap from the test setup to the
tst_teststructure.Signed-off-by Cyril Hrubis <[email protected]>Reviewed-by Li Wang <[email protected]>
I've adjusted the commit message (as requested by the ltp-agent) and pushed, thanks for the review.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp