https://git.reactos.org/?p=reactos.git;a=commitdiff;h=81532227b6be15f8f143e879c85f329e5a084c12

commit 81532227b6be15f8f143e879c85f329e5a084c12
Author: Thomas Faber <[email protected]>
AuthorDate: Tue Nov 21 23:36:34 2017 +0100

    [NTOS:MM] Implement and use 
MiAcquirePfnLockAtDpcLevel/MiReleasePfnLockFromDpcLevel.
---
 ntoskrnl/include/internal/mm.h | 22 ++++++++++++++++++++++
 ntoskrnl/mm/ARM3/pool.c        |  6 ++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h
index d96900b27e..ec42abbfae 100644
--- a/ntoskrnl/include/internal/mm.h
+++ b/ntoskrnl/include/internal/mm.h
@@ -883,6 +883,28 @@ MiReleasePfnLock(
     KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
 }
 
+FORCEINLINE
+VOID
+MiAcquirePfnLockAtDpcLevel(VOID)
+{
+    PKSPIN_LOCK_QUEUE LockQueue;
+
+    ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
+    LockQueue = &KeGetCurrentPrcb()->LockQueue[LockQueuePfnLock];
+    KeAcquireQueuedSpinLockAtDpcLevel(LockQueue);
+}
+
+FORCEINLINE
+VOID
+MiReleasePfnLockFromDpcLevel(VOID)
+{
+    PKSPIN_LOCK_QUEUE LockQueue;
+
+    LockQueue = &KeGetCurrentPrcb()->LockQueue[LockQueuePfnLock];
+    KeReleaseQueuedSpinLockFromDpcLevel(LockQueue);
+    ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
+}
+
 #define MI_ASSERT_PFN_LOCK_HELD() ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL)
 
 FORCEINLINE
diff --git a/ntoskrnl/mm/ARM3/pool.c b/ntoskrnl/mm/ARM3/pool.c
index b47ee2608e..7cebabe818 100644
--- a/ntoskrnl/mm/ARM3/pool.c
+++ b/ntoskrnl/mm/ARM3/pool.c
@@ -433,7 +433,6 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
     PMMPFN Pfn1;
     PVOID BaseVa, BaseVaStart;
     PMMFREE_POOL_ENTRY FreeEntry;
-    PKSPIN_LOCK_QUEUE LockQueue;
 
     //
     // Figure out how big the allocation is in pages
@@ -844,8 +843,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
     //
     // Lock the PFN database too
     //
-    LockQueue = &KeGetCurrentPrcb()->LockQueue[LockQueuePfnLock];
-    KeAcquireQueuedSpinLockAtDpcLevel(LockQueue);
+    MiAcquirePfnLockAtDpcLevel();
 
     //
     // Loop the pages
@@ -889,7 +887,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
     //
     // Release the PFN and nonpaged pool lock
     //
-    KeReleaseQueuedSpinLockFromDpcLevel(LockQueue);
+    MiReleasePfnLockFromDpcLevel();
     KeReleaseQueuedSpinLock(LockQueueMmNonPagedPoolLock, OldIrql);
 
     //

Reply via email to