<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Richard, </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">This one looks good to me.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 16, 2020 at 6:52 PM Richard Palethorpe <<a href="mailto:rpalethorpe@suse.com">rpalethorpe@suse.com</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">These may be missing and we only access them for printing diagnostic<br>
info.<br>
<br>
Signed-off-by: Richard Palethorpe <<a href="mailto:rpalethorpe@suse.com" target="_blank">rpalethorpe@suse.com</a>><br></blockquote><div><span class="gmail_default" style="font-size:small">Reviewed-by: Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>></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">
---<br>
testcases/kernel/syscalls/madvise/madvise06.c | 22 ++++++++++++-------<br>
1 file changed, 14 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c<br>
index 2ba2bac6f..dc515d528 100644<br>
--- a/testcases/kernel/syscalls/madvise/madvise06.c<br>
+++ b/testcases/kernel/syscalls/madvise/madvise06.c<br>
@@ -64,14 +64,16 @@ static void check_path(const char *path)<br>
}<br>
<br>
#define READ_CGMEM(item) \<br>
- ({long tst_rval; \<br>
- SAFE_FILE_LINES_SCANF(MNT_NAME"/"GROUP_NAME"/memory."item, \<br>
- "%ld", \<br>
- &tst_rval); \<br>
+ ({long tst_rval = 0; \<br>
+ const char *cgpath = MNT_NAME"/"GROUP_NAME"/memory."item; \<br>
+ if (!access(cgpath, R_OK)) \<br>
+ SAFE_FILE_LINES_SCANF(cgpath, "%ld", &tst_rval); \<br>
tst_rval;})<br>
<br>
static void meminfo_diag(const char *point)<br>
{<br>
+ long rval;<br>
+<br>
FILE_PRINTF("/proc/sys/vm/stat_refresh", "1");<br>
tst_res(TINFO, "%s", point);<br>
tst_res(TINFO, "\tSwap: %ld Kb",<br>
@@ -82,10 +84,14 @@ static void meminfo_diag(const char *point)<br>
SAFE_READ_MEMINFO("Cached:") - init_cached);<br>
tst_res(TINFO, "\tcgmem.usage_in_bytes: %ld Kb",<br>
READ_CGMEM("usage_in_bytes") / 1024);<br>
- tst_res(TINFO, "\tcgmem.memsw.usage_in_bytes: %ld Kb",<br>
- READ_CGMEM("memsw.usage_in_bytes") / 1024);<br>
- tst_res(TINFO, "\tcgmem.kmem.usage_in_bytes: %ld Kb",<br>
- READ_CGMEM("kmem.usage_in_bytes") / 1024);<br>
+<br>
+ rval = READ_CGMEM("memsw.usage_in_bytes") / 1024;<br>
+ if (rval)<br>
+ tst_res(TINFO, "\tcgmem.memsw.usage_in_bytes: %ld Kb", rval);<br>
+<br>
+ rval = READ_CGMEM("kmem.usage_in_bytes") / 1024;<br>
+ if (rval)<br>
+ tst_res(TINFO, "\tcgmem.kmem.usage_in_bytes: %ld Kb", rval);<br>
}<br>
<br>
static void setup(void)<br>
-- <br>
2.29.1<br>
<br>
</blockquote></div><br clear="all"><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>