kernel/vm: Track fault and copy counts in VMCache.
This solves a TODO for reporting CoW counts in area_info, and paves the way for adaptive handling of pre-faulting based on how many faults a cache has handled. Change-Id: I4ecd7cf46b794c51acac87184fef49ea5ce76743 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8873 Haiku-Format: Haiku-format Bot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
b2b3e71456
commit
17c3890ce1
@@ -174,6 +174,16 @@ public:
|
|||||||
virtual status_t Fault(struct VMAddressSpace *aspace,
|
virtual status_t Fault(struct VMAddressSpace *aspace,
|
||||||
off_t offset);
|
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 void Merge(VMCache* source);
|
||||||
|
|
||||||
virtual status_t AcquireUnreferencedStoreRef();
|
virtual status_t AcquireUnreferencedStoreRef();
|
||||||
@@ -228,7 +238,10 @@ private:
|
|||||||
PageEventWaiter* fPageEventWaiters;
|
PageEventWaiter* fPageEventWaiters;
|
||||||
void* fUserData;
|
void* fUserData;
|
||||||
VMCacheRef* fCacheRef;
|
VMCacheRef* fCacheRef;
|
||||||
|
|
||||||
page_num_t fWiredPagesCount;
|
page_num_t fWiredPagesCount;
|
||||||
|
uint64 fFaultCount;
|
||||||
|
uint64 fCopiedPagesCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -642,6 +642,8 @@ VMCache::Init(uint32 cacheType, uint32 allocationFlags)
|
|||||||
temporary = 0;
|
temporary = 0;
|
||||||
page_count = 0;
|
page_count = 0;
|
||||||
fWiredPagesCount = 0;
|
fWiredPagesCount = 0;
|
||||||
|
fFaultCount = 0;
|
||||||
|
fCopiedPagesCount = 0;
|
||||||
type = cacheType;
|
type = cacheType;
|
||||||
fPageEventWaiters = NULL;
|
fPageEventWaiters = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -4405,6 +4405,7 @@ fault_get_page(PageFaultContext& context)
|
|||||||
|
|
||||||
context.cacheChainLocker.RelockCaches(true);
|
context.cacheChainLocker.RelockCaches(true);
|
||||||
sourcePage->Cache()->MarkPageUnbusy(sourcePage);
|
sourcePage->Cache()->MarkPageUnbusy(sourcePage);
|
||||||
|
sourcePage->Cache()->IncrementCopiedPagesCount();
|
||||||
|
|
||||||
// insert the new page into our cache
|
// insert the new page into our cache
|
||||||
context.topCache->InsertPage(page, context.cacheOffset);
|
context.topCache->InsertPage(page, context.cacheOffset);
|
||||||
@@ -4666,8 +4667,9 @@ vm_soft_fault(VMAddressSpace* addressSpace, addr_t originalAddress,
|
|||||||
*wirePage = context.page;
|
*wirePage = context.page;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PAGE_ACCESS_END(context.page);
|
context.page->Cache()->IncrementFaultCount();
|
||||||
|
|
||||||
|
DEBUG_PAGE_ACCESS_END(context.page);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4920,16 +4922,18 @@ fill_area_info(struct VMArea* area, area_info* info, size_t size)
|
|||||||
info->protection = area->protection;
|
info->protection = area->protection;
|
||||||
info->lock = area->wiring;
|
info->lock = area->wiring;
|
||||||
info->team = area->address_space->ID();
|
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);
|
VMCache* cache = vm_area_get_locked_cache(area);
|
||||||
|
|
||||||
// Note, this is a simplification; the cache could be larger than this area
|
// Note, this is a simplification; the cache could be larger than this area
|
||||||
info->ram_size = cache->page_count * B_PAGE_SIZE;
|
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);
|
vm_area_put_locked_cache(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user