testsAndMisc/python_pkg/swap_bench/tests/conftest.py
Krzysztof kuhy Rudnicki c76ce53e90
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Gate swap_bench host runs on desktop stall
The C6 live check failed: global memory PSI full avg10 rose during host
runs. Global PSI full counts moments when every busy task is stalled,
which the bench scope causes by itself, so no global figure measures the
desktop. A host run now fails (exit 3, row kept) when the login session
scopes stall over 1 s, and records outside_pswpout: zram's pool is not
charged to the scope, so global reclaim swaps other processes too
(153k-224k pages per run vs 111k idle). DOCS corrected: the scope does
not keep the desktop out of swap, and a nonzero zram disk_wb_pages on
the host is background (20k pages over an idle 28 s).

Bug-class-check: linux_configuration/fixes/lib/tests/test_swap_bench.sh (pressed-desktop case)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 13:24:52 +01:00

64 lines
2.0 KiB
Python

"""Fixture trees of the raw files swap_bench.sh copies for one run."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from pathlib import Path
_PSI = (
"some avg10=0.00 avg60=0.00 avg300=0.00 total={some}\n"
"full avg10={f10} avg60=0.00 avg300=0.00 total={full}\n"
)
def _write(root: Path, name: str, text: str) -> None:
path = root / name
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(text)
@pytest.fixture
def run_dir(tmp_path: Path) -> Path:
"""A zram run: 3 GiB in, 1 GiB compressed, 800 pages to disk."""
gib = 1 << 30
_write(
tmp_path,
"workload.txt",
"pages=256\nfill_crc=11\ntouch_crc=22\nmajflt=500\nseconds=12.5\n",
)
_write(tmp_path, "before/vmstat", "pswpout 1000\nzswpwb 5\npgmajfault 9\n")
_write(tmp_path, "after/vmstat", "pswpout 9000\nzswpwb 7\npgmajfault 9\n")
_write(tmp_path, "before/zram_stat", "1 0 0 0 1 0 8000 0 0 0 0\n")
_write(tmp_path, "after/zram_stat", "1 0 0 0 1 0 65600 0 0 0 0\n")
_write(tmp_path, "before/mm_stat", f"{gib} {gib // 2} 0 0\n")
_write(tmp_path, "peak/mm_stat", f"{4 * gib} {gib + gib // 2} 0 0\n")
_write(tmp_path, "before/pressure", _PSI.format(some=1000, full=500, f10="0.10"))
_write(
tmp_path, "after/pressure", _PSI.format(some=301000, full=200500, f10="0.20")
)
_write(
tmp_path,
"before/desktop_pressure",
2 * _PSI.format(some=0, full=1000, f10="0.00"),
)
_write(
tmp_path,
"after/desktop_pressure",
2 * _PSI.format(some=0, full=4000, f10="0.00"),
)
_write(tmp_path, "cg_pressure", _PSI.format(some=40000, full=30000, f10="1.00"))
_write(
tmp_path, "cg_memory.stat", "zswpwb 3\nzswap 100\nzswapped 400\npswpout 7000\n"
)
_write(tmp_path, "peak/memory.stat", "zswap 1000\nzswapped 3500\n")
_write(
tmp_path,
"peak/meminfo",
"MemTotal: 100 kB\nZswap: 200 kB\nZswapped: 500 kB\n",
)
return tmp_path