public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 2/3] lib: enable OOM protection for the main process
Date: Fri, 17 Dec 2021 15:49:51 +0100	[thread overview]
Message-ID: <Ybyjj40TuKTkeOW/@yuki> (raw)
In-Reply-To: <20211217113751.359613-2-liwang@redhat.com>

Hi!
> 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);

The fork_testrun() function is called in a loop, it would be a bit
cleaner to put the tst_enable_protection() call to the tst_run_tcases()
instead since we don't have to enable it over and over.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-12-17 14:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 11:37 [LTP] [PATCH v2 1/3] lib: add functions to adjust oom score Li Wang
2021-12-17 11:37 ` [LTP] [PATCH v2 2/3] lib: enable OOM protection for the main process Li Wang
2021-12-17 14:49   ` Cyril Hrubis [this message]
2021-12-17 11:37 ` [LTP] [PATCH v2 3/3] oom: enable OOM protection for mem lib process Li Wang
2021-12-17 14:51   ` Cyril Hrubis
2021-12-20  5:01     ` Li Wang
2021-12-17 14:36 ` [LTP] [PATCH v2 1/3] lib: add functions to adjust oom score Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ybyjj40TuKTkeOW/@yuki \
    --to=chrubis@suse.cz \
    --cc=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox