On 15/03/2023 13:51, Miroslav Lichvar wrote:
> On Wed, Mar 15, 2023 at 12:55:56PM +0100, Maciek Machnikowski wrote:
>> The SHM is not cleared upon servo release when exiting the tool. This leaves
>> the last update in the shared memory region marked as valid. As a result, the
>> NTP daemon starting later may consume stale data if the producer process
>> exited.
>>
>> To prevent such behavior - invalidate the SHM data when releasing the SHM 
>> servo.
> 
> It probably doesn't matter much either way, but this doesn't seem
> right to me. The sample stays valid after ptp4l/phc2sys exited. There
> is a timestamp when the measurement was made. It's up to the consumer
> to check if it's still acceptable.
> 
It depends on why you terminated the process.

If you start the synchronization process and see that it doesn't work
correctly then, this cleanup will prevent leaving invalid timestamps in
memory.

If timestamps were correct, it doesn't matter only as long as no one
else touches the clocks.

If the NTP process restarts, gets the time from a different source, and
returns to the stale timestamp (which will sit in memory forever) it may
incorrectly interpret this value as the right one.

It also may backfire on embedded systems that stop the clock when going
to sleep. After resuming, the value kept in there will be incorrect as well.

> The same situation happens when the servo stops due the port switching
> to another PTP state without exiting. The last sample was made when
> the source clock was considered synchronized and it can be used for
> synchronization of the system clock.
> 

Here we are a bit safer, as that's (theoretically) a transitional state,
and the "fundamental" system configuration shouldn't change while it
happens.

Regards,
Maciek


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to