Skip to content

start without PTP when /dev/fbclock/ptp or the PHC is missing (#592) - #592

Open
ESoapW wants to merge 1 commit into
meta:mainfrom
ESoapW:export-D128232627
Open

ESoapW wants to merge 1 commit into
meta:mainfrom
ESoapW:export-D128232627

Conversation

@ESoapW

@ESoapW ESoapW commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

This diff adds the conditions for what the sidecar writes. It writes NTP on every host, with -v3. It writes PTP and PRTC, and everything else PTP needs (v1, v2 and the linearizability tests), only on a PTP host: one where /dev/fbclock/ptp exists and -iface's PHC opens. A PTP host runs exactly as today; only hosts without PTP change.

Today the sidecar can't run on a host without PTP. It exits at startup without a PHC, and it always writes v1, runs the sptp loop and starts the linearizability tests. That blocks -v3 on those hosts. Chrony mode used to cover them, and D127943753 removed it.

The daemon checks the conditions at startup. The device is what marks a PTP host, since non-PTP NICs can have a PHC too. Any error from either check counts as no PTP, and the startup log line says why. A host without PTP then checks again every 10 s, the pace at which systemd restarts a sidecar that exits, and once the device exists and the PHC opens, it exits so that the restart runs PTP. So a link that udev makes after the sidecar started, at boot or on a turnup, or a PHC that comes back after a NIC reset, gets PTP without anyone restarting the sidecar, and ntp keeps flowing meanwhile. That matters once -manage goes off: today, with -manage on, main exits when -iface has no PHC and systemd retries.

Without PTP the sidecar writes only v3's ntp section (header 0x4) and keeps running. There's no PHC setup, no v1 or v2 file, no sptp loop, no PTP counters and no linearizability tests, whose failures fbclock.mon alerts on and FBAR answers by restarting sptp. It exits at startup when it has nothing to write: without -v3, or when /run/fbclock/data can't be opened. With -manage on, main exits before the daemon starts when -iface has no PHC, so for the v3 rollout those hosts run with -manage=false.

How the sidecar starts, before and after:

https://pxl.cl/hX3GC

In code, New checks the conditions and keeps the result, openDataV3 builds v3's header from it (0x7 on a PTP host, 0x4 without), and Run starts the ntp loop on every host. On a host without PTP, Run then waits there and re-checks every 10 s. Everything below that stop is today's Run, except that it no longer opens v3 itself.

The open-source fbclock-daemon shares this code. A host with a PHC, -manage=false and no /dev/fbclock/ptp now writes only ntp, or fails without -v3, where today's daemon runs PTP. The open-source client library doesn't init there on default options, so those setups don't change. A caller that opted into NTP or ANY loses data_v2 there.

No new files or flags. Without PTP the daemon creates only /run/fbclock/data, which it already creates with -v3.

Differential Revision: D128232627

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 30, 2026
@meta-codesync

meta-codesync Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

@ESoapW has exported this pull request. If you are a Meta employee, you can view the originating Diff in D128232627.

Summary:

This diff adds the conditions for what the sidecar writes. It writes NTP on every host, with -v3. It writes PTP and PRTC, and everything else PTP needs (v1, v2 and the linearizability tests), only on a PTP host: one where /dev/fbclock/ptp exists and -iface's PHC opens. A PTP host runs exactly as today; only hosts without PTP change.

Today the sidecar can't run on a host without PTP. It exits at startup without a PHC, and it always writes v1, runs the sptp loop and starts the linearizability tests. That blocks -v3 on those hosts. Chrony mode used to cover them, and D127943753 removed it.

The daemon checks the conditions at startup. The device is what marks a PTP host, since non-PTP NICs can have a PHC too. Any error from either check counts as no PTP, and the startup log line says why. A host without PTP then checks again every 10 s, the pace at which systemd restarts a sidecar that exits, and once the device exists and the PHC opens, it exits so that the restart runs PTP. So a link that udev makes after the sidecar started, at boot or on a turnup, or a PHC that comes back after a NIC reset, gets PTP without anyone restarting the sidecar, and ntp keeps flowing meanwhile. That matters once -manage goes off: today, with -manage on, main exits when -iface has no PHC and systemd retries.

Without PTP the sidecar writes only v3's ntp section (header 0x4) and keeps running. There's no PHC setup, no v1 or v2 file, no sptp loop, no PTP counters and no linearizability tests, whose failures fbclock.mon alerts on and FBAR answers by restarting sptp. It exits at startup when it has nothing to write: without -v3, or when /run/fbclock/data can't be opened. With -manage on, main exits before the daemon starts when -iface has no PHC, so for the v3 rollout those hosts run with -manage=false.

How the sidecar starts, before and after:

https://pxl.cl/hX3GC

In code, New checks the conditions and keeps the result, openDataV3 builds v3's header from it (0x7 on a PTP host, 0x4 without), and Run starts the ntp loop on every host. On a host without PTP, Run then waits there and re-checks every 10 s. Everything below that stop is today's Run, except that it no longer opens v3 itself.

The open-source fbclock-daemon shares this code. A host with a PHC, -manage=false and no /dev/fbclock/ptp now writes only ntp, or fails without -v3, where today's daemon runs PTP. The open-source client library doesn't init there on default options, so those setups don't change. A caller that opted into NTP or ANY loses data_v2 there.

No new files or flags. Without PTP the daemon creates only /run/fbclock/data, which it already creates with -v3.

Differential Revision: D128232627
@meta-codesync meta-codesync Bot changed the title start without PTP when /dev/fbclock/ptp or the PHC is missing start without PTP when /dev/fbclock/ptp or the PHC is missing (#592) Oct 31, 2026
@ESoapW
ESoapW force-pushed the export-D128232627 branch from 8d81498 to 4cdf08d Compare October 31, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant