未验证 提交 7f1fd646 编写于 作者: L Lukáš Doktor

Merging pull request 1498

Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>

* https://github.com/autotest/tp-qemu:
  cgroup: Allow 5% of extra pages when RSS only limit
  cgroup: Avoid counting RssShmem
......@@ -1778,6 +1778,19 @@ def run(test, params, env):
else:
return ("Freezer works fine")
def _get_rss(status):
"""
Get VmRSS without RssShmem from /proc/$PID/status output
The RssShmem can be accounted to different process making the
overall sum of VmRSS greater than set in limit_in_bytes
"""
rss = int(re.search(r'VmRSS:[\t ]*(\d+) kB', status)
.group(1))
shmem = int(re.search(r'RssShmem:[\t ]*(\d+) kB', status)
.group(1))
return rss - shmem
@error_context.context_aware
def memory_limit(memsw=False):
"""
......@@ -1853,7 +1866,7 @@ def run(test, params, env):
# VM already eat-up more than allowed by this cgroup
fstats = open('/proc/%s/status' % vm.get_pid(), 'r')
rss = int(re.search(r'VmRSS:[\t ]*(\d+) kB', fstats.read()).group(1))
rss = _get_rss(fstats.read())
if rss > mem_limit:
raise exceptions.TestFail("Init failed to move VM into cgroup, VmRss"
"=%s, expected=%s" % (rss, mem_limit))
......@@ -1880,8 +1893,7 @@ def run(test, params, env):
try:
fstats.seek(0)
status = fstats.read()
rss = int(re.search(r'VmRSS:[\t ]*(\d+) kB', status)
.group(1))
rss = _get_rss(status)
max_rss = max(rss, max_rss)
swap = int(re.search(r'VmSwap:[\t ]*(\d+) kB', status)
.group(1))
......@@ -1932,9 +1944,10 @@ def run(test, params, env):
logging.info(out)
else: # only RSS limit
exit_nr = session.cmd_output("echo $?")[:-1]
if max_rss > mem_limit:
err = ("The limit was broken: max_rss=%s, limit=%s" %
(max_rss, mem_limit))
if max_rss > mem_limit * 1.05:
# Allow 5% pages to be in-progress of swapping out
err = ("The limit was broken: max_rss=%s, limit=%s (+5%%)"
% (max_rss, mem_limit))
elif exit_nr != '0':
err = ("dd command failed(%s) output: %s" % (exit_nr, out))
elif (max_rssswap) < mem_limit:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册