mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 18:01:07 +00:00
[NTOS]: Add page-tracking macro calls wherever needed. MI_TRACE_PFNS is still off, though, so this code won't be called.
svn path=/trunk/; revision=49444
This commit is contained in:
parent
5f9569d3c5
commit
ee45da75e0
|
@ -41,6 +41,8 @@ CcInitCacheZeroPage(VOID)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
MI_SET_USAGE(MI_USAGE_CACHE);
|
||||
//MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
|
||||
Status = MmRequestPageMemoryConsumer(MC_SYSTEM, TRUE, &CcZeroPage);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
|
|
@ -703,6 +703,18 @@ CcRosCreateCacheSegment(PBCB Bcb,
|
|||
#endif
|
||||
|
||||
/* Create a virtual mapping for this memory area */
|
||||
MI_SET_USAGE(MI_USAGE_CACHE);
|
||||
#if MI_TRACE_PFNS
|
||||
PWCHAR pos = NULL;
|
||||
ULONG len = 0;
|
||||
if ((Bcb->FileObject) && (Bcb->FileObject->FileName.Buffer))
|
||||
{
|
||||
pos = wcsrchr(Bcb->FileObject->FileName.Buffer, '\\');
|
||||
len = wcslen(pos) * sizeof(WCHAR);
|
||||
if (pos) snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
MmMapMemoryArea(current->BaseAddress, Bcb->CacheSegmentSize,
|
||||
MC_CACHE, PAGE_READWRITE);
|
||||
|
||||
|
|
|
@ -130,6 +130,8 @@ MiFindContiguousPages(IN PFN_NUMBER LowestPfn,
|
|||
//
|
||||
// This PFN is now a used page, set it up
|
||||
//
|
||||
MI_SET_USAGE(MI_USAGE_CONTINOUS_ALLOCATION);
|
||||
MI_SET_PROCESS2("Kernel Driver");
|
||||
MiUnlinkFreeOrZeroedPage(Pfn1);
|
||||
Pfn1->u3.e2.ReferenceCount = 1;
|
||||
Pfn1->u2.ShareCount = 1;
|
||||
|
|
|
@ -531,6 +531,8 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||
|
||||
/* Allocate a page for hyperspace and create it */
|
||||
MI_SET_USAGE(MI_USAGE_PAGE_TABLE);
|
||||
MI_SET_PROCESS2("Kernel");
|
||||
PageFrameIndex = MiRemoveAnyPage(0);
|
||||
TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
|
||||
TempPde.u.Hard.Global = FALSE; // Hyperspace is local!
|
||||
|
|
|
@ -678,6 +678,10 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
Pfn1->u3.e2.ReferenceCount = 1;
|
||||
Pfn1->u3.e1.PageLocation = ActiveAndValid;
|
||||
Pfn1->u3.e1.CacheAttribute = MiNonCached;
|
||||
#if MI_TRACE_PFNS
|
||||
Pfn1->PfnUsage = MI_USAGE_INIT_MEMORY;
|
||||
memcpy(Pfn1->ProcessName, "Initial PDE", 16);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -721,6 +725,10 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
Pfn2->u3.e2.ReferenceCount = 1;
|
||||
Pfn2->u3.e1.PageLocation = ActiveAndValid;
|
||||
Pfn2->u3.e1.CacheAttribute = MiNonCached;
|
||||
#if MI_TRACE_PFNS
|
||||
Pfn2->PfnUsage = MI_USAGE_INIT_MEMORY;
|
||||
memcpy(Pfn1->ProcessName, "Initial PTE", 16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -876,6 +884,9 @@ MiBuildPfnDatabaseFromLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
Pfn1->u3.e2.ReferenceCount = 1;
|
||||
Pfn1->u3.e1.PageLocation = ActiveAndValid;
|
||||
Pfn1->u3.e1.CacheAttribute = MiNonCached;
|
||||
#if MI_TRACE_PFNS
|
||||
Pfn1->PfnUsage = MI_USAGE_BOOT_DRIVER;
|
||||
#endif
|
||||
|
||||
/* Check for RAM disk page */
|
||||
if (MdBlock->MemoryType == LoaderXIPRom)
|
||||
|
@ -923,6 +934,9 @@ MiBuildPfnDatabaseSelf(VOID)
|
|||
Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber);
|
||||
Pfn1->u2.ShareCount = 1;
|
||||
Pfn1->u3.e2.ReferenceCount = 1;
|
||||
#if MI_TRACE_PFNS
|
||||
Pfn1->PfnUsage = MI_USAGE_PFN_DATABASE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Next */
|
||||
|
@ -1222,17 +1236,46 @@ MmDumpArmPfnDatabase(IN BOOLEAN StatusOnly)
|
|||
PCHAR Consumer = "Unknown";
|
||||
KIRQL OldIrql;
|
||||
ULONG ActivePages = 0, FreePages = 0, OtherPages = 0;
|
||||
|
||||
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
ULONG UsageBucket[MI_USAGE_FREE_PAGE + 1] = {0};
|
||||
PCHAR MI_USAGE_TEXT[MI_USAGE_FREE_PAGE + 1] =
|
||||
{
|
||||
"Not set",
|
||||
"Paged Pool",
|
||||
"Nonpaged Pool",
|
||||
"Nonpaged Pool Ex",
|
||||
"Kernel Stack",
|
||||
"Kernel Stack Ex",
|
||||
"System PTE",
|
||||
"VAD",
|
||||
"PEB/TEB",
|
||||
"Section",
|
||||
"Page Table",
|
||||
"Page Directory",
|
||||
"Old Page Table",
|
||||
"Driver Page",
|
||||
"Contiguous Alloc",
|
||||
"MDL",
|
||||
"Demand Zero",
|
||||
"Zero Loop",
|
||||
"Cache",
|
||||
"PFN Database",
|
||||
"Boot Driver",
|
||||
"Initial Memory",
|
||||
"Free Page"
|
||||
};
|
||||
#endif
|
||||
//
|
||||
// Loop the PFN database
|
||||
//
|
||||
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
||||
for (i = 0; i <= MmHighestPhysicalPage; i++)
|
||||
{
|
||||
Pfn1 = MiGetPfnEntry(i);
|
||||
if (!Pfn1) continue;
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
ASSERT(Pfn1->PfnUsage <= MI_USAGE_FREE_PAGE);
|
||||
#endif
|
||||
//
|
||||
// Get the page location
|
||||
//
|
||||
|
@ -1243,12 +1286,18 @@ MmDumpArmPfnDatabase(IN BOOLEAN StatusOnly)
|
|||
Consumer = "Active and Valid";
|
||||
ActivePages++;
|
||||
break;
|
||||
|
||||
|
||||
case ZeroedPageList:
|
||||
|
||||
Consumer = "Zero Page List";
|
||||
FreePages++;
|
||||
break;//continue;
|
||||
|
||||
case FreePageList:
|
||||
|
||||
Consumer = "Free Page List";
|
||||
FreePages++;
|
||||
break;
|
||||
break;//continue;
|
||||
|
||||
default:
|
||||
|
||||
|
@ -1256,23 +1305,55 @@ MmDumpArmPfnDatabase(IN BOOLEAN StatusOnly)
|
|||
OtherPages++;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
/* Add into bucket */
|
||||
UsageBucket[Pfn1->PfnUsage]++;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Pretty-print the page
|
||||
//
|
||||
DbgPrint("0x%08p:\t%20s\t(%02d.%02d) [%08p-%08p])\n",
|
||||
if (!StatusOnly)
|
||||
DbgPrint("0x%08p:\t%20s\t(%04d.%04d)\t[%16s - %16s])\n",
|
||||
i << PAGE_SHIFT,
|
||||
Consumer,
|
||||
Pfn1->u3.e2.ReferenceCount,
|
||||
Pfn1->u2.ShareCount,
|
||||
Pfn1->PteAddress,
|
||||
Pfn1->u4.PteFrame);
|
||||
Pfn1->u2.ShareCount == LIST_HEAD ? 0xFFFF : Pfn1->u2.ShareCount,
|
||||
#if MI_TRACE_PFNS
|
||||
MI_USAGE_TEXT[Pfn1->PfnUsage],
|
||||
Pfn1->ProcessName);
|
||||
#else
|
||||
"Page tracking",
|
||||
"is disabled");
|
||||
#endif
|
||||
}
|
||||
|
||||
DbgPrint("Active: %d pages\t[%d KB]\n", ActivePages, (ActivePages << PAGE_SHIFT) / 1024);
|
||||
DbgPrint("Free: %d pages\t[%d KB]\n", FreePages, (FreePages << PAGE_SHIFT) / 1024);
|
||||
DbgPrint("Other: %d pages\t[%d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
|
||||
DbgPrint("Active: %5d pages\t[%6d KB]\n", ActivePages, (ActivePages << PAGE_SHIFT) / 1024);
|
||||
DbgPrint("Free: %5d pages\t[%6d KB]\n", FreePages, (FreePages << PAGE_SHIFT) / 1024);
|
||||
DbgPrint("-----------------------------------------\n");
|
||||
#if MI_TRACE_PFNS
|
||||
OtherPages = UsageBucket[MI_USAGE_BOOT_DRIVER];
|
||||
DbgPrint("Boot Images: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
OtherPages = UsageBucket[MI_USAGE_DRIVER_PAGE];
|
||||
DbgPrint("System Drivers: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
OtherPages = UsageBucket[MI_USAGE_PFN_DATABASE];
|
||||
DbgPrint("PFN Database: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
OtherPages = UsageBucket[MI_USAGE_PAGE_TABLE] + UsageBucket[MI_USAGE_LEGACY_PAGE_DIRECTORY];
|
||||
DbgPrint("Page Tables: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
OtherPages = UsageBucket[MI_USAGE_NONPAGED_POOL] + UsageBucket[MI_USAGE_NONPAGED_POOL_EXPANSION];
|
||||
DbgPrint("NonPaged Pool: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
OtherPages = UsageBucket[MI_USAGE_PAGED_POOL];
|
||||
DbgPrint("Paged Pool: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
OtherPages = UsageBucket[MI_USAGE_KERNEL_STACK] + UsageBucket[MI_USAGE_KERNEL_STACK_EXPANSION];
|
||||
DbgPrint("Kernel Stack: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
OtherPages = UsageBucket[MI_USAGE_INIT_MEMORY];
|
||||
DbgPrint("Init Memory: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
OtherPages = UsageBucket[MI_USAGE_SECTION];
|
||||
DbgPrint("Sections: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
OtherPages = UsageBucket[MI_USAGE_CACHE];
|
||||
DbgPrint("Cache: %5d pages\t[%6d KB]\n", OtherPages, (OtherPages << PAGE_SHIFT) / 1024);
|
||||
#endif
|
||||
KeLowerIrql(OldIrql);
|
||||
}
|
||||
|
||||
|
@ -1565,6 +1646,8 @@ MiBuildPagedPool(VOID)
|
|||
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||
|
||||
/* Allocate a page and map the first paged pool PDE */
|
||||
MI_SET_USAGE(MI_USAGE_PAGED_POOL);
|
||||
MI_SET_PROCESS2("Kernel");
|
||||
PageFrameIndex = MiRemoveZeroPage(0);
|
||||
TempPte.u.Hard.PageFrameNumber = PageFrameIndex;
|
||||
MI_WRITE_VALID_PTE(PointerPde, TempPte);
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
BOOLEAN UserPdeFault = FALSE;
|
||||
#endif
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
PMMPTE
|
||||
|
@ -256,6 +260,12 @@ MiResolveDemandZeroFault(IN PVOID Address,
|
|||
|
||||
/* Do we need a zero page? */
|
||||
ASSERT(PointerPte->u.Hard.Valid == 0);
|
||||
#if MI_TRACE_PFNS
|
||||
if (UserPdeFault) MI_SET_USAGE(MI_USAGE_PAGE_TABLE);
|
||||
if (!UserPdeFault) MI_SET_USAGE(MI_USAGE_DEMAND_ZERO);
|
||||
#endif
|
||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||
if (!Process) MI_SET_PROCESS2("Kernel Demand 0");
|
||||
if ((NeedZero) && (Process))
|
||||
{
|
||||
/* Try to get one, if we couldn't grab a free page and zero it */
|
||||
|
@ -892,6 +902,9 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction,
|
|||
MI_WRITE_INVALID_PTE(PointerPde, DemandZeroPde);
|
||||
|
||||
/* And go dispatch the fault on the PDE. This should handle the demand-zero */
|
||||
#if MI_TRACE_PFNS
|
||||
UserPdeFault = TRUE;
|
||||
#endif
|
||||
Status = MiDispatchFault(TRUE,
|
||||
PointerPte,
|
||||
PointerPde,
|
||||
|
@ -900,7 +913,9 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction,
|
|||
PsGetCurrentProcess(),
|
||||
TrapInformation,
|
||||
NULL);
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
UserPdeFault = FALSE;
|
||||
#endif
|
||||
/* We should come back with APCs enabled, and with a valid PDE */
|
||||
ASSERT(KeAreAllApcsDisabled() == TRUE);
|
||||
#if (_MI_PAGING_LEVELS >= 3)
|
||||
|
@ -987,6 +1002,8 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction,
|
|||
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||
|
||||
/* Try to get a zero page */
|
||||
MI_SET_USAGE(MI_USAGE_PEB_TEB);
|
||||
MI_SET_PROCESS2(CurrentProcess->ImageFileName);
|
||||
Color = MI_GET_NEXT_PROCESS_COLOR(CurrentProcess);
|
||||
PageFrameIndex = MiRemoveZeroPageSafe(Color);
|
||||
if (!PageFrameIndex)
|
||||
|
|
|
@ -55,6 +55,10 @@ PMMPFNLIST MmPageLocationList[] =
|
|||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
ULONG MI_PFN_CURRENT_USAGE;
|
||||
CHAR MI_PFN_CURRENT_PROCESS_NAME[16] = "None yet";
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
VOID
|
||||
|
@ -204,6 +208,14 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry)
|
|||
{
|
||||
/* FIXME: Should wake up the MPW and working set manager, if we had one */
|
||||
}
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
ASSERT(MI_PFN_CURRENT_USAGE != MI_USAGE_NOT_SET);
|
||||
Entry->PfnUsage = MI_PFN_CURRENT_USAGE;
|
||||
memcpy(Entry->ProcessName, MI_PFN_CURRENT_PROCESS_NAME, 16);
|
||||
// MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET;
|
||||
// memcpy(MI_PFN_CURRENT_PROCESS_NAME, "Not Set", 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
PFN_NUMBER
|
||||
|
@ -321,6 +333,14 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex,
|
|||
/* FIXME: Should wake up the MPW and working set manager, if we had one */
|
||||
}
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
//ASSERT(MI_PFN_CURRENT_USAGE != MI_USAGE_NOT_SET);
|
||||
Pfn1->PfnUsage = MI_PFN_CURRENT_USAGE;
|
||||
memcpy(Pfn1->ProcessName, MI_PFN_CURRENT_PROCESS_NAME, 16);
|
||||
//MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET;
|
||||
//memcpy(MI_PFN_CURRENT_PROCESS_NAME, "Not Set", 16);
|
||||
#endif
|
||||
|
||||
/* Return the page */
|
||||
return PageIndex;
|
||||
}
|
||||
|
@ -576,6 +596,11 @@ MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
|
|||
MmZeroingPageThreadActive = TRUE;
|
||||
KeSetEvent(&MmZeroingPageEvent, IO_NO_INCREMENT, FALSE);
|
||||
}
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
Pfn1->PfnUsage = MI_USAGE_FREE_PAGE;
|
||||
RtlZeroMemory(Pfn1->ProcessName, 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Note: This function is hardcoded only for the zeroed page list, for now */
|
||||
|
@ -691,6 +716,13 @@ MiInsertPageInList(IN PMMPFNLIST ListHead,
|
|||
|
||||
/* One more paged on the colored list */
|
||||
ColorHead->Count++;
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
//ASSERT(MI_PFN_CURRENT_USAGE == MI_USAGE_NOT_SET);
|
||||
Pfn1->PfnUsage = MI_USAGE_FREE_PAGE;
|
||||
MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET;
|
||||
RtlZeroMemory(Pfn1->ProcessName, 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
VOID
|
||||
|
|
|
@ -476,11 +476,10 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
|
|||
ASSERT(PointerPde->u.Hard.Valid == 0);
|
||||
|
||||
/* Request a page */
|
||||
DPRINT1("Requesting %d PDEs\n", i);
|
||||
MI_SET_USAGE(MI_USAGE_PAGED_POOL);
|
||||
MI_SET_PROCESS2("Kernel");
|
||||
PageFrameNumber = MiRemoveAnyPage(MI_GET_NEXT_COLOR());
|
||||
TempPde.u.Hard.PageFrameNumber = PageFrameNumber;
|
||||
DPRINT1("We have a PDE: %lx\n", PageFrameNumber);
|
||||
|
||||
#if (_MI_PAGING_LEVELS >= 3)
|
||||
/* On PAE/x64 systems, there's no double-buffering */
|
||||
ASSERT(FALSE);
|
||||
|
@ -773,6 +772,8 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
|
|||
do
|
||||
{
|
||||
/* Allocate a page */
|
||||
MI_SET_USAGE(MI_USAGE_PAGED_POOL);
|
||||
MI_SET_PROCESS2("Kernel");
|
||||
PageFrameNumber = MiRemoveAnyPage(MI_GET_NEXT_COLOR());
|
||||
|
||||
/* Get the PFN entry for it and fill it out */
|
||||
|
|
|
@ -363,6 +363,8 @@ MmCreateKernelStack(IN BOOLEAN GuiStack,
|
|||
PointerPte++;
|
||||
|
||||
/* Get a page and write the current invalid PTE */
|
||||
MI_SET_USAGE(MI_USAGE_KERNEL_STACK);
|
||||
MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
|
||||
PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR());
|
||||
MI_WRITE_INVALID_PTE(PointerPte, InvalidPte);
|
||||
|
||||
|
@ -447,6 +449,8 @@ MmGrowKernelStackEx(IN PVOID StackPointer,
|
|||
while (LimitPte >= NewLimitPte)
|
||||
{
|
||||
/* Get a page and write the current invalid PTE */
|
||||
MI_SET_USAGE(MI_USAGE_KERNEL_STACK_EXPANSION);
|
||||
MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
|
||||
PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR());
|
||||
MI_WRITE_INVALID_PTE(LimitPte, InvalidPte);
|
||||
|
||||
|
@ -1074,6 +1078,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
|
|||
|
||||
/* Get a zero page for the PDE, if possible */
|
||||
Color = MI_GET_NEXT_PROCESS_COLOR(Process);
|
||||
MI_SET_USAGE(MI_USAGE_PAGE_DIRECTORY);
|
||||
PdeIndex = MiRemoveZeroPageSafe(Color);
|
||||
if (!PdeIndex)
|
||||
{
|
||||
|
@ -1087,6 +1092,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
|
|||
}
|
||||
|
||||
/* Get a zero page for hyperspace, if possible */
|
||||
MI_SET_USAGE(MI_USAGE_PAGE_DIRECTORY);
|
||||
Color = MI_GET_NEXT_PROCESS_COLOR(Process);
|
||||
HyperIndex = MiRemoveZeroPageSafe(Color);
|
||||
if (!HyperIndex)
|
||||
|
|
|
@ -339,6 +339,8 @@ MiFillSystemPageDirectory(IN PVOID Base,
|
|||
if (SystemMapPde->u.Hard.Valid == 0)
|
||||
{
|
||||
/* Grab a page for it */
|
||||
MI_SET_USAGE(MI_USAGE_PAGE_TABLE);
|
||||
MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
|
||||
PageFrameIndex = MiRemoveZeroPage(MI_GET_NEXT_COLOR());
|
||||
ASSERT(PageFrameIndex);
|
||||
TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
|
||||
|
|
|
@ -166,12 +166,24 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr,
|
|||
|
||||
/* The driver is here */
|
||||
*ImageBase = DriverBase;
|
||||
DPRINT1("Loading: %wZ at %p with %lx pages\n", FileName, DriverBase, PteCount);
|
||||
|
||||
/* Loop the new driver PTEs */
|
||||
TempPte = ValidKernelPte;
|
||||
while (PointerPte < LastPte)
|
||||
{
|
||||
/* Allocate a page */
|
||||
MI_SET_USAGE(MI_USAGE_DRIVER_PAGE);
|
||||
#if MI_TRACE_PFNS
|
||||
PWCHAR pos = NULL;
|
||||
ULONG len = 0;
|
||||
if (FileName->Buffer)
|
||||
{
|
||||
pos = wcsrchr(FileName->Buffer, '\\');
|
||||
len = wcslen(pos) * sizeof(WCHAR);
|
||||
if (pos) snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos);
|
||||
}
|
||||
#endif
|
||||
TempPte.u.Hard.PageFrameNumber = MiAllocatePfn(PointerPte, MM_EXECUTE);
|
||||
|
||||
/* Write it */
|
||||
|
@ -1385,6 +1397,23 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
(ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage,
|
||||
&LdrEntry->FullDllName);
|
||||
|
||||
/* Get the first PTE and the number of PTEs we'll need */
|
||||
PointerPte = StartPte = MiAddressToPte(LdrEntry->DllBase);
|
||||
PteCount = ROUND_TO_PAGES(LdrEntry->SizeOfImage) >> PAGE_SHIFT;
|
||||
LastPte = StartPte + PteCount;
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
/* Loop the PTEs */
|
||||
while (PointerPte < LastPte)
|
||||
{
|
||||
ULONG len;
|
||||
ASSERT(PointerPte->u.Hard.Valid == 1);
|
||||
Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte));
|
||||
len = wcslen(LdrEntry->BaseDllName.Buffer) * sizeof(WCHAR);
|
||||
snprintf(Pfn1->ProcessName, min(16, len), "%S", LdrEntry->BaseDllName.Buffer);
|
||||
PointerPte++;
|
||||
}
|
||||
#endif
|
||||
/* Skip kernel and HAL */
|
||||
/* ROS HACK: Skip BOOTVID/KDCOM too */
|
||||
i++;
|
||||
|
@ -1424,12 +1453,8 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
/* Remember the original address */
|
||||
DllBase = LdrEntry->DllBase;
|
||||
|
||||
/* Get the first PTE and the number of PTEs we'll need */
|
||||
PointerPte = StartPte = MiAddressToPte(LdrEntry->DllBase);
|
||||
PteCount = ROUND_TO_PAGES(LdrEntry->SizeOfImage) >> PAGE_SHIFT;
|
||||
LastPte = StartPte + PteCount;
|
||||
|
||||
/* Loop the PTEs */
|
||||
PointerPte = StartPte;
|
||||
while (PointerPte < LastPte)
|
||||
{
|
||||
/* Mark the page modified in the PFN database */
|
||||
|
|
|
@ -71,6 +71,8 @@ MmZeroPageThread(VOID)
|
|||
PageIndex = MmFreePageListHead.Flink;
|
||||
ASSERT(PageIndex != LIST_HEAD);
|
||||
Pfn1 = MiGetPfnEntry(PageIndex);
|
||||
MI_SET_USAGE(MI_USAGE_ZERO_LOOP);
|
||||
MI_SET_PROCESS2("Kernel 0 Loop");
|
||||
FreePage = MiRemoveAnyPage(MI_GET_PAGE_COLOR(PageIndex));
|
||||
|
||||
/* The first global free page should also be the first on its own list */
|
||||
|
|
|
@ -367,6 +367,8 @@ MmNotPresentFaultVirtualMemory(PMMSUPPORT AddressSpace,
|
|||
/*
|
||||
* Try to allocate a page
|
||||
*/
|
||||
MI_SET_USAGE(MI_USAGE_VAD);
|
||||
MI_SET_PROCESS2(Process->ImageFileName);
|
||||
Status = MmRequestPageMemoryConsumer(MC_USER, FALSE, &Page);
|
||||
if (Status == STATUS_NO_MEMORY)
|
||||
{
|
||||
|
|
|
@ -230,6 +230,8 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
|
|||
while (PagesFound < PageCount)
|
||||
{
|
||||
/* Grab a page */
|
||||
MI_SET_USAGE(MI_USAGE_MDL);
|
||||
MI_SET_PROCESS2("Kernel");
|
||||
Page = MiRemoveAnyPage(0);
|
||||
if (Page == 0)
|
||||
{
|
||||
|
@ -288,6 +290,8 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
|
|||
|
||||
/* Remove the page from the free or zero list */
|
||||
ASSERT(Pfn1->u3.e1.ReadInProgress == 0);
|
||||
MI_SET_USAGE(MI_USAGE_MDL);
|
||||
MI_SET_PROCESS2("Kernel");
|
||||
MiUnlinkFreeOrZeroedPage(Pfn1);
|
||||
|
||||
//
|
||||
|
|
|
@ -223,6 +223,9 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
|
|||
MmDeleteHyperspaceMapping(PageDir);
|
||||
return NULL;
|
||||
}
|
||||
MI_SET_USAGE(MI_USAGE_LEGACY_PAGE_DIRECTORY);
|
||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||
if (!Process) MI_SET_PROCESS2("Kernel Legacy");
|
||||
Status = MmRequestPageMemoryConsumer(MC_SYSTEM, FALSE, &Pfn);
|
||||
if (!NT_SUCCESS(Status) || Pfn == 0)
|
||||
{
|
||||
|
@ -258,6 +261,9 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
MI_SET_USAGE(MI_USAGE_LEGACY_PAGE_DIRECTORY);
|
||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||
if (!Process) MI_SET_PROCESS2("Kernel Legacy");
|
||||
Status = MmRequestPageMemoryConsumer(MC_SYSTEM, FALSE, &Pfn);
|
||||
if (!NT_SUCCESS(Status) || Pfn == 0)
|
||||
{
|
||||
|
@ -280,6 +286,9 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
MI_SET_USAGE(MI_USAGE_LEGACY_PAGE_DIRECTORY);
|
||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||
if (!Process) MI_SET_PROCESS2("Kernel Legacy");
|
||||
Status = MmRequestPageMemoryConsumer(MC_SYSTEM, FALSE, &Pfn);
|
||||
if (!NT_SUCCESS(Status) || Pfn == 0)
|
||||
{
|
||||
|
|
|
@ -1193,6 +1193,8 @@ MiReadPage(PMEMORY_AREA MemoryArea,
|
|||
* Allocate a page, this is rather complicated by the possibility
|
||||
* we might have to move other things out of memory
|
||||
*/
|
||||
MI_SET_USAGE(MI_USAGE_SECTION);
|
||||
MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
|
||||
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, Page);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -1486,6 +1488,9 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
|||
MmDeletePageFileMapping(Process, (PVOID)PAddress, &SwapEntry);
|
||||
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
MI_SET_USAGE(MI_USAGE_SECTION);
|
||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||
if (!Process) MI_SET_PROCESS2("Kernel Section");
|
||||
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -1567,6 +1572,9 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
|||
if (Segment->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
|
||||
{
|
||||
MmUnlockSectionSegment(Segment);
|
||||
MI_SET_USAGE(MI_USAGE_SECTION);
|
||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||
if (!Process) MI_SET_PROCESS2("Kernel Section");
|
||||
Status = MmRequestPageMemoryConsumer(MC_USER, FALSE, &Page);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -1621,6 +1629,9 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
|||
if ((Segment->Flags & MM_PAGEFILE_SEGMENT) ||
|
||||
(Offset >= PAGE_ROUND_UP(Segment->RawLength) && Section->AllocationAttributes & SEC_IMAGE))
|
||||
{
|
||||
MI_SET_USAGE(MI_USAGE_SECTION);
|
||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||
if (!Process) MI_SET_PROCESS2("Kernel Section");
|
||||
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -1704,7 +1715,9 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
|||
MmUnlockSectionSegment(Segment);
|
||||
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
|
||||
MI_SET_USAGE(MI_USAGE_SECTION);
|
||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||
if (!Process) MI_SET_PROCESS2("Kernel Section");
|
||||
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -1912,6 +1925,9 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
|||
/*
|
||||
* Allocate a page
|
||||
*/
|
||||
MI_SET_USAGE(MI_USAGE_SECTION);
|
||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||
if (!Process) MI_SET_PROCESS2("Kernel Section");
|
||||
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &NewPage);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
|
|
@ -669,6 +669,13 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
|
|||
}
|
||||
}
|
||||
|
||||
#if MI_TRACE_PFNS
|
||||
/* Copy the process name now that we have it */
|
||||
memcpy(MiGetPfnEntry(Process->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT)->ProcessName, Process->ImageFileName, 16);
|
||||
if (Process->Pcb.DirectoryTableBase[1]) memcpy(MiGetPfnEntry(Process->Pcb.DirectoryTableBase[1] >> PAGE_SHIFT)->ProcessName, Process->ImageFileName, 16);
|
||||
if (Process->WorkingSetPage) memcpy(MiGetPfnEntry(Process->WorkingSetPage)->ProcessName, Process->ImageFileName, 16);
|
||||
#endif
|
||||
|
||||
/* Check if we have a section object and map the system DLL */
|
||||
if (SectionObject) PspMapSystemDll(Process, NULL, FALSE);
|
||||
|
||||
|
|
Loading…
Reference in a new issue