[Click] click_get_cycles() on x86_64

Eddie Kohler kohler at cs.ucla.edu
Tue Aug 28 01:39:42 EDT 2007


Hi Salman,

Thanks for the update.  I guess the =A constraint doesn't work on x86_64.

However, the problem with your code is not the SMP machine, but rather that 
you have switched the meaning of __low and __high.  You should set "=a" 
(__low), "=d" (__high).  I've checked the right version in.

I've checked in a fix that will allow CPU affinities when Click is running 
multithreaded: the --cpu=N argument will specify CPU affinities N, N+1, ... 
for however many threads there are.  Does that work for you?

Eddie


Salman Abdul Baset wrote:
> 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