[LTP] [PATCH v2 2/3] lib: enable OOM protection for the main process

Li Wang liwang@redhat.com
Fri Dec 17 12:37:49 CET 2021


Here invoke OOM protection in fork_testrun, since it is the key point
to distiguish many process branches. We do protect 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:

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

Signed-off-by: Li Wang <liwang@redhat.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
---

Notes:
    Changes v1->v2:
        * remove the protection for parent process as suggested by Martin

 lib/tst_test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index ce2b8239d..0b370e691 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1441,11 +1441,14 @@ static int fork_testrun(void)
 
 	SAFE_SIGNAL(SIGINT, sigint_handler);
 
+	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