Message ID | 20211217113751.359613-3-liwang@redhat.com |
---|---|
State | Superseded |
Headers | show |
Series | [v2,1/3] lib: add functions to adjust oom score | expand |
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.
On Fri, Dec 17, 2021 at 10:49 PM Cyril Hrubis <chrubis@suse.cz> wrote: > > > + 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. > Yes, agree with all suggestions (include comments in 1/3 2/3).
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: