I am trying to measure the difference of hour counters between two time points in a kernel module. I use the following function named get_ccnt() to get the hour counter value at a specific time:
static __inline__ long long int get_ccnt(void) { #if defined(__i386__) long long int x; __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); return x; #elif defined(__x86_64__) unsigned int hi, lo; __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); return ( (long long int)lo)|( ((long long int)hi)<<32 ); #endif }
What I touch, I use the HP EliteBook 2530p in which the Intel Core 2 Duo SL9400 ( link specification )
I heard that processors after Nehalem have a consistent hour counter across all cores. (If I am mistaken, indicate this.) But the Intel Core 2 Duo SL 9400 has the code name Penryn .
Thus, I think that if a core module moves from one core to another between two time points, then the consistency between the two cores is compromised, and I cannot get the correct clock difference.
Is what I think right? If so, is there a way to fix it (for example, fix the kernel module so as not to move the kernel to the kernel?)
source share