From owner-freebsd-smp Tue Dec 3 14:39:29 1996 Return-Path: owner-smp Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA17162 for smp-outgoing; Tue, 3 Dec 1996 14:39:29 -0800 (PST) Received: from cs.utah.edu (cs.utah.edu [128.110.4.21]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id OAA17154 for ; Tue, 3 Dec 1996 14:39:27 -0800 (PST) Received: from fast.cs.utah.edu by cs.utah.edu (8.8.3/utah-2.21-cs) id PAA28898; Tue, 3 Dec 1996 15:39:20 -0700 (MST) Received: by fast.cs.utah.edu (8.6.10/utah-2.15-leaf) id PAA15211; Tue, 3 Dec 1996 15:39:19 -0700 Date: Tue, 3 Dec 1996 15:39:19 -0700 From: vanmaren@fast.cs.utah.edu (Kevin Van Maren) Message-Id: <199612032239.PAA15211@fast.cs.utah.edu> To: ccsanady@friley216.res.iastate.edu Subject: Re: Finished locks.. Cc: freebsd-smp@freebsd.org Sender: owner-smp@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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