Skip to content

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

Open
awilczyns wants to merge 2 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 2 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 6 times, most recently from 26f0ba7 to 02ef58b Compare July 7, 2026 17:12
@awilczyns
awilczyns force-pushed the fix-ptp-hanging-tests branch 2 times, most recently from 8662255 to e8f49a1 Compare July 28, 2026 13:50
setup_validation.sh assumed a system-wide MTL install and 2M hugepages, so a
runner prepared with .local_install was reported as not ready even though
RxTxApp/MtlManager were present.

Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
The @pytest.mark.ptp st20p tests failed EBU LIST compliance with
invalid_delta_packet_ts_vs_rtp_ts offsets of ~-116s (vf_only captures were
rejected outright as containing no stream at all). Two independent framework
defects put the pcap timestamps and the transmitted RTP timestamps on
different timescales:

1. ptp_sync started ptp4l on both physical ports. E810/E830 expose a single
   PHC per adapter (both instances log "selected /dev/ptp1"), so the second
   daemon did not get its own clock - and when its port was link-down after a
   previous test rebound it, that instance declared itself grandmaster and
   free-ran the shared PHC underneath the capture. Sync only the capture
   interface; it is the only PHC that has to follow the grandmaster.

2. The netsniff hook slept a fixed 50s "for PTP sync" before capturing. MTL's
   own PTP client can take well over a minute to lock after a PF is bound to
   DPDK, and until it does MTL stamps RTP from the system clock while the
   capture PHC already follows the grandmaster. Wait for MTL to report a
   locked PTP delta (< 1ms) on its stdout instead of guessing.

Also carried over from the earlier work on this branch: skip mixed PF/VF
interface profiles when both PFs share one IOMMU group (VFIO group is not
viable, previously an opaque rc=244 crash), poll for actual ptp4l/phc2sys
death before rebinding a PF, and fail fast when no grandmaster is reachable.

Verified on mtl-runner-9 (E830, 720p60 VF-to-VF): MTL PTP lock detected in
21s and packet_ts_vs_rtp_ts drops from -116s to 131us (compliant).

Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
@awilczyns
awilczyns force-pushed the fix-ptp-hanging-tests branch from e8f49a1 to 4b4f646 Compare July 28, 2026 15:48
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