[COMPLIB] improve spinlocks to take a more efficient spinlock while at DPC level
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 7 Feb 2007 12:10:54 +0000 (12:10 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 7 Feb 2007 12:10:54 +0000 (12:10 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@579 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

inc/kernel/complib/cl_spinlock_osd.h

index 54306bb..bf6a419 100644 (file)
@@ -88,9 +88,15 @@ CL_INLINE void
 cl_spinlock_acquire( \r
        IN      cl_spinlock_t* const    p_spinlock )\r
 {\r
+       KIRQL irql = KeGetCurrentIrql();\r
        CL_ASSERT( p_spinlock );\r
 \r
-       KeAcquireSpinLock( &p_spinlock->lock, &p_spinlock->irql );\r
+       if (irql == DISPATCH_LEVEL) {\r
+               KeAcquireSpinLockAtDpcLevel( &p_spinlock->lock );\r
+               p_spinlock->irql = irql;\r
+       }\r
+       else\r
+               KeAcquireSpinLock( &p_spinlock->lock, &p_spinlock->irql );\r
 }\r
 \r
 \r
@@ -100,7 +106,10 @@ cl_spinlock_release(
 {\r
        CL_ASSERT( p_spinlock );\r
 \r
-       KeReleaseSpinLock( &p_spinlock->lock, p_spinlock->irql );\r
+       if (p_spinlock->irql == DISPATCH_LEVEL)\r
+               KeReleaseSpinLockFromDpcLevel( &p_spinlock->lock );\r
+       else\r
+               KeReleaseSpinLock( &p_spinlock->lock, p_spinlock->irql );\r
 }\r
 \r
 \r