diff mbox series

[v2,2/2] swapon01: create 128MB swapfile

Message ID 20240319100822.3243785-3-liwang@redhat.com
State Changes Requested
Headers show
Series add method to create swapfile by MB size | expand

Commit Message

Li Wang March 19, 2024, 10:08 a.m. UTC
The modification in the setup function changes the swap file
creation approach. Instead of allocating swap space based on
a number of blocks (which potentially could be too small for
the polluted memory swapout, thus causing an OOM), it now uses
a fixed size of 128 units for the swap file creation.

This is likely a conservative figure to prevent the OOM killer
from being triggered due to excessive memory allocation for the
swap file, helping ensure the test runs successfully on systems
with no swap space.

Signed-off-by: Li Wang <liwang@redhat.com>
Reviewed-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/syscalls/swapon/swapon01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Petr Vorel March 20, 2024, 7:32 a.m. UTC | #1
> The modification in the setup function changes the swap file
> creation approach. Instead of allocating swap space based on
> a number of blocks (which potentially could be too small for
> the polluted memory swapout, thus causing an OOM), it now uses
> a fixed size of 128 units for the swap file creation.

Great, thank you.

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

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
index 2e399db61..17fde00bc 100644
--- a/testcases/kernel/syscalls/swapon/swapon01.c
+++ b/testcases/kernel/syscalls/swapon/swapon01.c
@@ -38,7 +38,7 @@  static void verify_swapon(void)
 static void setup(void)
 {
 	is_swap_supported(SWAP_FILE);
-	MAKE_SWAPFILE_BLKS(SWAP_FILE, 10, 0);
+	MAKE_SWAPFILE_SIZE(SWAP_FILE, 128, 0);
 
 	SAFE_CG_PRINTF(tst_cg, "cgroup.procs", "%d", getpid());
 	SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM);