Port-amd64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: rdtscp instruction

> On 25.07.2010 00:31, Christoph Egger wrote:
> > The differences between RDTSC and RDTSCP are:
> > 
> > - RDTSCP is a serializing instruction
> > - RDTSCP additionally loads the lower 32bits
> >   of MSR_TSC_AUX into ecx register.
> > 
> > The MSR_TSC_AUX (0xc0000103) is read-write
> > for the OS and can be filled with anything
> > meaningful to the OS (i.e. processor ID).
> > The upper 32bits are reserved.
> > The MSR exists for each CPU-core.
> > 
> > The question is: What useful information
> > can NetBSD store into MSR_TSC_AUX ?
> What do other kernels store in this MSR?

OpenSolaris stores the cpu id,
Linux stores the cpu id and NUMA node
and Xen stores the guest incarnation into this MSR.

If in cr4 the TSC bit is set then userland can use
the rdtsc and rdtscp instructions.

Userland can get per-cpu informations with the rdtscp

When we fill in the cpu id in MSR_TSC_AUX then userland
can detect and deal with TSC clock skews between different
physical cpus. However, on CPUs w/o a constant TSC
(e.g. AMD K8), the tsc is bound on the cpu clock frequency
and the tsc is not guarateed to increase at
constant rate. Switching between different P-States
changes the cpu frequency and the TSC rate.

When we fill in the cpu id and the NUMA node then userland
can also detect that it moved to a different NUMA node or
that its threads run on different NUMA nodes.

I think we should fill in the MSR_TSC_AUX the cpuid,
reserve some bits for the NUMA node (will be used once we have NUMA) and 
reserve some bits for the future.


Home | Main Index | Thread Index | Old Index