mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[NTOS:MM] Implement PeakCommitment (MmPeakCommitment, MmTotalCommittedPages) (#4650)
And return the corresponding values in SystemPerformanceInformation. Lockless updating counters suggestion by Thomas Faber.
This commit is contained in:
parent
51dd0523c7
commit
3703bbd631
4 changed files with 35 additions and 8 deletions
|
@ -714,13 +714,8 @@ QSI_DEF(SystemPerformanceInformation)
|
|||
}
|
||||
|
||||
Spi->AvailablePages = (ULONG)MmAvailablePages;
|
||||
/*
|
||||
* Add up all the used "Committed" memory + pagefile.
|
||||
* Not sure this is right. 8^\
|
||||
*/
|
||||
Spi->CommittedPages = MiMemoryConsumers[MC_SYSTEM].PagesUsed +
|
||||
MiMemoryConsumers[MC_USER].PagesUsed +
|
||||
MiUsedSwapPages;
|
||||
|
||||
Spi->CommittedPages = MmTotalCommittedPages;
|
||||
/*
|
||||
* Add up the full system total + pagefile.
|
||||
* All this make Taskmgr happy but not sure it is the right numbers.
|
||||
|
@ -728,7 +723,7 @@ QSI_DEF(SystemPerformanceInformation)
|
|||
*/
|
||||
Spi->CommitLimit = MmNumberOfPhysicalPages + MiFreeSwapPages + MiUsedSwapPages;
|
||||
|
||||
Spi->PeakCommitment = 0; /* FIXME */
|
||||
Spi->PeakCommitment = MmPeakCommitment;
|
||||
Spi->PageFaultCount = 0; /* FIXME */
|
||||
Spi->CopyOnWriteCount = 0; /* FIXME */
|
||||
Spi->TransitionCount = 0; /* FIXME */
|
||||
|
|
|
@ -866,6 +866,33 @@ NTAPI
|
|||
MmDeleteKernelStack(PVOID Stack,
|
||||
BOOLEAN GuiStack);
|
||||
|
||||
/* balance.c / pagefile.c******************************************************/
|
||||
|
||||
inline VOID UpdateTotalCommittedPages(LONG Delta)
|
||||
{
|
||||
/*
|
||||
* Add up all the used "Committed" memory + pagefile.
|
||||
* Not sure this is right. 8^\
|
||||
* MmTotalCommittedPages should be adjusted consistently with
|
||||
* other counters at different places.
|
||||
*
|
||||
MmTotalCommittedPages = MiMemoryConsumers[MC_SYSTEM].PagesUsed +
|
||||
MiMemoryConsumers[MC_USER].PagesUsed +
|
||||
MiUsedSwapPages;
|
||||
*/
|
||||
|
||||
/* Update Commitment */
|
||||
SIZE_T TotalCommittedPages = InterlockedExchangeAddSizeT(&MmTotalCommittedPages, Delta) + Delta;
|
||||
|
||||
/* Update Peak = max(Peak, Total) in a lockless way */
|
||||
SIZE_T PeakCommitment = MmPeakCommitment;
|
||||
while (TotalCommittedPages > PeakCommitment &&
|
||||
InterlockedCompareExchangeSizeT(&MmPeakCommitment, TotalCommittedPages, PeakCommitment) != PeakCommitment)
|
||||
{
|
||||
PeakCommitment = MmPeakCommitment;
|
||||
}
|
||||
}
|
||||
|
||||
/* balance.c *****************************************************************/
|
||||
|
||||
CODE_SEG("INIT")
|
||||
|
|
|
@ -81,6 +81,7 @@ MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
|
|||
}
|
||||
|
||||
(void)InterlockedDecrementUL(&MiMemoryConsumers[Consumer].PagesUsed);
|
||||
UpdateTotalCommittedPages(-1);
|
||||
|
||||
OldIrql = MiAcquirePfnLock();
|
||||
|
||||
|
@ -284,6 +285,7 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait,
|
|||
|
||||
/* Update the target */
|
||||
InterlockedIncrementUL(&MiMemoryConsumers[Consumer].PagesUsed);
|
||||
UpdateTotalCommittedPages(1);
|
||||
|
||||
/*
|
||||
* Actually allocate the page.
|
||||
|
|
|
@ -295,6 +295,7 @@ MmFreeSwapPage(SWAPENTRY Entry)
|
|||
|
||||
MiFreeSwapPages++;
|
||||
MiUsedSwapPages--;
|
||||
UpdateTotalCommittedPages(-1);
|
||||
|
||||
KeReleaseGuardedMutex(&MmPageFileCreationLock);
|
||||
}
|
||||
|
@ -329,6 +330,8 @@ MmAllocSwapPage(VOID)
|
|||
}
|
||||
MiUsedSwapPages++;
|
||||
MiFreeSwapPages--;
|
||||
UpdateTotalCommittedPages(1);
|
||||
|
||||
KeReleaseGuardedMutex(&MmPageFileCreationLock);
|
||||
|
||||
entry = ENTRY_FROM_FILE_OFFSET(i, off + 1);
|
||||
|
|
Loading…
Reference in a new issue