From 80e0af728d7e554310ad8ed6be2583b1cf73fefa Mon Sep 17 00:00:00 2001 From: Philipp Wendler Date: Mon, 26 Aug 2024 13:26:01 +0200 Subject: [PATCH 1/8] fix typo in CI job name --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 52da6fded..adc1d7a5a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,7 +60,7 @@ stages: coverage_format: cobertura path: coverage.xml -tests:cgroups1:python-3.8: +tests:cgroupsv1:python-3.8: <<: *tests-cgroupsv1 variables: PYTHON_VERSION: '3.8' From af027a1a8661003b90a84ed5b4aea1b9b2addd0d Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 28 Aug 2024 07:16:24 +0200 Subject: [PATCH 2/8] Fix bug from 1049c395d: containerexec crashes since then --- benchexec/cgroups.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchexec/cgroups.py b/benchexec/cgroups.py index 971fdf9ed..3b16e23e5 100644 --- a/benchexec/cgroups.py +++ b/benchexec/cgroups.py @@ -167,7 +167,7 @@ def handle_errors(self, critical_cgroups): pass @abstractmethod - def create_fresh_child_cgroup(self, subsystems): + def create_fresh_child_cgroup(self, subsystems, prefix=None): pass @abstractmethod @@ -356,7 +356,7 @@ def add_task(self, pid): def kill_all_tasks(self): pass - def create_fresh_child_cgroup(self, subsystems): + def create_fresh_child_cgroup(self, subsystems, prefix=None): return self def create_fresh_child_cgroup_for_delegation(self): From ddb57f7ffc145642d501f771d9910949bf8d05a1 Mon Sep 17 00:00:00 2001 From: Philipp Wendler Date: Fri, 30 Aug 2024 10:57:13 +0200 Subject: [PATCH 3/8] Add some comments and documentations about kernel versions and features --- benchexec/cgroupsv2.py | 8 +++++++- doc/INSTALL.md | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/benchexec/cgroupsv2.py b/benchexec/cgroupsv2.py index 4f2f337ce..70107b8cb 100644 --- a/benchexec/cgroupsv2.py +++ b/benchexec/cgroupsv2.py @@ -118,7 +118,7 @@ def initialize(): else: # No usable cgroup. We might still be able to continue if we actually # do not require cgroups for benchmarking. So we do not fail here - # but return an instance that will on produce an error later. + # but return an instance that will only produce an error later. return CgroupsV2({}) # Now we are the only process in this cgroup. In order to make it usable for @@ -562,6 +562,12 @@ def raise_error(e): # On cgroupsv2, frozen processes can still be killed, so this is all we need to # do. util.write_file("1", self.path, "cgroup.freeze", force=True) + # According to Lennart Poettering, this is not enough: + # https://lwn.net/Articles/855312/ + # But we never encountered any problems, and new kernels have cgroup.kill + # anyway (since 5.14). So it is probably not worth to fix it and instead + # we just eventually require kernel 5.14 for cgroupsv2 + # (before 5.19 memory measurements are missing as well). keep_child = self._delegated_to.path if self._delegated_to else None for child_cgroup in recursive_child_cgroups(self.path): kill_all_tasks_in_cgroup(child_cgroup) diff --git a/doc/INSTALL.md b/doc/INSTALL.md index fe1f1788d..401b13551 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -152,8 +152,10 @@ For other distributions, please read the following detailed requirements. Except on Ubuntu, the full feature set of BenchExec is only usable on **Linux 5.11 or newer**, so we suggest at least this kernel version. +And if your system is using cgroups v2 (cf. below), +the full feature set requires **Linux 5.19 or newer**. -On older kernels, you need to avoid using the overlay filesystem (cf. below), +On kernels than 5.11, you need to avoid using the overlay filesystem (cf. below), all other features are supported. However, we strongly recommend to use at least **Linux 4.14 or newer** because it reduces the overhead of BenchExec's memory measurements and limits. @@ -213,6 +215,9 @@ echo 'GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} systemd.unified_ sudo update-grub ``` +Furthermore, with cgroups v2 Linux 5.19 or newer is required +in order to have memory measurements. + ### Setting up Cgroups v2 on Machines with systemd This applies for example for Ubuntu 21.10 and newer, From 48564d78327bfe93cff74093281c83a5688e6c9e Mon Sep 17 00:00:00 2001 From: Philipp Wendler Date: Fri, 30 Aug 2024 11:09:14 +0200 Subject: [PATCH 4/8] Declare minimum Python version as dependency in package metadata We should have done that a long time ago, but were not aware that this is possible. --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index be3291295..0c68b11dd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -61,6 +61,7 @@ license_files = packages = benchexec, benchexec.tablegenerator, benchexec.tools install_requires = PyYAML >= 3.12 +python_requires = >= 3.8 zip_safe = True [options.extras_require] From 44c0a99a95d932d19c74207cd2d2a933478b4975 Mon Sep 17 00:00:00 2001 From: Philipp Wendler Date: Fri, 30 Aug 2024 12:48:43 +0200 Subject: [PATCH 5/8] Cleanup .gitignore For subcomponents we use a separate .gitignore file instead of adding paths to the main file, this is easier to maintain. --- .gitignore | 7 ++----- contrib/vcloud/lib/.gitignore | 9 +++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 contrib/vcloud/lib/.gitignore diff --git a/.gitignore b/.gitignore index eacea18cd..789154b01 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,5 @@ /BenchExec.egg-info /.coverage* /coverage -/.pytype -.idea -node_modules/ -/contrib/vcloud/lib/ivy*.jar -/contrib/vcloud/lib/vcloud-jars +/coverage.xml +/.idea diff --git a/contrib/vcloud/lib/.gitignore b/contrib/vcloud/lib/.gitignore new file mode 100644 index 000000000..66bcbb67f --- /dev/null +++ b/contrib/vcloud/lib/.gitignore @@ -0,0 +1,9 @@ +# This file is part of BenchExec, a framework for reliable benchmarking: +# https://github.com/sosy-lab/benchexec +# +# SPDX-FileCopyrightText: 2007-2024 Dirk Beyer +# +# SPDX-License-Identifier: Apache-2.0 + +/ivy*.jar +/vcloud-jars From 5a9df4f98c7480549cb4a46898431c7f57de20f8 Mon Sep 17 00:00:00 2001 From: Philipp Wendler Date: Fri, 30 Aug 2024 12:57:19 +0200 Subject: [PATCH 6/8] Add .rgignore ignoring some files that we never want to search in This is used by rg (ripgrep). --- benchexec/tablegenerator/react-table/.rgignore | 9 +++++++++ benchexec/tablegenerator/test_integration/.rgignore | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 benchexec/tablegenerator/react-table/.rgignore create mode 100644 benchexec/tablegenerator/test_integration/.rgignore diff --git a/benchexec/tablegenerator/react-table/.rgignore b/benchexec/tablegenerator/react-table/.rgignore new file mode 100644 index 000000000..2761807e9 --- /dev/null +++ b/benchexec/tablegenerator/react-table/.rgignore @@ -0,0 +1,9 @@ +# This file is part of BenchExec, a framework for reliable benchmarking: +# https://github.com/sosy-lab/benchexec +# +# SPDX-FileCopyrightText: 2024 Dirk Beyer +# +# SPDX-License-Identifier: Apache-2.0 + +/build +/src/tests/__snapshots__/ diff --git a/benchexec/tablegenerator/test_integration/.rgignore b/benchexec/tablegenerator/test_integration/.rgignore new file mode 100644 index 000000000..27489f8c5 --- /dev/null +++ b/benchexec/tablegenerator/test_integration/.rgignore @@ -0,0 +1,9 @@ +# This file is part of BenchExec, a framework for reliable benchmarking: +# https://github.com/sosy-lab/benchexec +# +# SPDX-FileCopyrightText: 2024 Dirk Beyer +# +# SPDX-License-Identifier: Apache-2.0 + +/expected +/results From e72cede78abd602748eb6265d7aaa845c2f1618a Mon Sep 17 00:00:00 2001 From: Philipp Wendler Date: Fri, 30 Aug 2024 13:20:16 +0200 Subject: [PATCH 7/8] Fix unclosed file descriptor when reading PSI from cgroupsv2 --- benchexec/cgroupsv2.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/benchexec/cgroupsv2.py b/benchexec/cgroupsv2.py index 70107b8cb..b2b40e168 100644 --- a/benchexec/cgroupsv2.py +++ b/benchexec/cgroupsv2.py @@ -593,12 +593,13 @@ def read_max_mem_usage(self): return None def _read_pressure_stall_information(self, subsystem): - for line in open(self.path / (subsystem + ".pressure")): - if line.startswith("some "): - for item in line.split(" ")[1:]: - k, v = item.split("=") - if k == "total": - return Decimal(v) / 1_000_000 + with open(self.path / (subsystem + ".pressure")) as pressure_file: + for line in pressure_file: + if line.startswith("some "): + for item in line.split(" ")[1:]: + k, v = item.split("=") + if k == "total": + return Decimal(v) / 1_000_000 return None def read_mem_pressure(self): From b3debbe7df4795b308ca5fe5a8eca90d2a5dc69f Mon Sep 17 00:00:00 2001 From: Philipp Wendler Date: Fri, 30 Aug 2024 13:47:57 +0200 Subject: [PATCH 8/8] Enable warnings as errors when executing our test suite --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index acd0770cb..e1ff62eaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,5 +72,11 @@ ignore = [ ] [tool.pytest.ini_options] +filterwarnings = [ + "error", + # TODO cf. https://github.com/sosy-lab/benchexec/issues/1073 + # To make warning visible change "ignore" to "default". + "ignore:subprocess .* is still running:ResourceWarning", +] python_files = ["test_*.py", "test_integration/__init__.py", "test.py"] norecursedirs = ["contrib/p4/docker_files", "build", "benchexec/tablegenerator/react-table"]