Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Dec 1996 15:39:19 -0700
From:      vanmaren@fast.cs.utah.edu (Kevin Van Maren)
To:        ccsanady@friley216.res.iastate.edu
Cc:        freebsd-smp@freebsd.org
Subject:   Re:  Finished locks..
Message-ID:  <199612032239.PAA15211@fast.cs.utah.edu>

next in thread | raw e-mail | index | archive | help
There are a few problems with your code:

1) It can't be inlined by the compiler.  Especially Unlock,
which is trivial, should be inlined for performance.
(With fine-grained locking, there are tens of thousands of them a 
second...if not more)

2) You are pessemistic about the register usage.  If you use a gcc
__asm__ macro, gcc will know if it can trash registers; this will
save considerable time.  (It can also arrange for the values to be
loaded in advance, or whatever).  By allowing the compiler to
pick the registers whenever possible ("r"), it can better manage the
register usage.

I rewrote my recursive lock functions as macros, which is the
reason I discovered a "feature" of gcc: if you pre-load eax with -1
(in param) it won't work if the code is inlined, as gcc trashed the
IN parameter as it reused the variable; ie, %eax, an IN parameter,
was also assigned as "r").  (This was for the three-register cmpxchg;
it specified %eax as a register, even though it was already implicit).

This was VERY annoying to debug.  (I just had to look at the assembly
output).  Why gcc thinks it can re-use IN registers is beyond me.

Kevin T. Van Maren
University of Utah, CSL



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612032239.PAA15211>