diff options
author | Bill Paul <wpaul@FreeBSD.org> | 2004-01-07 07:29:27 +0000 |
---|---|---|
committer | Bill Paul <wpaul@FreeBSD.org> | 2004-01-07 07:29:27 +0000 |
commit | e15712876215565688b40db0123502e2c56bbeee (patch) | |
tree | 0bbc95e856a26a77d8697ca0941527c820f67829 /sys/compat | |
parent | e3c8d8194c262e1741f6aa83fda1816ceba676b6 (diff) | |
download | src-e15712876215565688b40db0123502e2c56bbeee.tar.gz src-e15712876215565688b40db0123502e2c56bbeee.zip |
Use atomic ops for the interlocked increment and decrement routines
in subr_ndis and subr_ntoskrnl. This is faster and avoids potential
LOR whinage from witness (an LOR couldn't happen with the old code
since the interlocked inc/dec routines could not sleep with a lock
held, but this will keep witness happy and it's more efficient
anyway. I think.)
Notes
Notes:
svn path=/head/; revision=124203
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/ndis/subr_ndis.c | 9 | ||||
-rw-r--r-- | sys/compat/ndis/subr_ntoskrnl.c | 11 |
2 files changed, 6 insertions, 14 deletions
diff --git a/sys/compat/ndis/subr_ndis.c b/sys/compat/ndis/subr_ndis.c index b272bc5fc72b..ad769f601acc 100644 --- a/sys/compat/ndis/subr_ndis.c +++ b/sys/compat/ndis/subr_ndis.c @@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$"); #include <net/if_dl.h> #include <net/if_media.h> +#include <machine/atomic.h> #include <machine/bus_memio.h> #include <machine/bus_pio.h> #include <machine/bus.h> @@ -1780,9 +1781,7 @@ __stdcall static uint32_t ndis_interlock_inc(addend) uint32_t *addend; { - mtx_lock(&ndis_interlock); - (*addend)++; - mtx_unlock(&ndis_interlock); + atomic_add_long((u_long *)addend, 1); return(*addend); } @@ -1790,9 +1789,7 @@ __stdcall static uint32_t ndis_interlock_dec(addend) uint32_t *addend; { - mtx_lock(&ndis_interlock); - (*addend)--; - mtx_unlock(&ndis_interlock); + atomic_subtract_long((u_long *)addend, 1); return(*addend); } diff --git a/sys/compat/ndis/subr_ntoskrnl.c b/sys/compat/ndis/subr_ntoskrnl.c index 5278bc2752da..72f1f11904f3 100644 --- a/sys/compat/ndis/subr_ntoskrnl.c +++ b/sys/compat/ndis/subr_ntoskrnl.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <sys/callout.h> #include <sys/kernel.h> +#include <machine/atomic.h> #include <machine/clock.h> #include <machine/bus_memio.h> #include <machine/bus_pio.h> @@ -578,10 +579,7 @@ ntoskrnl_interlock_inc(/*addend*/ void) __asm__ __volatile__ ("" : "=c" (addend)); - mtx_lock(&ntoskrnl_interlock); - (*addend)++; - mtx_unlock(&ntoskrnl_interlock); - + atomic_add_long((volatile u_long *)addend, 1); return(*addend); } @@ -592,10 +590,7 @@ ntoskrnl_interlock_dec(/*addend*/ void) __asm__ __volatile__ ("" : "=c" (addend)); - mtx_lock(&ntoskrnl_interlock); - (*addend)--; - mtx_unlock(&ntoskrnl_interlock); - + atomic_subtract_long((volatile u_long *)addend, 1); return(*addend); } |