- Define a new consumer: MC_SYSTEM:

- Right now, it is only used for allocating new page tables for kernel-mode mappings.
  - This consumer's pages are never zeroed automatically (this is a more endemic ReactOS problem -- kernel pages are zeroed when they shouldn't be).
    - New page tables, however, should indeed be zeroed, so now they are zeroed manually with RtlZeroMemory.
    - The page zero function is not called anymore, and a useless zero-space hyperspace mapping is thus saved each time this happens.
    - Because of this, zero-space hyperspace mappings are required much later in the Memory Manager's initialization steps than before.

svn path=/trunk/; revision=41508
This commit is contained in:
ReactOS Portable Systems Group 2009-06-21 05:33:48 +00:00
parent 7afb3ea904
commit ec3307ef64
3 changed files with 8 additions and 4 deletions

View file

@ -102,7 +102,8 @@ typedef ULONG PFN_TYPE, *PPFN_TYPE;
#define MC_USER (1) #define MC_USER (1)
#define MC_PPOOL (2) #define MC_PPOOL (2)
#define MC_NPPOOL (3) #define MC_NPPOOL (3)
#define MC_MAXIMUM (4) #define MC_SYSTEM (4)
#define MC_MAXIMUM (5)
#define PAGED_POOL_MASK 1 #define PAGED_POOL_MASK 1
#define MUST_SUCCEED_POOL_MASK 2 #define MUST_SUCCEED_POOL_MASK 2

View file

@ -777,7 +777,7 @@ MmAllocPage(ULONG Consumer, SWAPENTRY SwapEntry)
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql); KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
PfnOffset = PageDescriptor - MmPfnDatabase; PfnOffset = PageDescriptor - MmPfnDatabase;
if (NeedClear) if ((NeedClear) && (Consumer != MC_SYSTEM))
{ {
MiZeroPage(PfnOffset); MiZeroPage(PfnOffset);
} }

View file

@ -310,7 +310,7 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
{ {
return NULL; return NULL;
} }
Status = MmRequestPageMemoryConsumer(MC_NPPOOL, FALSE, &Pfn); Status = MmRequestPageMemoryConsumer(MC_SYSTEM, FALSE, &Pfn);
if (!NT_SUCCESS(Status) || Pfn == 0) if (!NT_SUCCESS(Status) || Pfn == 0)
{ {
KeBugCheck(MEMORY_MANAGEMENT); KeBugCheck(MEMORY_MANAGEMENT);
@ -322,8 +322,11 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
} }
if(0 != InterlockedCompareExchangePte(&MmGlobalKernelPageDirectory[PdeOffset], Entry, 0)) if(0 != InterlockedCompareExchangePte(&MmGlobalKernelPageDirectory[PdeOffset], Entry, 0))
{ {
MmReleasePageMemoryConsumer(MC_NPPOOL, Pfn); MmReleasePageMemoryConsumer(MC_SYSTEM, Pfn);
} }
InterlockedExchangePte(PageDir, MmGlobalKernelPageDirectory[PdeOffset]);
RtlZeroMemory(MiPteToAddress(PageDir), PAGE_SIZE);
return (PULONG)MiAddressToPte(Address);
} }
InterlockedExchangePte(PageDir, MmGlobalKernelPageDirectory[PdeOffset]); InterlockedExchangePte(PageDir, MmGlobalKernelPageDirectory[PdeOffset]);
} }