Using rdtsc to timestamp RTT of packets

Stephen Hemminger stephen at networkplumber.org
Mon Mar 6 17:56:14 CET 2023


On Sun, 5 Mar 2023 20:01:15 -0500
fwefew 4t4tg <7532yahoo at gmail.com> wrote:

> I think rdtsc does all this. But then I read [1]:
> 
>    - The TSC is not always invariant
>    - And of course context switches (if a thread is not pinned to a core)
>    will invalidate any time difference
>    - The TSC is not incremented when the processor enters a deep sleep. I
>    don't care about this because I'll turn off the power saving modes anyway

Stack Overflow is only one step better than ChatGPT in giving
partially correct answers.

TSC is almost always works well on modern processors.
The Linux kernel aligns all the TSC values for each core at boot up.
It is invariant (derived from a single clock source) unless you have some
poorly designed NUMA system.  In the past, there were some CPU's that
did bad things during suspend, but that is fixed in current generations.

Bottom line: that advice is no longer true.


More information about the users mailing list