https://git.reactos.org/?p=reactos.git;a=commitdiff;h=477792856e42be09b12fd3...
commit 477792856e42be09b12fd3e3ce557657c6cc63c2 Author: Timo Kreuzer timo.kreuzer@reactos.org AuthorDate: Sat Apr 1 19:18:45 2023 +0300 Commit: Timo Kreuzer timo.kreuzer@reactos.org CommitDate: Sat Jul 29 14:00:44 2023 +0300
[NTOS:Mm] Replace YieldProcessor() with KeDelayExecutionThread()
These are used in the paging path, when the page is currently in the process of being read from or written to the disk. While YieldProcessor() provides the chance to switch context to the other paging thread, it only does so, once the current thread's quantum has expired. On a single CPU system this effectively leads to busy waiting for the rest of the quantum. On SMP systems this could succeed earlier, thus reducing latency, but it would still contribute to high CPU usage, while wait [...] Using KeDelayExecutionThread() will instantly allow another thread to run, providing enough time to complete the IO operation. --- ntoskrnl/mm/section.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 49c0e0e8f4f..33584a02230 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1477,7 +1477,7 @@ MmAlterViewAttributes(PMMSUPPORT AddressSpace, break; MmUnlockSectionSegment(Segment); MmUnlockAddressSpace(AddressSpace); - YieldProcessor(); + KeDelayExecutionThread(KernelMode, FALSE, &TinyTime); MmLockAddressSpace(AddressSpace); MmLockSectionSegment(Segment); } @@ -1608,7 +1608,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, if (SwapEntry == MM_WAIT_ENTRY) { MmUnlockAddressSpace(AddressSpace); - YieldProcessor(); + KeDelayExecutionThread(KernelMode, FALSE, &TinyTime); MmLockAddressSpace(AddressSpace); return STATUS_MM_RESTART_OPERATION; } @@ -1789,7 +1789,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, { MmUnlockSectionSegment(Segment); MmUnlockAddressSpace(AddressSpace); - YieldProcessor(); + KeDelayExecutionThread(KernelMode, FALSE, &TinyTime); MmLockAddressSpace(AddressSpace); return STATUS_MM_RESTART_OPERATION; } @@ -3442,7 +3442,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, MmUnlockSectionSegment(Segment); MmUnlockAddressSpace(AddressSpace);
- YieldProcessor(); + KeDelayExecutionThread(KernelMode, FALSE, &TinyTime);
MmLockAddressSpace(AddressSpace); MmLockSectionSegment(Segment); @@ -5202,7 +5202,7 @@ MmMakePagesDirty( { MmUnlockSectionSegment(Segment); MmUnlockAddressSpace(AddressSpace); - YieldProcessor(); + KeDelayExecutionThread(KernelMode, FALSE, &TinyTime); MmLockAddressSpace(AddressSpace); MmLockSectionSegment(Segment); Entry = MmGetPageEntrySectionSegment(Segment, &SegmentOffset);