amd64 modules still use atomics as callable functions

John-Mark Gurney jmg at funkthat.com
Mon Oct 27 23:34:34 UTC 2014


Mateusz Guzik wrote this message on Mon, Oct 27, 2014 at 23:49 +0100:
> Turns out several years ago the kernel was modified to provide actual
> functions for atomic operations and modules are always using them.
> 
> I propose plugging it on amd64 in head.

It'd be interesting to measure the difference between making the call,
and the cost of the lock prefix...

On modern processors, according to instruction_tables.pdf, the lock
prefix costs between 5 and 45 cycles..  It could be more on older
processors...  Though another references says that a function call
over head is in the 7-9 cycle range, so w/o measuring, I'm not so sure
this is a good idea...

Originally I was in favor of this, as the number of amd64 systems that
aren't SMP aware are getting rarer by the day...  But, considering that
many locking ops (if contended) will take a lot longer, I'm not so
sure that the inline call will save you that much..

It'd be useful to see a comparision between:
LOCK'd inlined
LOCK'd via function call
non-LOCK'd inlined

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-arch mailing list