mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[RTL]: Correctly read PEB or Kernel Variables for Heap Tuning.
[NTOSKRNL]: MmCreatePeb should correctly fill out the Heap PEB parameters. [NTOSKRNL]: MmInitSystem and mminit.c should correctly initialize and hold the Heap Tuning Parameters. [NTOSKRNL]: CmControlVector should read the registry Heap Tuning Parameters into the real Mm variables, instaed of "Dummy". This removes heap hacks and makes Windows NTDLL happy. svn path=/trunk/; revision=59857
This commit is contained in:
parent
c268c87586
commit
4ca622a65d
8 changed files with 84 additions and 37 deletions
|
@ -174,6 +174,22 @@ CHECK_PAGED_CODE_RTL(char *file, int line)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
RtlpSetHeapParameters(IN PRTL_HEAP_PARAMETERS Parameters)
|
||||||
|
{
|
||||||
|
PPEB Peb;
|
||||||
|
|
||||||
|
/* Get PEB */
|
||||||
|
Peb = RtlGetCurrentPeb();
|
||||||
|
|
||||||
|
/* Apply defaults for non-set parameters */
|
||||||
|
if (!Parameters->SegmentCommit) Parameters->SegmentCommit = Peb->HeapSegmentCommit;
|
||||||
|
if (!Parameters->SegmentReserve) Parameters->SegmentReserve = Peb->HeapSegmentReserve;
|
||||||
|
if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = Peb->HeapDeCommitFreeBlockThreshold;
|
||||||
|
if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = Peb->HeapDeCommitTotalFreeThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlpHandleDpcStackException(IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
|
RtlpHandleDpcStackException(IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
|
||||||
|
|
|
@ -1223,7 +1223,6 @@ RtlCreateHeap(ULONG Flags,
|
||||||
PVOID CommittedAddress = NULL, UncommittedAddress = NULL;
|
PVOID CommittedAddress = NULL, UncommittedAddress = NULL;
|
||||||
PHEAP Heap = NULL;
|
PHEAP Heap = NULL;
|
||||||
RTL_HEAP_PARAMETERS SafeParams = {0};
|
RTL_HEAP_PARAMETERS SafeParams = {0};
|
||||||
PPEB Peb;
|
|
||||||
ULONG_PTR MaximumUserModeAddress;
|
ULONG_PTR MaximumUserModeAddress;
|
||||||
SYSTEM_BASIC_INFORMATION SystemInformation;
|
SYSTEM_BASIC_INFORMATION SystemInformation;
|
||||||
MEMORY_BASIC_INFORMATION MemoryInfo;
|
MEMORY_BASIC_INFORMATION MemoryInfo;
|
||||||
|
@ -1276,32 +1275,10 @@ RtlCreateHeap(ULONG Flags,
|
||||||
|
|
||||||
if (NtGlobalFlags & FLG_USER_STACK_TRACE_DB)
|
if (NtGlobalFlags & FLG_USER_STACK_TRACE_DB)
|
||||||
Flags |= HEAP_CAPTURE_STACK_BACKTRACES;
|
Flags |= HEAP_CAPTURE_STACK_BACKTRACES;
|
||||||
|
|
||||||
/* Get PEB */
|
|
||||||
Peb = RtlGetCurrentPeb();
|
|
||||||
|
|
||||||
/* Apply defaults for non-set parameters */
|
|
||||||
if (!Parameters->SegmentCommit) Parameters->SegmentCommit = Peb->HeapSegmentCommit;
|
|
||||||
if (!Parameters->SegmentReserve) Parameters->SegmentReserve = Peb->HeapSegmentReserve;
|
|
||||||
if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = Peb->HeapDeCommitFreeBlockThreshold;
|
|
||||||
if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = Peb->HeapDeCommitTotalFreeThreshold;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Apply defaults for non-set parameters */
|
|
||||||
#if 0
|
|
||||||
if (!Parameters->SegmentCommit) Parameters->SegmentCommit = MmHeapSegmentCommit;
|
|
||||||
if (!Parameters->SegmentReserve) Parameters->SegmentReserve = MmHeapSegmentReserve;
|
|
||||||
if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = MmHeapDeCommitFreeBlockThreshold;
|
|
||||||
if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = MmHeapDeCommitTotalFreeThreshold;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Move to memory manager
|
/* Set tunable parameters */
|
||||||
if (!Parameters->SegmentCommit) Parameters->SegmentCommit = PAGE_SIZE * 2;
|
RtlpSetHeapParameters(Parameters);
|
||||||
if (!Parameters->SegmentReserve) Parameters->SegmentReserve = 1048576;
|
|
||||||
if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = PAGE_SIZE;
|
|
||||||
if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = 65536;
|
|
||||||
|
|
||||||
/* Get the max um address */
|
/* Get the max um address */
|
||||||
Status = ZwQuerySystemInformation(SystemBasicInformation,
|
Status = ZwQuerySystemInformation(SystemBasicInformation,
|
||||||
|
|
|
@ -50,6 +50,10 @@ PEXCEPTION_REGISTRATION_RECORD
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlpGetExceptionList(VOID);
|
RtlpGetExceptionList(VOID);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
RtlpSetHeapParameters(IN PRTL_HEAP_PARAMETERS Parameters);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlpSetExceptionList(PEXCEPTION_REGISTRATION_RECORD NewExceptionList);
|
RtlpSetExceptionList(PEXCEPTION_REGISTRATION_RECORD NewExceptionList);
|
||||||
|
|
|
@ -522,6 +522,14 @@ INIT_FUNCTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
L"Session Manager\\Memory Management",
|
||||||
|
L"MinimumStackCommitInBytes",
|
||||||
|
&MmMinimumStackCommitInBytes,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
L"Session Manager\\Executive",
|
L"Session Manager\\Executive",
|
||||||
L"AdditionalCriticalWorkerThreads",
|
L"AdditionalCriticalWorkerThreads",
|
||||||
|
@ -613,7 +621,7 @@ INIT_FUNCTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
|
||||||
{
|
{
|
||||||
L"Session Manager",
|
L"Session Manager",
|
||||||
L"CriticalSectionTimeout",
|
L"CriticalSectionTimeout",
|
||||||
&DummyData,
|
&MmCritsectTimeoutSeconds,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
@ -621,15 +629,14 @@ INIT_FUNCTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
|
||||||
{
|
{
|
||||||
L"Session Manager",
|
L"Session Manager",
|
||||||
L"HeapSegmentReserve",
|
L"HeapSegmentReserve",
|
||||||
&DummyData,
|
&MmHeapSegmentReserve,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
L"Session Manager",
|
L"Session Manager",
|
||||||
L"HeapSegmentCommit",
|
L"HeapSegmentCommit",
|
||||||
&DummyData,
|
&MmHeapSegmentCommit,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
@ -637,7 +644,7 @@ INIT_FUNCTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
|
||||||
{
|
{
|
||||||
L"Session Manager",
|
L"Session Manager",
|
||||||
L"HeapDeCommitTotalFreeThreshold",
|
L"HeapDeCommitTotalFreeThreshold",
|
||||||
&DummyData,
|
&MmHeapDeCommitTotalFreeThreshold,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
@ -645,7 +652,7 @@ INIT_FUNCTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
|
||||||
{
|
{
|
||||||
L"Session Manager",
|
L"Session Manager",
|
||||||
L"HeapDeCommitFreeBlockThreshold",
|
L"HeapDeCommitFreeBlockThreshold",
|
||||||
&DummyData,
|
&MmHeapDeCommitFreeBlockThreshold,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
|
|
@ -680,11 +680,13 @@ extern PFN_NUMBER MiLowNonPagedPoolThreshold;
|
||||||
extern PFN_NUMBER MiHighNonPagedPoolThreshold;
|
extern PFN_NUMBER MiHighNonPagedPoolThreshold;
|
||||||
extern PFN_NUMBER MmMinimumFreePages;
|
extern PFN_NUMBER MmMinimumFreePages;
|
||||||
extern PFN_NUMBER MmPlentyFreePages;
|
extern PFN_NUMBER MmPlentyFreePages;
|
||||||
|
extern SIZE_T MmMinimumStackCommitInBytes;
|
||||||
extern PFN_COUNT MiExpansionPoolPagesInitialCharge;
|
extern PFN_COUNT MiExpansionPoolPagesInitialCharge;
|
||||||
extern PFN_NUMBER MmResidentAvailablePages;
|
extern PFN_NUMBER MmResidentAvailablePages;
|
||||||
extern PFN_NUMBER MmResidentAvailableAtInit;
|
extern PFN_NUMBER MmResidentAvailableAtInit;
|
||||||
extern ULONG MmTotalFreeSystemPtes[MaximumPtePoolTypes];
|
extern ULONG MmTotalFreeSystemPtes[MaximumPtePoolTypes];
|
||||||
extern PFN_NUMBER MmTotalSystemDriverPages;
|
extern PFN_NUMBER MmTotalSystemDriverPages;
|
||||||
|
extern ULONG MmCritsectTimeoutSeconds;
|
||||||
extern PVOID MiSessionImageStart;
|
extern PVOID MiSessionImageStart;
|
||||||
extern PVOID MiSessionImageEnd;
|
extern PVOID MiSessionImageEnd;
|
||||||
extern PMMPTE MiHighestUserPte;
|
extern PMMPTE MiHighestUserPte;
|
||||||
|
|
|
@ -359,6 +359,16 @@ SIZE_T MmAllocationFragment;
|
||||||
SIZE_T MmTotalCommitLimit;
|
SIZE_T MmTotalCommitLimit;
|
||||||
SIZE_T MmTotalCommitLimitMaximum;
|
SIZE_T MmTotalCommitLimitMaximum;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These value tune certain user parameters. They have default values set here,
|
||||||
|
* as well as in the code, and can be overwritten by registry settings.
|
||||||
|
*/
|
||||||
|
SIZE_T MmHeapSegmentReserve = 1 * _1MB;
|
||||||
|
SIZE_T MmHeapSegmentCommit = 2 * PAGE_SIZE;
|
||||||
|
SIZE_T MmHeapDeCommitTotalFreeThreshold = 64 * _1KB;
|
||||||
|
SIZE_T MmHeapDeCommitFreeBlockThreshold = PAGE_SIZE;
|
||||||
|
SIZE_T MmMinimumStackCommitInBytes = 0;
|
||||||
|
|
||||||
/* Internal setting used for debugging memory descriptors */
|
/* Internal setting used for debugging memory descriptors */
|
||||||
BOOLEAN MiDbgEnableMdDump =
|
BOOLEAN MiDbgEnableMdDump =
|
||||||
#ifdef _ARM_
|
#ifdef _ARM_
|
||||||
|
@ -2176,6 +2186,27 @@ MmArmInitSystem(IN ULONG Phase,
|
||||||
DPRINT("System PTE count has been tuned to %d (%d bytes)\n",
|
DPRINT("System PTE count has been tuned to %d (%d bytes)\n",
|
||||||
MmNumberOfSystemPtes, MmNumberOfSystemPtes * PAGE_SIZE);
|
MmNumberOfSystemPtes, MmNumberOfSystemPtes * PAGE_SIZE);
|
||||||
|
|
||||||
|
/* Check if no values are set for the heap limits */
|
||||||
|
if (MmHeapSegmentReserve == 0)
|
||||||
|
{
|
||||||
|
MmHeapSegmentReserve = 2 * _1MB;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MmHeapSegmentCommit == 0)
|
||||||
|
{
|
||||||
|
MmHeapSegmentCommit = 2 * PAGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MmHeapDeCommitTotalFreeThreshold == 0)
|
||||||
|
{
|
||||||
|
MmHeapDeCommitTotalFreeThreshold = 64 * _1KB;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MmHeapDeCommitFreeBlockThreshold == 0)
|
||||||
|
{
|
||||||
|
MmHeapDeCommitFreeBlockThreshold = PAGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize the working set lock */
|
/* Initialize the working set lock */
|
||||||
ExInitializePushLock(&MmSystemCacheWs.WorkingSetMutex);
|
ExInitializePushLock(&MmSystemCacheWs.WorkingSetMutex);
|
||||||
|
|
||||||
|
|
|
@ -687,13 +687,12 @@ MmCreatePeb(IN PEPROCESS Process,
|
||||||
Peb->NumberOfProcessors = KeNumberProcessors;
|
Peb->NumberOfProcessors = KeNumberProcessors;
|
||||||
Peb->BeingDebugged = (BOOLEAN)(Process->DebugPort != NULL);
|
Peb->BeingDebugged = (BOOLEAN)(Process->DebugPort != NULL);
|
||||||
Peb->NtGlobalFlag = NtGlobalFlag;
|
Peb->NtGlobalFlag = NtGlobalFlag;
|
||||||
/*Peb->HeapSegmentReserve = MmHeapSegmentReserve;
|
Peb->HeapSegmentReserve = MmHeapSegmentReserve;
|
||||||
Peb->HeapSegmentCommit = MmHeapSegmentCommit;
|
Peb->HeapSegmentCommit = MmHeapSegmentCommit;
|
||||||
Peb->HeapDeCommitTotalFreeThreshold = MmHeapDeCommitTotalFreeThreshold;
|
Peb->HeapDeCommitTotalFreeThreshold = MmHeapDeCommitTotalFreeThreshold;
|
||||||
Peb->HeapDeCommitFreeBlockThreshold = MmHeapDeCommitFreeBlockThreshold;*/
|
Peb->HeapDeCommitFreeBlockThreshold = MmHeapDeCommitFreeBlockThreshold;
|
||||||
Peb->CriticalSectionTimeout = MmCriticalSectionTimeout;
|
Peb->CriticalSectionTimeout = MmCriticalSectionTimeout;
|
||||||
/*Peb->MinimumStackCommit = MmMinimumStackCommitInBytes;
|
Peb->MinimumStackCommit = MmMinimumStackCommitInBytes;
|
||||||
*/
|
|
||||||
Peb->MaximumNumberOfHeaps = (PAGE_SIZE - sizeof(PEB)) / sizeof(PVOID);
|
Peb->MaximumNumberOfHeaps = (PAGE_SIZE - sizeof(PEB)) / sizeof(PVOID);
|
||||||
Peb->ProcessHeaps = (PVOID*)(Peb + 1);
|
Peb->ProcessHeaps = (PVOID*)(Peb + 1);
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,17 @@ CHECK_PAGED_CODE_RTL(char *file, int line)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
RtlpSetHeapParameters(IN PRTL_HEAP_PARAMETERS Parameters)
|
||||||
|
{
|
||||||
|
/* Apply defaults for non-set parameters */
|
||||||
|
if (!Parameters->SegmentCommit) Parameters->SegmentCommit = MmHeapSegmentCommit;
|
||||||
|
if (!Parameters->SegmentReserve) Parameters->SegmentReserve = MmHeapSegmentReserve;
|
||||||
|
if (!Parameters->DeCommitFreeBlockThreshold) Parameters->DeCommitFreeBlockThreshold = MmHeapDeCommitFreeBlockThreshold;
|
||||||
|
if (!Parameters->DeCommitTotalFreeThreshold) Parameters->DeCommitTotalFreeThreshold = MmHeapDeCommitTotalFreeThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlpCheckLogException(IN PEXCEPTION_RECORD ExceptionRecord,
|
RtlpCheckLogException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
|
|
Loading…
Reference in a new issue