[NTOS:KE] Also rewrite KeZeroPages in assembly for amd64

Let's stick with "rep movsq" until we are able to have more precise benchmarks
This commit is contained in:
Jérôme Gardou 2021-06-25 10:24:04 +02:00 committed by Jérôme Gardou
parent 51258295bd
commit 42bec35f65
3 changed files with 47 additions and 11 deletions

View file

@ -88,16 +88,6 @@ KiDpcInterruptHandler(VOID)
KeLowerIrql(OldIrql); KeLowerIrql(OldIrql);
} }
VOID
FASTCALL
KeZeroPages(IN PVOID Address,
IN ULONG Size)
{
/* Not using XMMI in this routine */
RtlZeroMemory(Address, Size);
}
PVOID PVOID
KiSwitchKernelStackHelper( KiSwitchKernelStackHelper(
LONG_PTR StackOffset, LONG_PTR StackOffset,

View file

@ -0,0 +1,45 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Fast zeroing of pages
* COPYRIGHT: Copyright 2021 Jérôme Gardou <jerome.gardou@reactos.org>
*/
#include <asm.inc>
/* FUNCTIONS ****************************************************************/
.code
/* Benchmarking from Timo on some AMD machine:
rep movsq : 128
movaps 175
movnti 620
movntdq: 620
movntps: 620
MS KeZeroPages (movnti unrolled): 883
MS KeZeroSinglePage (mov): 346
whole discussion in https://github.com/reactos/reactos/pull/3765
We stick with rep stosq.
*/
/*
* VOID
* KeZeroPages(PVOID Ptr, ULONG Size);
*/
PUBLIC KeZeroPages
FUNC KeZeroPages
push rdi
.PUSHREG rdi
.ENDPROLOG
mov rdi, rcx
mov ecx, edx
shr ecx, 3
xor rax, rax
rep stosq
pop rdi
ret
ENDFUNC
END

View file

@ -328,7 +328,8 @@ elseif(ARCH STREQUAL "amd64")
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/boot.S ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/boot.S
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/ctxswitch.S ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/ctxswitch.S
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/trap.S ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/trap.S
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/usercall_asm.S) ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/usercall_asm.S
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/amd64/zeropage.S)
list(APPEND SOURCE list(APPEND SOURCE
${REACTOS_SOURCE_DIR}/ntoskrnl/config/i386/cmhardwr.c ${REACTOS_SOURCE_DIR}/ntoskrnl/config/i386/cmhardwr.c
${REACTOS_SOURCE_DIR}/ntoskrnl/mm/i386/page.c ${REACTOS_SOURCE_DIR}/ntoskrnl/mm/i386/page.c