Skip to content

Fix: Wait for ptp4l/phc2sys death before PF rebind in validation conftest#1646

Open
awilczyns wants to merge 4 commits into
mainfrom
fix-ptp-hanging-tests
Open

Fix: Wait for ptp4l/phc2sys death before PF rebind in validation conftest#1646
awilczyns wants to merge 4 commits into
mainfrom
fix-ptp-hanging-tests

Conversation

@awilczyns

Copy link
Copy Markdown
Collaborator

Summary

Nightly run-pytest (e810, ptp) jobs on e810 runners (observed on
mtl-runner-2) intermittently hang the host for the rest of the night.
Root cause traced through the host journal: ptp4l holds the PF's PHC
fd, test teardown killed it with a blind sleep(0.3), and if the kernel
hadn't yet released the fd, nicctl's VF/PF rebind checks (bind_kernel
/ disable_vf) timed out and fell back to a PCI remove+rescan. That
force-reprobes the PF (ice_probe) outside the graceful sriov_numvfs=0
teardown path and can hit an ice driver GPF (RSS flow-profile
use-after-free in ice_add_prof).

Also adds real PTP conformance coverage: the existing @pytest.mark.ptp
test never asserted anything about PTP state, so it passed even with no
reachable grandmaster.

Changes

  • Fix: _reap_ptp_daemons now polls for actual process death
    (_wait_daemon_dead) after both SIGTERM and SIGKILL instead of
    sleeping a fixed duration, closing the race before callers rebind the
    PF.
  • Test: adds tests/validation/tests/single/ptp/ptp_helpers.py and
    tests/validation/tests/single/ptp/grandmaster/test_ptp_conformance.py:
    • test_mtl_internal_ptp_converges — asserts MTL's own software PTP
      client (mt_ptp.c's periodic PTP(0): delta avg ... stat line)
      actually leaves "not connected" and settles within tolerance.
    • test_mtl_and_ptp4l_agree_on_grandmaster — cross-checks that
      against ptp4l (via the existing ptp_sync fixture) converging on
      the same wire, verifying external-grandmaster interoperability.
    • Both skip (not fail) when no grandmaster is reachable at all, since
      that's a topology precondition, not a regression.

Testing

  • pytest --collect-only clean (8 tests collected, no import errors).
  • Not yet run against real hardware/VFs — needs a run on an e810 runner
    with a confirmed-reachable grandmaster to verify the new tests assert
    (rather than skip).

@awilczyns awilczyns force-pushed the fix-ptp-hanging-tests branch 2 times, most recently from 89940b5 to c96fe66 Compare July 7, 2026 13:04
_reap_ptp_daemons used a blind 0.3s sleep between SIGTERM and SIGKILL,
which does not guarantee the kernel has released the PF netdev/PHC fd
ptp4l held. nicctl's VF/PF rebind checks (bind_kernel/disable_vf) can
still see the PF busy, time out, and fall back to a PCI remove+rescan
that force-reprobes the PF (ice_probe) -- observed on mtl-runner-2 to
hit an ice driver GPF (RSS flow-profile UAF in ice_add_prof), hanging
the host for the rest of the night.

_wait_daemon_dead() now polls for actual process death after both
SIGTERM and SIGKILL instead of sleeping a fixed duration, closing the
race before callers touch the PF again.

Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
@awilczyns awilczyns force-pushed the fix-ptp-hanging-tests branch 4 times, most recently from 26f0ba7 to 02ef58b Compare July 7, 2026 17:12
awilczyns added 3 commits July 7, 2026 17:13
…lity crash

- Dynamically probe for interface presence in /sys/class/net inside conftest.py
  to skip starting ptp4l on ports bound to DPDK PMDs.
- Gracefully skip single-host mixed-mode (PF/VF) tests when physical functions
  share an IOMMU group, resolving the EAL/VFIO viability failure on shared environments.
- Enforce strict non-empty capture compliance checks in pytest validation run.
- Add ptp_sync request to mixed-mode PT/VF test signature.

Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
…up_validation.sh

Preflight hardcoded tests/tools/RxTxApp/build/RxTxApp and
build/manager/MtlManager, but mtl_engine/const.py::PREFIX actually
invokes .local_install/mtl/bin/* -- preflight reported MISSING on hosts
built that way even though pytest itself worked fine.

HugePages_Free*2 also silently under-reports free hugepage MiB on hosts
booted with default_hugepagesz=1G, since the multiplier assumes 2MB
pages; now reads Hugepagesize from /proc/meminfo instead of assuming.

Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
ptp_sync started ptp4l on kernel-bound interfaces but only checked the
process stayed alive 0.2s after spawn -- never that it actually locked
onto a grandmaster. A free-running/unsynced PHC produced a real EBU
compliance failure (~-55.8s packet_ts_vs_rtp_ts offset, 2110_21_vrx
non-compliant) that only surfaced after a multi-minute run.

ptp_sync now blocks on wait_for_ptp4l_foreign_master() for every
interface it starts ptp4l on, before yielding to the test body, and
reaps on timeout so a dead grandmaster cannot orphan the daemon into
PID 1 (the same leak class that previously triggered an ice driver
use-after-free and a BMC reset on mtl-runner-2/3).

require_grandmaster no longer duplicates this wait since ptp_sync (its
own dependency) already guarantees it.

Also adds the grandmaster/ PTP conformance test package
(test_mtl_internal_ptp_converges, test_mtl_and_ptp4l_agree_on_grandmaster)
and shared ptp_helpers.py assertion helpers.

Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant