On Sun, 5 Mar 2023 20:01:15 -0500
fwefew 4t4tg <7532ya...@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.

Reply via email to