diff mbox series

[v3,2/3] lib: enable OOM protection for ltp lib process

Message ID 20211220095416.583323-2-liwang@redhat.com
State Changes Requested
Headers show
Series [v3,1/3] lib: add functions to adjust oom score | expand

Commit Message

Li Wang Dec. 20, 2021, 9:54 a.m. UTC
We do protect ltp-lib ($PID) process from killing by OOM Killer,
hope this can help to get the completed correct report for all of
LTP tests.

This achieve by invoking tst_enable_oom_protection in tst_run_tcases,
at the same time, we purposely disabling the protection for children
in fork_testrun, to avoid the oom score inherit by testcase.

Fundamental principle:

                   ltp test harness --> library process
  (enable protection)   main --> tst_run_tcases --> ... --> fork_testrun
  (disable protection)    testrun --> run_tests --> ... --> testname
                            child_test --> ... --> end

Signed-off-by: Li Wang <liwang@redhat.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
---
 lib/tst_test.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Cyril Hrubis Dec. 20, 2021, 1:26 p.m. UTC | #1
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
diff mbox series

Patch

diff --git a/lib/tst_test.c b/lib/tst_test.c
index ce2b8239d..51f438d06 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1446,6 +1446,7 @@  static int fork_testrun(void)
 		tst_brk(TBROK | TERRNO, "fork()");
 
 	if (!test_pid) {
+		tst_disable_oom_protection(0);
 		SAFE_SIGNAL(SIGALRM, SIG_DFL);
 		SAFE_SIGNAL(SIGUSR1, SIG_DFL);
 		SAFE_SIGNAL(SIGINT, SIG_DFL);
@@ -1523,6 +1524,7 @@  void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
 	tst_test = self;
 
 	do_setup(argc, argv);
+	tst_enable_oom_protection(lib_pid);
 
 	SAFE_SIGNAL(SIGALRM, alarm_handler);
 	SAFE_SIGNAL(SIGUSR1, heartbeat_handler);