<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 11, 2022 at 8:35 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
> Signed-off-by: Petr Vorel <<a href="mailto:pvorel@suse.cz" target="_blank">pvorel@suse.cz</a>><br>
> ---<br>
> Is it ok to define it earlier? i.e. before calling sync() ?<br>
> <br>
> testcases/kernel/syscalls/madvise/madvise06.c | 5 ++---<br>
> 1 file changed, 2 insertions(+), 3 deletions(-)<br>
> <br>
> diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c<br>
> index b21f2cc7de..15171442cb 100644<br>
> --- a/testcases/kernel/syscalls/madvise/madvise06.c<br>
> +++ b/testcases/kernel/syscalls/madvise/madvise06.c<br>
> @@ -55,6 +55,7 @@<br>
> #define PASS_THRESHOLD (CHUNK_SZ / 4)<br>
> #define PASS_THRESHOLD_KB (PASS_THRESHOLD / 1024)<br>
> #define SWAPPINESS "60"<br>
> +#define OOM_SCORE_ADJ "-1000"<br>
> <br>
> static const char drop_caches_fname[] = "/proc/sys/vm/drop_caches";<br>
> static int pg_sz, stat_refresh_sup;<br>
> @@ -116,9 +117,6 @@ static void setup(void)<br>
> 2 * CHUNK_SZ);<br>
> }<br>
> <br>
> - check_path("/proc/self/oom_score_adj");<br>
> - SAFE_FILE_PRINTF("/proc/self/oom_score_adj", "%d", -1000);<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Maybe use tst_enable_oom_protection(0) here is better.</div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> -<br>
> SAFE_CG_PRINTF(tst_cg, "memory.max", "%ld", MEM_LIMIT);<br>
> if (SAFE_CG_HAS(tst_cg, "memory.swap.max"))<br>
> SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%ld", MEMSW_LIMIT);<br>
> @@ -231,6 +229,7 @@ static struct tst_test test = {<br>
> .needs_root = 1,<br>
> .save_restore = (const struct tst_path_val const[]) {<br>
> {"?/proc/sys/vm/swappiness", SWAPPINESS},<br>
> + {"/proc/self/<span class="gmail_default" style="font-size:small"></span>oom_score_adj", OOM_SCORE_ADJ},<br>
<br>
I do not think that this is even correct, after this change the file is<br>
being written to by the test library and the 'self' points to a<br>
different process as far as I can tell.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">That's right. But from the code logic, seems it try to protect the</div><div class="gmail_default" style="font-size:small">madvise06 from being killed by OOM. So enabling the oom</div><div class="gmail_default" style="font-size:small">protection in the test library also has the same effect because</div><div class="gmail_default" style="font-size:small">children(madvise06) will inherit the score.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">However, I agree that we shouldn't add the <span class="gmail_default"></span>oom_score_adj"</div><div class="gmail_default" style="font-size:small">knob in .svae_restore since that might bring more confusion</div><div class="gmail_default" style="font-size:small">to users. </div></div><div><br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>