From 01ec4e184fe9f03219104aaa355f08941994764e Mon Sep 17 00:00:00 2001 From: Gleb Surikov Date: Tue, 4 Aug 2026 00:07:27 +0300 Subject: [PATCH] [NTOS:EX] Document push lock list optimization state Rename the ExpOptimizePushLockList argument from OldValue to Initial Value to reflect that it's the lock avlue installed by the caller when setting Waking. Document and assert the required Locked,Waiting, and Waking state, and clarify that the routine either completes the waiter list links and clears Waking or enters the wakeup if the lock has been released. --- ntoskrnl/ex/pushlock.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/ntoskrnl/ex/pushlock.c b/ntoskrnl/ex/pushlock.c index ac78670f9e3..4436156f3b5 100644 --- a/ntoskrnl/ex/pushlock.c +++ b/ntoskrnl/ex/pushlock.c @@ -219,21 +219,30 @@ ExfWakePushLock(PEX_PUSH_LOCK PushLock, * @param PushLock * Pointer to a pushlock whose waiter list needs to be optimized. * - * @param OldValue - * Last known value of the pushlock before this routine was called. + * @param InitialValue + * Last known value of the pushlock installed by the caller when + * it inserted a new wait block and set the Waking bit. * * @return None. * - * @remarks At the end of the optimization, the pushlock will also be wakened. + * @remarks If the pushlock remains locked, this routine completes + * the wait block links and clears Waking. If the lock has + * been released, the pushlock will be wakened. * *--*/ VOID FASTCALL ExpOptimizePushLockList(PEX_PUSH_LOCK PushLock, - EX_PUSH_LOCK OldValue) + EX_PUSH_LOCK InitialValue) { PEX_PUSH_LOCK_WAIT_BLOCK WaitBlock, LastWaitBlock, PreviousWaitBlock, FirstWaitBlock; - EX_PUSH_LOCK NewValue; + EX_PUSH_LOCK OldValue, NewValue; + + ASSERT(InitialValue.Locked); + ASSERT(InitialValue.Waiting); + ASSERT(InitialValue.Waking); + + OldValue = InitialValue; /* Start main loop */ for (;;)