diff --git a/ntoskrnl/mm/ARM3/zeropage.c b/ntoskrnl/mm/ARM3/zeropage.c index 4b0b9cbe64..3bf1cc0fef 100644 --- a/ntoskrnl/mm/ARM3/zeropage.c +++ b/ntoskrnl/mm/ARM3/zeropage.c @@ -43,6 +43,9 @@ MmZeroPageThread(VOID) PVOID ZeroAddress; PFN_NUMBER PageIndex, FreePage; PMMPFN Pfn1; + LARGE_INTEGER StartCounter, EndCounter, Frequency; + ULONG PageCount; + KFLOATING_SAVE FloatingSave; /* Get the discardable sections to free them */ MiFindInitializationCode(&StartAddress, &EndAddress); @@ -67,9 +70,15 @@ MmZeroPageThread(VOID) FALSE, NULL, NULL); + + KeEnterGuardedRegion(); + KeSaveFloatingPointState(&FloatingSave); + OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); MmZeroingPageThreadActive = TRUE; + PageCount = 0; + StartCounter = KeQueryPerformanceCounter(NULL); while (TRUE) { if (!MmFreePageListHead.Total) @@ -101,13 +110,51 @@ MmZeroPageThread(VOID) ZeroAddress = MiMapPagesInZeroSpace(Pfn1, 1); ASSERT(ZeroAddress); - RtlZeroMemory(ZeroAddress, PAGE_SIZE); + //RtlZeroMemory(ZeroAddress, PAGE_SIZE); +#ifdef _MSC_VER + __asm + { + mov edi, ZeroAddress + mov ecx, PAGE_SIZE / 16 + pxor xmm0, xmm0 + l: + movntdq [edi], xmm0 + add edi, 16 + dec ecx + jnz l + } +#else + asm ( + "pxor %%xmm0, %%xmm0\n\t" + "l:\n\t" + "movntdq %%xmm0, (%[dest])\n\t" + "addl $16, %[dest]\n\t" + "decl %[count]\n\t" + "jnz l\n\t" + : + : [dest] "r" (ZeroAddress), + [count] "r" (PAGE_SIZE / 16) + /* : "xmm0" */ + ); +#endif MiUnmapPagesInZeroSpace(ZeroAddress, 1); + PageCount++; OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); MiInsertPageInList(&MmZeroedPageListHead, PageIndex); } + if (PageCount > 16) + { + EndCounter = KeQueryPerformanceCounter(&Frequency); + EndCounter.QuadPart -= StartCounter.QuadPart; + EndCounter.QuadPart *= 1000000000; + EndCounter.QuadPart /= Frequency.QuadPart; + DPRINT1("Zeroed %lu pages (%lu MB) in %I64u ns @ %I64u ns/page (total)\n", PageCount, PageCount / (1024 * 1024 / PAGE_SIZE), EndCounter.QuadPart, EndCounter.QuadPart / PageCount); + } + + KeRestoreFloatingPointState(&FloatingSave); + KeLeaveGuardedRegion(); } }