[NTOS:MM]

- Make PFN tracing work... somewhat

svn path=/trunk/; revision=74626
This commit is contained in:
Thomas Faber 2017-05-22 13:30:44 +00:00
parent b0da8bcfdf
commit d855861c41
6 changed files with 42 additions and 17 deletions

View file

@ -607,6 +607,7 @@ CcRosMapVacb(
{
PFN_NUMBER PageFrameNumber;
MI_SET_USAGE(MI_USAGE_CACHE);
Status = MmRequestPageMemoryConsumer(MC_CACHE, TRUE, &PageFrameNumber);
if (PageFrameNumber == 0)
{
@ -741,8 +742,15 @@ CcRosCreateVacb (
PWCHAR pos = NULL;
ULONG len = 0;
pos = wcsrchr(SharedCacheMap->FileObject->FileName.Buffer, '\\');
len = wcslen(pos) * sizeof(WCHAR);
if (pos) snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos);
if (pos)
{
len = wcslen(pos) * sizeof(WCHAR);
snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos);
}
else
{
snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%wZ", &SharedCacheMap->FileObject->FileName);
}
}
#endif

View file

@ -653,8 +653,9 @@ MiResolveDemandZeroFault(IN PVOID Address,
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 (Process == HYDRA_PROCESS) MI_SET_PROCESS2("Hydra");
else if (Process) MI_SET_PROCESS2(Process->ImageFileName);
else MI_SET_PROCESS2("Kernel Demand 0");
/* Do we need a zero page? */
if (Color != 0xFFFFFFFF)

View file

@ -994,6 +994,8 @@ _WARN("MiSessionCommitPageTables halfplemented for amd64")
/* Acquire the PFN lock and grab a zero page */
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
MI_SET_USAGE(MI_USAGE_PAGE_TABLE);
MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
Color = (++MmSessionSpace->Color) & MmSecondaryColorMask;
PageFrameNumber = MiRemoveZeroPage(Color);
TempPde.u.Hard.PageFrameNumber = PageFrameNumber;

View file

@ -511,6 +511,7 @@ MiSessionInitializeWorkingSetList(VOID)
if (AllocatedPageTable != FALSE)
{
/* Get a zeroed colored zero page */
MI_SET_USAGE(MI_USAGE_INIT_MEMORY);
Color = MI_GET_NEXT_COLOR();
PageFrameIndex = MiRemoveZeroPageSafe(Color);
if (!PageFrameIndex)
@ -542,6 +543,7 @@ MiSessionInitializeWorkingSetList(VOID)
}
/* Get a zeroed colored zero page */
MI_SET_USAGE(MI_USAGE_INIT_MEMORY);
Color = MI_GET_NEXT_COLOR();
PageFrameIndex = MiRemoveZeroPageSafe(Color);
if (!PageFrameIndex)
@ -679,6 +681,7 @@ MiSessionCreateInternal(OUT PULONG SessionId)
for (i = 0; i < MiSessionDataPages; i++)
{
/* Get a zeroed colored zero page */
MI_SET_USAGE(MI_USAGE_INIT_MEMORY);
Color = MI_GET_NEXT_COLOR();
DataPage[i] = MiRemoveZeroPageSafe(Color);
if (!DataPage[i])
@ -701,6 +704,7 @@ MiSessionCreateInternal(OUT PULONG SessionId)
SessionGlobal = MiPteToAddress(SessionPte);
/* Get a zeroed colored zero page */
MI_SET_USAGE(MI_USAGE_INIT_MEMORY);
Color = MI_GET_NEXT_COLOR();
SessionPageDirIndex = MiRemoveZeroPageSafe(Color);
if (!SessionPageDirIndex)
@ -742,6 +746,7 @@ MiSessionCreateInternal(OUT PULONG SessionId)
for (i = 0; i < MiSessionTagPages; i++)
{
/* Grab a zeroed colored page */
MI_SET_USAGE(MI_USAGE_INIT_MEMORY);
Color = MI_GET_NEXT_COLOR();
TagPage[i] = MiRemoveZeroPageSafe(Color);
if (!TagPage[i])

View file

@ -328,6 +328,15 @@ MmAllocateSpecialPool(SIZE_T NumberOfBytes, ULONG Tag, POOL_TYPE PoolType, ULONG
MiSpecialPoolFirstPte = MmSystemPteBase + PointerPte->u.List.NextEntry;
/* Allocate a physical page */
if (PoolType == PagedPool)
{
MI_SET_USAGE(MI_USAGE_PAGED_POOL);
}
else
{
MI_SET_USAGE(MI_USAGE_NONPAGED_POOL);
}
MI_SET_PROCESS2("Kernel-Special");
PageFrameNumber = MiRemoveAnyPage(MI_GET_NEXT_COLOR());
/* Initialize PFN and make it valid */

View file

@ -178,19 +178,6 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr,
/* Lock the PFN database */
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
/* Some debug stuff */
MI_SET_USAGE(MI_USAGE_DRIVER_PAGE);
#if MI_TRACE_PFNS
if (FileName->Buffer)
{
PWCHAR pos = NULL;
ULONG len = 0;
pos = wcsrchr(FileName->Buffer, '\\');
len = wcslen(pos) * sizeof(WCHAR);
if (pos) snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos);
}
#endif
/* Loop the new driver PTEs */
TempPte = ValidKernelPte;
while (PointerPte < LastPte)
@ -198,6 +185,19 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr,
/* Make sure the PTE is not valid for whatever reason */
ASSERT(PointerPte->u.Hard.Valid == 0);
/* Some debug stuff */
MI_SET_USAGE(MI_USAGE_DRIVER_PAGE);
#if MI_TRACE_PFNS
if (FileName->Buffer)
{
PWCHAR pos = NULL;
ULONG len = 0;
pos = wcsrchr(FileName->Buffer, '\\');
len = wcslen(pos) * sizeof(WCHAR);
if (pos) snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos);
}
#endif
/* Grab a page */
PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR());