[Click] click_get_cycles() on x86_64

Salman Abdul Baset salman at cs.columbia.edu
Wed Jul 25 14:29:32 EDT 2007


Hi Eddie,

I double-checked the code fragment I sent earlier and it does not seem to 
work :)

The following fragment does indeed give the cycle count using rdtsc:

uint32_t __low, __high;
     uint64_t x;
     __asm__ __volatile__ ("rdtsc" : "=d" (__low), "=a" (__high));
     x = (__high << 32) | __low;
     return x;

I have a SMP machine (quad-core dual socket Xeon 1.6GHz), and the value 
of rdtsc is not monotonically increasing and sometimes decreases across 
subsequent instructions. This happens because my kernel thread is not 
necessarily pinned to one CPU.

Assuming I have N click threads, is there a way to specify CPU affinity 
for each thread at command-line?

regards,
Salman


On Tue, 24 Jul 2007, Eddie Kohler wrote:

> Hi Salman,
>
> The Linux headers say the equivalent of
>
> "rdtsc" : "=d" (xhi), "=a" (xlo)
>
> but that should be the same as "=A".  If that code works for you, it works! 
> I'm checking a variant of it in.
>
> Eddie
>
>
>
>
> Salman Abdul Baset wrote:
>> In function click_get_cycles() defined in include/click/glue.hh, there is 
>> no #ifdef for x86_64. Consequently, on the machine I am testing (quad core, 
>> x86_64) click_get_cycles() returns zero.
>> 
>> I copied the code from
>> #if CLICK_LINUXMODULE && HAVE_INT64_TYPES && __i386__
>> to fix it:
>> 
>> <code>
>> #elif CLICK_LINUXMODULE && HAVE_INT64_TYPES && __x86_64__
>>      uint64_t x;
>>      __asm__ __volatile__ ("rdtsc" : "=A" (x));
>>      return x;
>> </code>
>> 
>> Is this a correct way to do this?
>> 
>> Thanks
>> Salman
>> _______________________________________________
>> click mailing list
>> click at amsterdam.lcs.mit.edu
>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>


More information about the click mailing list