[LTP] [PATCH v2 2/2] swapping01.c: Reporting /proc/meminfo during test

Wei Gao wegao@suse.com
Thu Dec 14 07:33:11 CET 2023


Get clear overview memory status during test is good for debug, such as
get report before the test and also at the moment of the failure.

Also i move init_meminfo() into do_alloc function since do_alloc will be
called twice during test and we need fresh data. This will be a small
improvement for 1b53999.

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/mem/swapping/swapping01.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index fc225e4a6..114456a19 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -79,11 +79,10 @@ static void test_swapping(void)
 	}
 	SAFE_FCLOSE(file);
 
-	init_meminfo();
-
 	switch (pid = SAFE_FORK()) {
 	case 0:
 		do_alloc(0);
+		tst_print_meminfo();
 		do_alloc(1);
 		exit(0);
 	default:
@@ -108,6 +107,8 @@ static void do_alloc(int allow_raise)
 	long mem_count;
 	void *s;
 
+	init_meminfo();
+
 	if (allow_raise == 1)
 		tst_res(TINFO, "available physical memory: %ld MB",
 				mem_available_init / 1024);
@@ -146,6 +147,7 @@ static void check_swapping(void)
 
 	swapped = SAFE_READ_PROC_STATUS(pid, "VmSwap:");
 	if (swapped > mem_over_max) {
+		tst_print_meminfo();
 		kill(pid, SIGCONT);
 		tst_brk(TFAIL, "heavy swapping detected: "
 				"%ld MB swapped.", swapped / 1024);
-- 
2.35.3



More information about the ltp mailing list