Media-Transport-Library

CPU isolation wrapper

isolate.sh [--] <command...> runs one command at nice −20 inside a cgroup v2 cpuset partition that exists only while the command runs. The NoCtx runner (tests/integration_tests/noctx/run.sh) uses it for the cases in NOCTX_ISOLATE_CASES, and the acceptance rx_timing tests for RxTxApp (cpu_isolation="require"). Background on static and dynamic CPU isolation: doc/isolation.md.

Environment

Variable Set by Values
MTL_ISOLATE caller off (default) runs the command as is; try; require
MTL_ISOLATE_PORTS caller Comma-separated PCI BDFs, the MTL primary port (port P) first
MTL_CPU_ISOLATION wrapper, for the command exclusive or none

If the partition is unavailable, try prints one WARNING with the reason and runs the command unconfined; require prints isolate.sh: ERROR ... (<why>) and exits without running it: 3 when another wrapper holds the lock, else 1. Usage errors exit 2. Otherwise the command’s exit status is the wrapper’s. CI (.github/scripts/gtest.sh) runs NoCtx with MTL_ISOLATE=require.

Requirements

What it does

Cleanup and sweep

On exit the wrapper terminates what is left in its cgroup, removes it and restores the saved settings. If the wrapper is SIGKILLed, a watcher in its own session does this, so a kill of the wrapper’s session or process group does not reach it, and it ignores SIGPIPE in case its stderr pipe is already gone. If both die, the next wrapper or isolate.sh --sweep (root) does; it exits 1 if a partition is left, 3 if the lock is held. .github/scripts/gtest.sh sweeps before and after the NoCtx run, the acceptance suite at session start, and task cleanup at the start of each CI test job. /run is tmpfs, so a reboot also resets the settings. Wrappers and sweeps serialize on flock /run/mtl-isolate.lock (a wrapper waits 10 s, then gives up), and remove the stale mtl-isolate-* cgroups of dead wrappers.

Limits