qemurunner: Try to ensure mmap'd libs are paged in

We've seeing issues where IO load appears to cause strange failures due to timeouts
within qemu. One theory for these is that it is is hitting hard page faults
at in-opportune moments which cause timing problems within the VM.

This patch is a bit of a hack which tries to ensure the data is paged in
at a point when we know we can take the time delays (waiting for the QMP
start signal). Whilst this isn't ideal, it does seem to improve things on
the autobuilder and shouldn't harm anything.

The code figures out which files to read my looking at the mmap'd files
the process has open from /proc. On Centos7 systems these files are not
user readable, if that is the case we just skip them.

(From OE-Core rev: e77844314d09ceff9c22338d366519928f4f7284)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2021-05-26 14:03:55 +01:00
parent 576ddf658d
commit 37be8268f9

View File

@ -342,7 +342,24 @@ class QemuRunner:
finally:
os.chdir(origpath)
# Release the qemu porcess to continue running
# We worry that mmap'd libraries may cause page faults which hang the qemu VM for periods
# causing failures. Before we "start" qemu, read through it's mapped files to try and
# ensure we don't hit page faults later
mapdir = "/proc/" + str(self.qemupid) + "/map_files/"
try:
for f in os.listdir(mapdir):
linktarget = os.readlink(os.path.join(mapdir, f))
if not linktarget.startswith("/") or linktarget.startswith("/dev") or "deleted" in linktarget:
continue
with open(linktarget, "rb") as readf:
data = True
while data:
data = readf.read(4096)
# Centos7 doesn't allow us to read /map_files/
except PermissionError:
pass
# Release the qemu process to continue running
self.run_monitor('cont')
# We are alive: qemu is running