[LTP] [PATCH v2 3/3] oom: enable OOM protection for mem lib process

Cyril Hrubis chrubis@suse.cz
Fri Dec 17 15:51:18 CET 2021


Hi!
> Just simply invoke oom protection on mem library to make
> it can collect full state of children.
> 
> Signed-off-by: Li Wang <liwang@redhat.com>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/kernel/mem/lib/mem.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
> index ac890491c..566e29055 100644
> --- a/testcases/kernel/mem/lib/mem.c
> +++ b/testcases/kernel/mem/lib/mem.c
> @@ -129,8 +129,11 @@ void oom(int testcase, int lite, int retcode, int allow_sigkill)
>  	pid_t pid;
>  	int status, threads;
>  
> +	tst_enable_oom_protection(getpid());
> +
>  	switch (pid = SAFE_FORK()) {
>  	case 0:
> +		tst_cancel_oom_protection(getpid());
>  		threads = MAX(1, tst_ncpus() - 1);
>  		child_alloc(testcase, lite, threads);
>  	default:

Looking at the code we have, we always pass getpid(). We may as well
change the library to use /proc/self/oom_score_adj if 0 is passed
instead of the pid.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list