Author: sir_richard
Date: Sat Jan 23 22:27:26 2010
New Revision: 45217
URL:
http://svn.reactos.org/svn/reactos?rev=45217&view=rev
Log:
[PERF]: Replace early ZwClose system calls with ObCloseHandle(KernelMode). This avoids
taking a system call for those cases and gives a slight perf boost to booting up the
system. It also pushes the first system call somewhat later in the boot process, allowing
for easier debugging should the interface have issues/need tracing.
[NTOS]: Do not attempt querying the Registry Primary Handle for the Backing Hive File Size
in the case where there is no actual Primary! There was no error checking so nobody
noticed this happens -- it also probably resets Cluster to 0 (instead of 1), which can
cause corruption in some cases.
[NTOS]: Make KiUserTrap use the MODE_MASK instead of hard-coding a check for Ring 0 CS
(which is slower and not as correct).
Modified:
trunk/reactos/ntoskrnl/config/cminit.c
trunk/reactos/ntoskrnl/ex/init.c
trunk/reactos/ntoskrnl/ex/work.c
trunk/reactos/ntoskrnl/include/internal/trap_x.h
trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
trunk/reactos/ntoskrnl/ps/psmgr.c
Modified: trunk/reactos/ntoskrnl/config/cminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cminit.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cminit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cminit.c [iso-8859-1] Sat Jan 23 22:27:26 2010
@@ -163,13 +163,17 @@
/* Set flags */
Hive->Flags = HiveFlags;
- /* Check how large the file is */
- ZwQueryInformationFile(Primary,
- &IoStatusBlock,
- &FileInformation,
- sizeof(FileInformation),
- FileStandardInformation);
- Cluster = FileInformation.EndOfFile.LowPart;
+ /* Check if this is a primary */
+ if (Primary)
+ {
+ /* Check how large the file is */
+ ZwQueryInformationFile(Primary,
+ &IoStatusBlock,
+ &FileInformation,
+ sizeof(FileInformation),
+ FileStandardInformation);
+ Cluster = FileInformation.EndOfFile.LowPart;
+ }
/* Initialize it */
Status = HvInitialize(&Hive->Hive,
Modified: trunk/reactos/ntoskrnl/ex/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=452…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] Sat Jan 23 22:27:26 2010
@@ -303,7 +303,7 @@
KernelMode,
&ExpNlsSectionPointer,
NULL);
- ZwClose(NlsSection);
+ ObCloseHandle(NlsSection, KernelMode);
if (!NT_SUCCESS(Status))
{
/* Failed */
Modified: trunk/reactos/ntoskrnl/ex/work.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/work.c?rev=452…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/work.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/work.c [iso-8859-1] Sat Jan 23 22:27:26 2010
@@ -310,7 +310,7 @@
/* Dereference and close handle */
ObDereferenceObject(Thread);
- ZwClose(hThread);
+ ObCloseHandle(hThread, KernelMode);
}
/*++
@@ -586,7 +586,7 @@
ExpWorkerThreadBalanceManagerPtr = Thread;
/* Close the handle and return */
- ZwClose(ThreadHandle);
+ ObCloseHandle(ThreadHandle, KernelMode);
}
/* PUBLIC FUNCTIONS **********************************************************/
Modified: trunk/reactos/ntoskrnl/include/internal/trap_x.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] Sat Jan 23 22:27:26
2010
@@ -165,7 +165,7 @@
KiUserTrap(IN PKTRAP_FRAME TrapFrame)
{
/* Anything else but Ring 0 is Ring 3 */
- return (TrapFrame->SegCs != KGDT_R0_CODE);
+ return (TrapFrame->SegCs & MODE_MASK);
}
BOOLEAN
Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Sat Jan 23 22:27:26 2010
@@ -466,7 +466,7 @@
NULL,
TrapFrame,
TrapFrame->EFlags & EFLAGS_V86_MASK ?
- -1 : TrapFrame->SegCs & MODE_MASK,
+ -1 : KiUserTrap(TrapFrame),
TRUE);
/* Return from this trap */
Modified: trunk/reactos/ntoskrnl/ps/psmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/psmgr.c?rev=45…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/psmgr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/psmgr.c [iso-8859-1] Sat Jan 23 22:27:26 2010
@@ -586,7 +586,7 @@
KernelMode,
(PVOID*)&SysThread,
NULL);
- ZwClose(SysThreadHandle);
+ ObCloseHandle(SysThreadHandle, KernelMode);
SysThreadCreated = TRUE;
/* Return success */