<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 Mon, Feb 1, 2021 at 9:45 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz" target="_blank">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>
>  lib/tst_memutils.c | 23 +++++++++++++++++++++++<br>
>  1 file changed, 23 insertions(+)<br>
> <br>
> diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c<br>
> index dd09db490..af2178a9c 100644<br>
> --- a/lib/tst_memutils.c<br>
> +++ b/lib/tst_memutils.c<br>
> @@ -15,6 +15,7 @@<br>
>  <br>
>  void tst_pollute_memory(size_t maxsize, int fillchar)<br>
>  {<br>
> +     unsigned int ori_overcommit_mem, ori_overcommit_rat, new_overcommit_rat;<br>
>       size_t i, map_count = 0, safety = 0, blocksize = BLOCKSIZE;<br>
>       void **map_blocks;<br>
>       struct sysinfo info;<br>
> @@ -40,6 +41,25 @@ void tst_pollute_memory(size_t maxsize, int fillchar)<br>
>       map_count = maxsize / blocksize;<br>
>       map_blocks = SAFE_MALLOC(map_count * sizeof(void *));<br>
>  <br>
> +     /* Only allow to run on systems with less than or equal to 128GB of memory */<br>
> +     if (info.totalram  >= (137438953472 / info.mem_unit)) {<br>
> +             tst_brk(TCONF, "Skip test - totalram (%lukB) is larger than 128GB",<br>
> +                             info.totalram * info.mem_unit / 1024);<br>
> +     }<br>
<br>
This is completely wrong, attempt to dirty memory only increases chances<br>
of reproducing the kernel bug but it's not strictly required.<br>
<br>
It's okay to limit the memory or completely skip the rest of this<br>
function but we must not exit the test. The test is valid even if we do<br>
not dirty any memory, it's just less likely to fail on buggy kernel.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">I thought dirty memory is a strict requirement before, so avoid test</div><div class="gmail_default" style="font-size:small">on a large system.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Ok, I'm fine with removing these lines.</div><br></div><div> </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_FILE_SCANF("/proc/sys/vm/overcommit_memory", "%u", &ori_overcommit_mem);<br>
> +     SAFE_FILE_SCANF("/proc/sys/vm/overcommit_ratio",  "%u", &ori_overcommit_rat);<br>
> +<br>
> +     /* Disable the memory overcommit to prevent test invoking OOM killer */<br>
> +     if (SAFE_READ_MEMINFO("CommitLimit:") >= SAFE_READ_MEMINFO("MemAvailable:")) {<br>
> +             SAFE_FILE_PRINTF("/proc/sys/vm/overcommit_memory", "2");<br>
> +     } else {<br>
> +             new_overcommit_rat = (maxsize / info.mem_unit * 100) / info.totalram;<br>
> +             SAFE_FILE_PRINTF("/proc/sys/vm/overcommit_ratio", "%u", new_overcommit_rat);<br>
> +<br>
> +             SAFE_FILE_PRINTF("/proc/sys/vm/overcommit_memory", "2");<br>
> +     }<br>
<br>
And I do not like this that much either, I would be happier with<br>
attempt to dirty only half of the available memory instead of depending<br>
on specific kernel behavior like this.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">The reason I come this way because I noticed that Xinpeng's system</div><div class="gmail_default" style="font-size:small">has NO swap-space, that's probably the root cause to make 'CommitLimit' </div><div class="gmail_default" style="font-size:small">less than 'MemAvailable'.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Then the system will prefer to use OOM (with overcommit_memory = 0 by default) when allocated-memory reach to the CommitLimit.</div><div dir="ltr"><div class="gmail_default"><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div>[root@test-env-nm05-compute-14e5e72e38 ~]# cat /proc/meminfo</div><div>MemTotal:       526997420 kB</div><div>MemFree:        520224908 kB</div><div><span class="gmail_default"></span>MemAvailable:   519936744 kB</div><div>Buffers:               0 kB</div><div>Cached:          2509036 kB</div><div>SwapCached:            0 kB</div><div><span class="gmail_default">...</span></div><div>SwapTotal:             0 kB</div><div>SwapFree:              0 kB</div><div><span class="gmail_default">...</span></div><div><span class="gmail_default"></span>CommitLimit:    263498708 kB</div><div>Committed_AS:   10263760 kB</div></div></blockquote></div><br></div><div><br></div></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>