<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 Wed, Jan 27, 2021 at 5:23 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>
> > I sent to you the case swapping01 solving this(via FILE_LINES_SCANF)<br>
> > already, feel free to take an reference:<br>
> ><br>
> > <a href="https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/mem/swapping/swapping01.c#L85" rel="noreferrer" target="_blank">https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/mem/swapping/swapping01.c#L85</a><br>
> ><br>
> <br>
> Or, maybe we can extract this process into a function and put it in<br>
> tst_memutils.h, to convinently reuse by other testcases too?<br>
> <br>
> void tst_get_MemAvailable(void);<br>
<br>
Please do not use CamelCase.<br></blockquote><div> </div><div><span class="gmail_default" style="font-size:small">+1 </span></div><div><span class="gmail_default" style="font-size:small">Sorry, I just pasted the name by the editor, and YES, we should avoid that.</span></div><div><span class="gmail_default" style="font-size:small"></span> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
It should be tst_get_mem_available(void) and it should also return<br>
unsigned long.<br></blockquote><div> </div><div><span class="gmail_default" style="font-size:small">Absolutely right.</span></div><div class="gmail_default" style="font-size:small"><span class="gmail_default"></span><div dir="ltr"><div class="gmail_default"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><a href="mailto:liuxp11@chinatelecom.cn" target="_blank">liuxp11@chinatelecom.cn</a> <<a href="mailto:liuxp11@chinatelecom.cn" target="_blank">liuxp11@chinatelecom.cn</a>> wrote:<br></div><div dir="ltr" class="gmail_attr"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>In this testcase,we first check <span style="line-height:1.5;background-color:transparent">MemAvailable. If </span><span style="line-height:1.5;background-color:transparent">MemAvailable doesn't exist,then use </span><span style="line-height:1.5;background-color:transparent">info.freeram.</span></div><div>Maybe not other cases need do these.</div></blockquote><div> </div><div>Yes, but we also could make use of tst_get_mem_available() here because,</div><div>in the patch, you're trying to avoid that (MemFree > MemAvailable) situation.</div><div>If the fix is correct, we just need to get both and choose the smaller one</div><div>to use, isn't it?</div><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"><blockquote style="margin-top:0px;margin-bottom:0px;margin-left:0.5em;margin-right:inherit"><div class="gmail_quote"><div dir="ltr" class="gmail_attr"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Have a question about using macro <span style="line-height:19.5px;background-color:transparent">SAFE_READ_MEMINFO get </span><span style="line-height:1.5;background-color:transparent">MemAvailable value,</span></div><div>Some old kernels maybe not privode "<span style="line-height:1.5;background-color:transparent">MemAvailable</span><span style="line-height:1.5;background-color:transparent">" field, which will broken.</span></div></blockquote></div></blockquote></blockquote><div><br></div><div>The most different of SAFE_* macro is that will exit with TBROK if not</div><div>get it expected. As Cyril proposes another one FILE_LINES_SCANF</div><div>has no such concern.</div></div></div></div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>