From: John Hodge Date: Fri, 10 Feb 2012 10:57:47 +0000 (+0800) Subject: Kernel/x86 - Slight fixes to PMM statistics X-Git-Tag: rel0.15~780 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=4868742c184ac3d4b95a7651f79507e8e8c0521a;p=tpg%2Facess2.git Kernel/x86 - Slight fixes to PMM statistics --- diff --git a/KernelLand/Kernel/arch/x86/mm_phys.c b/KernelLand/Kernel/arch/x86/mm_phys.c index aa1b2603..55768116 100644 --- a/KernelLand/Kernel/arch/x86/mm_phys.c +++ b/KernelLand/Kernel/arch/x86/mm_phys.c @@ -81,7 +81,8 @@ void MM_Install(tMBoot_Info *MBoot) kernelPages = (Uint)&gKernelEnd - KERNEL_BASE - 0x100000; kernelPages += 0xFFF; // Page Align kernelPages >>= 12; - + giPhysAlloc += kernelPages; // Add to used count + // Fill page bitmap num = kernelPages/32; memsetd( &gaPageBitmap[0x100000/(4096*32)], -1, num ); @@ -109,7 +110,9 @@ void MM_Install(tMBoot_Info *MBoot) gaPageReferences = (void*)MM_REFCOUNT_BASE; - Log_Log("PMem", "Physical memory set up"); + Log_Log("PMem", "Physical memory set up (%lli pages of ~%lli MiB used)", + giPhysAlloc, (giPageCount*4)/1024 + ); } /** @@ -423,7 +426,10 @@ void MM_RefPhys(tPAddr PAddr) // Log_Debug("PMem", "MM_RefPhys: Allocating info for %X", PAddr); Mutex_Release( &glPhysAlloc ); if( MM_Allocate( addr ) == 0 ) { - Log_KernelPanic("PMem", "MM_RefPhys: Out of physical memory allocating info for %X", PAddr*PAGE_SIZE); + Log_KernelPanic("PMem", + "MM_RefPhys: Out of physical memory allocating info for %X", + PAddr*PAGE_SIZE + ); } Mutex_Acquire( &glPhysAlloc ); @@ -434,9 +440,13 @@ void MM_RefPhys(tPAddr PAddr) } gaPageReferences[ PAddr ] ++; } - - // Mark as used - gaPageBitmap[ PAddr / 32 ] |= 1 << (PAddr&31); + + // If not already used + if( !(gaPageBitmap[ PAddr / 32 ] & 1 << (PAddr&31)) ) { + giPhysAlloc ++; + // Mark as used + gaPageBitmap[ PAddr / 32 ] |= 1 << (PAddr&31); + } // Mark used block if(gaPageBitmap[ PAddr / 32 ] == -1)