Cpuid + rdtsc and out-of-order execution

cpuid used as a serialization command to prevent ooo from doing benchmarking, because the execution of control instructions can be reordered to rdtsc if it is used alone. My question is, is it possible to reorder the instructions below rdtsc between cpuid and rdtsc ? Since rdtsc not a serialization instruction, can instructions reorder freely around it?

+5
source share
1 answer

Since the RDTSC is independent of any input (it does not accept any arguments), in principle, the OOO pipeline will start it as soon as possible. The reason you add instructions for serialization before it prevents RDTSC from executing earlier.

There is an answer from John McCalpin here , this may seem useful to you. It explains the LLC reordering for the RDTSCP instruction (which behaves differently than RDTSC), which you prefer to use instead.

+1
source

All Articles