Skip to content

Commit

Permalink
swapping01.c: Reporting /proc/meminfo during test
Browse files Browse the repository at this point in the history
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.

Link: https://lore.kernel.org/ltp/[email protected]/
Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Wei Gao <[email protected]>
  • Loading branch information
coolgw authored and pevik committed Dec 18, 2023
1 parent dddc06b commit ddb29d1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions testcases/kernel/mem/swapping/swapping01.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ static void test_swapping(void)

switch (pid = SAFE_FORK()) {
case 0:
TST_PRINT_MEMINFO();
do_alloc(0);
TST_PRINT_MEMINFO();
do_alloc(1);
exit(0);
default:
Expand Down Expand Up @@ -138,6 +140,7 @@ static void check_swapping(void)
swap_free_now = SAFE_READ_MEMINFO("SwapFree:");
sleep(1);
long diff = labs(swap_free_now - SAFE_READ_MEMINFO("SwapFree:"));

if (diff < 10)
break;

Expand All @@ -146,6 +149,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);
Expand Down

0 comments on commit ddb29d1

Please sign in to comment.