[LTP] [PATCH 2/2] madvise06: Move oom_score_adj initialization to struct tst_path_val

Li Wang liwang@redhat.com
Mon Mar 14 04:37:15 CET 2022


On Fri, Mar 11, 2022 at 8:35 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > Is it ok to define it earlier? i.e. before calling sync() ?
> >
> >  testcases/kernel/syscalls/madvise/madvise06.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/madvise/madvise06.c
> b/testcases/kernel/syscalls/madvise/madvise06.c
> > index b21f2cc7de..15171442cb 100644
> > --- a/testcases/kernel/syscalls/madvise/madvise06.c
> > +++ b/testcases/kernel/syscalls/madvise/madvise06.c
> > @@ -55,6 +55,7 @@
> >  #define PASS_THRESHOLD (CHUNK_SZ / 4)
> >  #define PASS_THRESHOLD_KB (PASS_THRESHOLD / 1024)
> >  #define SWAPPINESS "60"
> > +#define OOM_SCORE_ADJ "-1000"
> >
> >  static const char drop_caches_fname[] = "/proc/sys/vm/drop_caches";
> >  static int pg_sz, stat_refresh_sup;
> > @@ -116,9 +117,6 @@ static void setup(void)
> >                       2 * CHUNK_SZ);
> >       }
> >
> > -     check_path("/proc/self/oom_score_adj");
> > -     SAFE_FILE_PRINTF("/proc/self/oom_score_adj", "%d", -1000);
>

Maybe use tst_enable_oom_protection(0) here is better.


> -
> >       SAFE_CG_PRINTF(tst_cg, "memory.max", "%ld", MEM_LIMIT);
> >       if (SAFE_CG_HAS(tst_cg, "memory.swap.max"))
> >               SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%ld",
> MEMSW_LIMIT);
> > @@ -231,6 +229,7 @@ static struct tst_test test = {
> >       .needs_root = 1,
> >       .save_restore = (const struct tst_path_val const[]) {
> >               {"?/proc/sys/vm/swappiness", SWAPPINESS},
> > +             {"/proc/self/oom_score_adj", OOM_SCORE_ADJ},
>
> I do not think that this is even correct, after this change the file is
> being written to by the test library and the 'self' points to a
> different process as far as I can tell.
>

That's right. But from the code logic, seems it try to protect the
madvise06 from being killed by OOM. So enabling the oom
protection in the test library also has the same effect because
children(madvise06) will inherit the score.

However, I agree that we shouldn't add the oom_score_adj"
knob in .svae_restore since that might bring more confusion
to users.


-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20220314/51d66ee8/attachment-0001.htm>


More information about the ltp mailing list