diff options
author | alc <alc@FreeBSD.org> | 1999-08-18 04:08:31 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 1999-08-18 04:08:31 +0000 |
commit | 999b998faadf98cd252ae30361406a176da029bd (patch) | |
tree | 84d98ec8a5702a071d3e1d0cf2972575f512b794 /sys/i386/include/atomic.h | |
parent | c3587e5dcb4c284938b70a3896c2d0f07b9cd626 (diff) | |
download | FreeBSD-src-999b998faadf98cd252ae30361406a176da029bd.zip FreeBSD-src-999b998faadf98cd252ae30361406a176da029bd.tar.gz |
Create callable (non-inline) versions of the atomic_OP_TYPE functions
that are linked into the kernel. The KLD compilation options are
changed to call these functions, rather than in-lining the
atomic operations.
This approach makes atomic operations from KLDs significantly
faster on UP systems (though somewhat slower on SMP systems).
PR: i386/13111
Submitted by: peter.jeremy@alcatel.com.au
Diffstat (limited to 'sys/i386/include/atomic.h')
-rw-r--r-- | sys/i386/include/atomic.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/i386/include/atomic.h b/sys/i386/include/atomic.h index d4e371b..e9f9403 100644 --- a/sys/i386/include/atomic.h +++ b/sys/i386/include/atomic.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: atomic.h,v 1.3 1999/07/13 06:35:25 alc Exp $ + * $Id: atomic.h,v 1.4 1999/07/23 23:45:19 alc Exp $ */ #ifndef _MACHINE_ATOMIC_H_ #define _MACHINE_ATOMIC_H_ @@ -54,9 +54,19 @@ */ /* - * Make kernel modules portable between UP and SMP. + * The above functions are expanded inline in the statically-linked + * kernel. Lock prefixes are generated if an SMP kernel is being + * built. + * + * Kernel modules call real functions which are built into the kernel. + * This allows kernel modules to be portable between UP and SMP systems. */ -#if defined(SMP) || defined(KLD_MODULE) +#if defined(KLD_MODULE) +#define ATOMIC_ASM(NAME, TYPE, OP, V) \ + extern void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); + +#else /* !KLD_MODULE */ +#if defined(SMP) #define MPLOCKED "lock ; " #else #define MPLOCKED @@ -74,6 +84,7 @@ atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ : "=m" (*p) \ : "0" (*p), "ir" (V)); \ } +#endif /* KLD_MODULE */ ATOMIC_ASM(set, char, "orb %2,%0", v) ATOMIC_ASM(clear, char, "andb %2,%0", ~v) |