[LTP] [PATCH 2/3] ltp: enable OOM protection for main and test harness process

Li Wang liwang@redhat.com
Thu Dec 16 04:41:24 CET 2021


Here invoke OOM protection in fork_testrun, since it is the key point
to distiguish many process branches. We do protect ltp test harness($PPID)
and main ($PID) process from killing by OOM Killer, hope this can help
to get the completed correct report for all of LTP tests.

Fundamental principle:

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

Note: there might be still argument on doing this protection for test harness,
      because it will affect all common testcases (I mean none oom tests), but
      I slightly think it is safe as there seems no much system load during
      perform them.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 lib/tst_test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index ce2b8239d..f3ae48240 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1441,11 +1441,15 @@ static int fork_testrun(void)
 
 	SAFE_SIGNAL(SIGINT, sigint_handler);
 
+	tst_enable_oom_protection(getppid());
+	tst_enable_oom_protection(getpid());
+
 	test_pid = fork();
 	if (test_pid < 0)
 		tst_brk(TBROK | TERRNO, "fork()");
 
 	if (!test_pid) {
+		tst_cancel_oom_protection(getpid());
 		SAFE_SIGNAL(SIGALRM, SIG_DFL);
 		SAFE_SIGNAL(SIGUSR1, SIG_DFL);
 		SAFE_SIGNAL(SIGINT, SIG_DFL);
-- 
2.31.1



More information about the ltp mailing list