cvs commit: src/sys/amd64/include atomic.h src/sys/i386/include atomic.h

Bruce Evans bde at FreeBSD.org
Wed Dec 27 12:26:01 PST 2006


bde         2006-12-27 20:26:00 UTC

  FreeBSD src repository

  Modified files:
    sys/amd64/include    atomic.h 
    sys/i386/include     atomic.h 
  Log:
  Avoid an instruction in atomic_cmpset_{int_long)() in most cases.
  These functions are used a lot for mutexes, so this reduces the text
  size of an average kernel by about 0.75%.  This wasn't intended to
  be a significant optimization, but it somehow increased the maximum
  number of packets per second that can be transmitted by my bge hardware
  from 320000 to 460000 (this benchmark is CPU-bound and remarkably
  sensitive to changes in the text section).
  
  Details: we would prefer to leave the result of the cmpxchg in %al,
  but cannot tell gcc that it is there, so we have to convert it to an
  integer register.  We converted  to %al, then to %[re]ax, but the
  latter step is usually wasted since gcc usually only wants the condition
  code and can recover it from %al just as easily as from %[re]ax.  Let
  gcc promote %al in the few cases where this is needed.
  
  Nearby style fixes;
  - let gcc manage the load of `res', and don't abuse `res' for a copy of `exp'
  - don't echo `res's name in comments
  - consistently spell the condition code as 'e' after comparison for equality
  - don't hard-code %al anywhere except in constraints
  - for the version that doesn't use cmpxchg, there is no requirement to use
    %al anywhere, so don't hard-code it in the constraints either.
  
  Style non-fix:
  - for the versions that use cmpxchg, keep using "a" (was %[re]ax, now %al)
    for the main output operand, although this is not required.  The input
    and output operands that use the "a" constraint are now decoupled, and
    this makes things clearer except for the reason that the output register
    is hard-coded.  It is now just a hack to tell gcc that the input "a" has
    been clobbered without increasing the number of operands.
  
  Revision  Changes    Path
  1.40      +10 -10    src/sys/amd64/include/atomic.h
  1.43      +11 -11    src/sys/i386/include/atomic.h


More information about the cvs-src mailing list