integ/base/linuxptp/debian/patches/0009-sysoff-Retry-on-EBUSY-when-probing-supported-ioctls.patch
Cole Walker aca42c6d4c Implement logic to skip updates with offset spike in ts2phc.
This change allows ts2phc to be configured to ignore timing updates that
have a large offset spike in order to mitigate the resulting timing
skew.

In some circumstances on realtime systems with high CPU load, the
timestamp consumed by ts2phc can be delayed in reaching ts2phc and
results in the offset calculation attempting to speed the clock up by a
large margin.

This change causes ts2phc to ignore updates that would greatly skew the
clock when ts2phc is already in a synchronized state.

The global configuration option "max_phc_update_skip_cnt" is provided to
allow users to specify how many consecutive offset spike incidents will
be ignored before adjusting the clock. The default value is 120. The
behaviour can be disabled by setting max_phc_update_skip_cnt to 0.

This code is ported from a proposed upstream patch found here:
https://sourceforge.net/p/linuxptp/mailman/message/44114092/

Test-plan:
Pass: Verify linuxptp package build
Pass: Deploy ts2phc binary and verify system time sync
Pass: Manually trigger offset spike and verify that ts2phc maintains
stable time sync

Closes-bug: https://bugs.launchpad.net/starlingx/+bug/2059955

Change-Id: I13cd5c3440682ec9256e11449fe62d5fe28f66fa
Signed-off-by: Cole Walker <cole.walker@windriver.com>
2024-04-01 14:53:06 -04:00

54 lines
1.5 KiB
Diff

From c36e970db481dc1d5482386418f046f46b25f645 Mon Sep 17 00:00:00 2001
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Wed, 18 May 2022 11:33:37 +0200
Subject: [PATCH 09/58] sysoff: Retry on EBUSY when probing supported ioctls.
Handle EBUSY when probing support for a PTP_SYS_OFFSET ioctl. Try each
ioctl up to three times before giving up on it to make the detection
more reliable.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
[commit dadd2593c7beaee9eba5828a7bd8a0b5849dd8bb upstream]
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
---
sysoff.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/sysoff.c b/sysoff.c
index a425275..fc1f7ca 100644
--- a/sysoff.c
+++ b/sysoff.c
@@ -145,8 +145,8 @@ int sysoff_measure(int fd, int method, int n_samples,
int sysoff_probe(int fd, int n_samples)
{
int64_t junk, delay;
+ int i, j, err;
uint64_t ts;
- int i;
if (n_samples > PTP_MAX_SAMPLES) {
fprintf(stderr, "warning: %d exceeds kernel max readings %d\n",
@@ -156,9 +156,15 @@ int sysoff_probe(int fd, int n_samples)
}
for (i = 0; i < SYSOFF_LAST; i++) {
- if (sysoff_measure(fd, i, n_samples, &junk, &ts, &delay) < 0)
- continue;
- return i;
+ for (j = 0; j < 3; j++) {
+ err = sysoff_measure(fd, i, n_samples, &junk, &ts,
+ &delay);
+ if (err == -EBUSY)
+ continue;
+ if (err)
+ break;
+ return i;
+ }
}
return SYSOFF_RUN_TIME_MISSING;
--
2.30.2