<div><br></div><div><br><div class="gmail_quote"><div>---------- Forwarded message ---------<br>From: FIXED-TERM Doan Minh Hung (RBVH/ENG22) <<a href="mailto:fixed-term.Hung.DoanMinh@vn.bosch.com">fixed-term.Hung.DoanMinh@vn.bosch.com</a>><br>Date: Thu, 31 May 2018 at 11.10 AM<br>Subject: Fail on memory.usage_in_bytes<br>To: <a href="mailto:minhhung290196@gmail.com">minhhung290196@gmail.com</a> <<a href="mailto:minhhung290196@gmail.com">minhhung290196@gmail.com</a>><br></div><br><br>
<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="m_2876133284042837871WordSection1">
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Hello,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">My name is Hung Doan and I have worked on some LTP tests about Cgroup memory recently. I’m writing this email
to inform an issue from the test case named memcg_usage_in_bytes_test.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">The test case creates a cgroup and checks whether<br>
memory.usage_in_bytes == memory.stat (rss value).<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">The test mostly passes but sometimes it gets fail, here is the log:<u></u><u></u></span></p>
<p class="MsoNormal"><i><span style="font-size:12.0pt;font-family:"Times New Roman",serif">memcg_usage_in_bytes_test 1 TINFO: Starting test 1<br>
memcg_usage_in_bytes_test 1 TINFO: Running memcg_process --mmap-anon -s 4194304<br>
memcg_usage_in_bytes_test 1 TINFO: Warming up pid: 1583<br>
memcg_usage_in_bytes_test 1 TINFO: Process is still here after warm up: 1583<br>
memcg_usage_in_bytes_test 1 TFAIL: memory.usage_in_bytes is 4325376, 4194304 expected</span></i><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Let’s check from a fail case of the test:<u></u><u></u></span></p>
<p class="MsoNormal"><i><span style="font-size:12.0pt;font-family:"Times New Roman",serif">root@mx6q:~# cat /dev/memcg/1/memory.{usage_in_bytes,stat}<br>
4325376<br>
cache 0<br>
rss 4194304<br>
rss_huge 0<br>
mapped_file 0<br>
writeback 0<br>
swap 0<br>
pgpgin 1024<br>
pgpgout 0<br>
pgfault 1024<br>
pgmajfault 0<br>
inactive_anon 0<br>
active_anon 4194304<br>
inactive_file 0<br>
active_file 0<br>
unevictable 0<br>
hierarchical_memory_limit 18446744073709551615<br>
hierarchical_memsw_limit 18446744073709551615<br>
total_cache 0<br>
total_rss 4194304<br>
total_rss_huge 0<br>
total_mapped_file 0<br>
total_writeback 0<br>
total_swap 0<br>
total_pgpgin 1024<br>
total_pgpgout 0<br>
total_pgfault 1024<br>
total_pgmajfault 0<br>
total_inactive_anon 0<br>
total_active_anon 4194304<br>
total_inactive_file 0<br>
total_active_file 0<br>
total_unevictable 0</span></i><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">As you can see, the value of memory.usage_in_bytes (4325376) is bigger than the sum of RSS, CACHE and SWAP (4194304),
which is the value the test case is expecting. The test case can’t correct 100% because RSS + CACHE + SWAP <= usage_in_bytes.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">As I check in a reliable documentation, the memory.usage_in_bytes doesn't show the exact value of memory (and
swap) usage. If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP) value in memory.stat.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">The reason of this is that a cgroup might have some charge associated with it. Even though all tasks have migrated
away from it, file caches can exist as charge, the charge is dropped when the page is reclaimed. However, reclaim only occurs when the memory.limit_in_byte is hit, but the test case doesn’t set this limit so that this limit is very big while testing.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Suggested solution for LTP:<u></u><u></u></span></p>
<ul type="disc">
<li class="MsoNormal">
<span style="font-size:12.0pt;font-family:"Times New Roman",serif">Set the memory.limit_in_bytes and memory.memsw.limit_in_bytes equal to the size of a process created (PAGESIZE*1024) before running the test. At a result, when new process created, the charges
will be reclaimed so that the limit can't be hit. I tried it and fail cases didn't show up anymore.<u></u><u></u></span></li></ul>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Reference: <a href="https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt" target="_blank">https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt</a><u></u><u></u></span></p>
</div>
</div>
</div></div>