diff --git a/headers/private/kernel/vm/VMCache.h b/headers/private/kernel/vm/VMCache.h index 7b9a83fec9..1d3fbae173 100644 --- a/headers/private/kernel/vm/VMCache.h +++ b/headers/private/kernel/vm/VMCache.h @@ -174,6 +174,16 @@ public: virtual status_t Fault(struct VMAddressSpace *aspace, off_t offset); + inline uint64 FaultCount() const + { return fFaultCount; } + inline void IncrementFaultCount() + { fFaultCount++; } + + inline uint64 CopiedPagesCount() const + { return fCopiedPagesCount; } + inline void IncrementCopiedPagesCount() + { fCopiedPagesCount++; } + virtual void Merge(VMCache* source); virtual status_t AcquireUnreferencedStoreRef(); @@ -228,7 +238,10 @@ private: PageEventWaiter* fPageEventWaiters; void* fUserData; VMCacheRef* fCacheRef; + page_num_t fWiredPagesCount; + uint64 fFaultCount; + uint64 fCopiedPagesCount; }; diff --git a/src/system/kernel/vm/VMCache.cpp b/src/system/kernel/vm/VMCache.cpp index fb6b66c622..0472f14db2 100644 --- a/src/system/kernel/vm/VMCache.cpp +++ b/src/system/kernel/vm/VMCache.cpp @@ -642,6 +642,8 @@ VMCache::Init(uint32 cacheType, uint32 allocationFlags) temporary = 0; page_count = 0; fWiredPagesCount = 0; + fFaultCount = 0; + fCopiedPagesCount = 0; type = cacheType; fPageEventWaiters = NULL; diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 7f21dbd50e..78bf6776cd 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -4405,6 +4405,7 @@ fault_get_page(PageFaultContext& context) context.cacheChainLocker.RelockCaches(true); sourcePage->Cache()->MarkPageUnbusy(sourcePage); + sourcePage->Cache()->IncrementCopiedPagesCount(); // insert the new page into our cache context.topCache->InsertPage(page, context.cacheOffset); @@ -4666,8 +4667,9 @@ vm_soft_fault(VMAddressSpace* addressSpace, addr_t originalAddress, *wirePage = context.page; } - DEBUG_PAGE_ACCESS_END(context.page); + context.page->Cache()->IncrementFaultCount(); + DEBUG_PAGE_ACCESS_END(context.page); break; } @@ -4920,16 +4922,18 @@ fill_area_info(struct VMArea* area, area_info* info, size_t size) info->protection = area->protection; info->lock = area->wiring; info->team = area->address_space->ID(); - info->copy_count = 0; - info->in_count = 0; - info->out_count = 0; - // TODO: retrieve real values here! VMCache* cache = vm_area_get_locked_cache(area); // Note, this is a simplification; the cache could be larger than this area info->ram_size = cache->page_count * B_PAGE_SIZE; + info->copy_count = cache->CopiedPagesCount(); + + info->in_count = 0; + info->out_count = 0; + // TODO: retrieve real values here! + vm_area_put_locked_cache(cache); }