151 lines
5.2 KiB
Diff
151 lines
5.2 KiB
Diff
commit 2f5dd7261f2fc167ea1c8ef4154888fda0cf7db3
|
|
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
Date: Tue Nov 26 15:10:32 2024 +0100
|
|
|
|
pmc_agent: Use longer update interval when not subscribed.
|
|
|
|
When phc2sys is started with the -w option, the pmc agent is not
|
|
subscribed to events by the pmc_agent_subscribe() function, which also
|
|
sets the update interval. The update interval in this case is zero,
|
|
which means the pmc agent is trying to update the currentUtcOffset value
|
|
on every call of pmc_agent_update(), i.e. on every clock update in
|
|
phc2sys.
|
|
|
|
Set a default update interval of 60 seconds to reduce the rate of
|
|
pmc requests.
|
|
|
|
Fixes: e3ca7ea90a9e ("pmc_agent: Make update interval configurable.")
|
|
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
|
|
|
|
diff --git a/pmc_agent.c b/pmc_agent.c
|
|
index d1a3367..663adc0 100644
|
|
--- a/pmc_agent.c
|
|
+++ b/pmc_agent.c
|
|
@@ -33,6 +33,9 @@
|
|
#define UPDATES_PER_SUBSCRIPTION 3
|
|
#define MIN_UPDATE_INTERVAL 10
|
|
|
|
+/* Update interval if the agent not subscribed, just polling the UTC offset */
|
|
+#define DEFAULT_UPDATE_INTERVAL 60
|
|
+
|
|
struct pmc_agent {
|
|
struct pmc *pmc;
|
|
uint64_t pmc_last_update;
|
|
@@ -253,6 +256,7 @@ int init_pmc_node(struct config *cfg, struct pmc_agent *node, const char *uds,
|
|
}
|
|
node->recv_subscribed = recv_subscribed;
|
|
node->recv_context = context;
|
|
+ node->update_interval = DEFAULT_UPDATE_INTERVAL * NS_PER_SEC;
|
|
|
|
return 0;
|
|
}
|
|
|
|
commit b46f1bda3b13d17a67ffc9d0f9af76e2fc1af80a
|
|
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
Date: Tue Nov 26 15:10:33 2024 +0100
|
|
|
|
phc2sys: Don't disable pmc agent with -s -d -w options.
|
|
|
|
When phc2sys is started with -s and -d options to combine a PPS device
|
|
and PHC device as a time source, but without an offset specified by
|
|
the -O option, the pmc agent is disabled after waiting for ptp4l to have
|
|
a port in a synchronized state. This prevents phc2sys from following
|
|
changes in the currentUtcOffset value.
|
|
|
|
Disable the pmc agent only if no PHC device is specified by the -s
|
|
option, i.e. there are no PHC readings to which the UTC offset could be
|
|
applied.
|
|
|
|
Fixes: 5f1b419c4102 ("phc2sys: Replace magical test with a proper test.")
|
|
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
|
|
|
|
diff --git a/phc2sys.c b/phc2sys.c
|
|
index d09cb53..c98ecec 100644
|
|
--- a/phc2sys.c
|
|
+++ b/phc2sys.c
|
|
@@ -1594,7 +1594,7 @@ int main(int argc, char *argv[])
|
|
|
|
if (domains[0].forced_sync_offset ||
|
|
!phc2sys_using_systemclock(&domains[0]) ||
|
|
- hardpps_configured(pps_fd)) {
|
|
+ (hardpps_configured(pps_fd) && !src_name)) {
|
|
pmc_agent_disable(domains[0].agent);
|
|
}
|
|
}
|
|
|
|
commit 8bd0ee2f65c72fb45f95aca8e907514092fc9cd1
|
|
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
Date: Tue Nov 26 15:10:34 2024 +0100
|
|
|
|
phc2sys: Don't require -O option without -a and -w.
|
|
|
|
Allow phc2sys to be started in the static mode without the -O option,
|
|
meaning it should fetch the UTC offset from ptp4l, even if the -w option
|
|
is not included on the command line to wait for ptp4l to have a port in
|
|
the master or slave state.
|
|
|
|
This is useful when the PHC is synchronized by ts2phc or other
|
|
application and the system clock needs to be synchronized to the PHC
|
|
even when ptp4l has all ports in the faulty state (e.g. all network
|
|
links are down).
|
|
|
|
It's the responsibility of the user to start phc2sys when ptp4l is
|
|
already running. phc2sys will exit with an error message if it cannot
|
|
get a response with the 1-second timeout.
|
|
|
|
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
|
diff --git a/phc2sys.8 b/phc2sys.8
|
|
index 762a1b1..3246c8f 100644
|
|
--- a/phc2sys.8
|
|
+++ b/phc2sys.8
|
|
@@ -164,7 +164,10 @@ minimize the error caused by random delays in scheduling and bus utilization.
|
|
The default is 5.
|
|
.TP
|
|
.BI \-O " offset"
|
|
-Specify the offset between the sink and source times in seconds. Not
|
|
+Specify the offset between the sink and source times in seconds. If not
|
|
+specified, the offset will be set according to the currentUtcOffset value
|
|
+obtained from ptp4l and the direction of synchronization, assuming the system
|
|
+clock is keeping time in UTC and all used PHCs keep time in TAI. Not
|
|
compatible with the
|
|
.B \-a
|
|
option. See
|
|
diff --git a/phc2sys.c b/phc2sys.c
|
|
index c98ecec..ddd0a6a 100644
|
|
--- a/phc2sys.c
|
|
+++ b/phc2sys.c
|
|
@@ -1452,12 +1452,6 @@ int main(int argc, char *argv[])
|
|
goto bad_usage;
|
|
}
|
|
|
|
- if (!autocfg && !wait_sync && !settings.forced_sync_offset) {
|
|
- fprintf(stderr,
|
|
- "time offset must be specified using -w or -O\n");
|
|
- goto bad_usage;
|
|
- }
|
|
-
|
|
if (hardpps_configured(pps_fd) && (dst_cnt != 1 ||
|
|
strcmp(dst_names[0], "CLOCK_REALTIME"))) {
|
|
fprintf(stderr,
|
|
@@ -1559,7 +1553,7 @@ int main(int argc, char *argv[])
|
|
|
|
r = -1;
|
|
|
|
- if (wait_sync) {
|
|
+ if (wait_sync || !domains[0].forced_sync_offset) {
|
|
snprintf(uds_local, sizeof(uds_local),
|
|
"/var/run/phc2sys.%d", getpid());
|
|
|
|
@@ -1574,7 +1568,7 @@ int main(int argc, char *argv[])
|
|
phc2sys_recv_subscribed, &domains[0]))
|
|
goto end;
|
|
|
|
- while (is_running()) {
|
|
+ while (wait_sync && is_running()) {
|
|
r = run_pmc_wait_sync(domains[0].agent, 1000);
|
|
if (r < 0)
|
|
goto end;
|