On 2024-09-16 20:15, Peter Zijlstra wrote:
[...]
The point being that it is possible to wrap one CPU into the id space of
another CPU. It is not trivial, but someone who wants to can make it
happen.
I agree that the overflow of the free-running counter bleeding into the
CPU numbers is something we want to prevent. We don't care if this
counter overflows after day/months/years for sake of correlation
within a system call, but we do care about the fact that this
free-running counter could be made to overflow after a very long
time while the system runs, and then we reach a state where the
CPU numbers are mixed up, which leads to short-term correlation
issues.
I would recommend this layout for this 64-bit value instead:
low-bits: cpu number
high-bits: free-running counter
This way, we eliminate any carry from overflow into the cpu number bits.
Thanks,
Mathieu