Skip to content

Commit

Permalink
Handle case of incomplete blkio cgroup subsystem
Browse files Browse the repository at this point in the history
It seems that in Docker Desktop this subsystem exists
but is incomplete (it misses the file that we need).
Work around that by ignoring the subsystem in this case.

Fixes #985.
  • Loading branch information
PhilippWendler committed Jan 18, 2024
1 parent f599439 commit 41b77d3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions benchexec/cgroupsv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

CGROUP_NAME_PREFIX = "benchmark_"

BLKIO_BYTES_FILE = "throttle.io_service_bytes"

_PERMISSION_HINT_GROUPS = """
You need to add your account to the following groups: {0}
Remember to logout and login again afterwards to make group changes effective."""
Expand Down Expand Up @@ -90,6 +92,15 @@ def find_my_cgroups(cgroup_paths=None, fallback=True):
and os.path.isdir(fallbackPath)
):
cgroupPath = fallbackPath

if subsystem == CgroupsV1.IO and not os.path.exists(
os.path.join(cgroupPath, f"{CgroupsV1.IO}.{BLKIO_BYTES_FILE}")
):
# At least on Docker Desktop blkio can exist in an incomplete way
# (cf. 985). Instead of ignoring this later we can simply skip the
# whole subsystem because we only need it for this single file.
continue

cgroupsParents[subsystem] = cgroupPath

return cgroupsParents
Expand Down Expand Up @@ -539,10 +550,9 @@ def read_allowed_memory_banks(self):
return util.parse_int_list(self.get_value(self.CPUSET, "mems"))

def read_io_stat(self):
blkio_bytes_file = "throttle.io_service_bytes"
bytes_read = 0
bytes_written = 0
for blkio_line in self.get_file_lines(self.IO, blkio_bytes_file):
for blkio_line in self.get_file_lines(self.IO, BLKIO_BYTES_FILE):
try:
dev_no, io_type, bytes_amount = blkio_line.split(" ")
if io_type == "Read":
Expand Down

0 comments on commit 41b77d3

Please sign in to comment.