diff mbox series

[v3,2/2] swapping01.c: Reporting /proc/meminfo during test

Message ID 20231214071321.9863-3-wegao@suse.com
State Changes Requested
Headers show
Series Add tst_print_meminfo function into swapping01 | expand

Commit Message

Wei Gao Dec. 14, 2023, 7:13 a.m. UTC
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.

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

Comments

Li Wang Dec. 18, 2023, 7:37 a.m. UTC | #1
Hi Wei,

The print of meminfo will help to debug but the negative
is to mess up the test log in LTP.

So, can we achieve an implicit way for debug printing and only
enable it by using additional parameters?

e.g. ./swapping01 -D (--debug)


On Thu, Dec 14, 2023 at 3:14 PM Wei Gao via ltp <ltp@lists.linux.it> wrote:

> 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.
>
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  testcases/kernel/mem/swapping/swapping01.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/testcases/kernel/mem/swapping/swapping01.c
> b/testcases/kernel/mem/swapping/swapping01.c
> index fc225e4a6..f7724e7e1 100644
> --- a/testcases/kernel/mem/swapping/swapping01.c
> +++ b/testcases/kernel/mem/swapping/swapping01.c
> @@ -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:
> @@ -146,6 +148,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
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
diff mbox series

Patch

diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index fc225e4a6..f7724e7e1 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -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:
@@ -146,6 +148,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);