Author: bonefish Date: 2010-06-15 01:57:00 +0200 (Tue, 15 Jun 2010) New Revision: 37138 Changeset: http://dev.haiku-os.org/changeset/37138/haiku Modified: haiku/trunk/headers/private/kernel/vm/vm.h haiku/trunk/src/system/kernel/cache/vnode_store.cpp haiku/trunk/src/system/kernel/cache/vnode_store.h haiku/trunk/src/system/kernel/vm/VMCache.cpp haiku/trunk/src/system/kernel/vm/vm.cpp Log: * Renamed cache_type_to_string() to vm_cache_type_to_string() and made in kernel private. * Moved dumping code from dump_cache() to new VMCache::Dump(). * Override VMCache::Dump() in VMVnodeCache to also print the vnode. * Removed no longer needed VMCache::GetLock(). Modified: haiku/trunk/headers/private/kernel/vm/vm.h =================================================================== --- haiku/trunk/headers/private/kernel/vm/vm.h 2010-06-14 23:51:54 UTC (rev 37137) +++ haiku/trunk/headers/private/kernel/vm/vm.h 2010-06-14 23:57:00 UTC (rev 37138) @@ -85,6 +85,8 @@ area_id transfer_area(area_id id, void** _address, uint32 addressSpec, team_id target, bool kernel); +const char* vm_cache_type_to_string(int32 type); + status_t vm_block_address_range(const char* name, void* address, addr_t size); status_t vm_unreserve_address_range(team_id team, void *address, addr_t size); status_t vm_reserve_address_range(team_id team, void **_address, Modified: haiku/trunk/src/system/kernel/cache/vnode_store.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/vnode_store.cpp 2010-06-14 23:51:54 UTC (rev 37137) +++ haiku/trunk/src/system/kernel/cache/vnode_store.cpp 2010-06-14 23:57:00 UTC (rev 37138) @@ -155,3 +155,12 @@ vfs_put_vnode(fVnode); } + +void +VMVnodeCache::Dump(bool showPages) const +{ + VMCache::Dump(showPages); + + kprintf(" vnode: %p <%" B_PRIdDEV ", %" B_PRIdINO ">\n", fVnode, + fDevice, fInode); +} Modified: haiku/trunk/src/system/kernel/cache/vnode_store.h =================================================================== --- haiku/trunk/src/system/kernel/cache/vnode_store.h 2010-06-14 23:51:54 UTC (rev 37137) +++ haiku/trunk/src/system/kernel/cache/vnode_store.h 2010-06-14 23:57:00 UTC (rev 37138) @@ -39,6 +39,8 @@ virtual void AcquireStoreRef(); virtual void ReleaseStoreRef(); + virtual void Dump(bool showPages) const; + void SetFileCacheRef(file_cache_ref* ref) { fFileCacheRef = ref; } file_cache_ref* FileCacheRef() const Modified: haiku/trunk/src/system/kernel/vm/VMCache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/VMCache.cpp 2010-06-14 23:51:54 UTC (rev 37137) +++ haiku/trunk/src/system/kernel/vm/VMCache.cpp 2010-06-14 23:57:00 UTC (rev 37138) @@ -29,6 +29,7 @@ #include <vm/vm_page.h> #include <vm/vm_priv.h> #include <vm/vm_types.h> +#include <vm/VMAddressSpace.h> #include <vm/VMArea.h> @@ -1271,6 +1272,58 @@ } +void +VMCache::Dump(bool showPages) const +{ + kprintf("CACHE %p:\n", this); + kprintf(" ref_count: %ld\n", RefCount()); + kprintf(" source: %p\n", source); + kprintf(" type: %s\n", vm_cache_type_to_string(type)); + kprintf(" virtual_base: 0x%Lx\n", virtual_base); + kprintf(" virtual_end: 0x%Lx\n", virtual_end); + kprintf(" temporary: %ld\n", temporary); + kprintf(" scan_skip: %ld\n", scan_skip); + kprintf(" lock: %p\n", &fLock); +#if KDEBUG + kprintf(" lock.holder: %ld\n", fLock.holder); +#endif + kprintf(" areas:\n"); + + for (VMArea* area = areas; area != NULL; area = area->cache_next) { + kprintf(" area 0x%lx, %s\n", area->id, area->name); + kprintf("\tbase_addr: 0x%lx, size: 0x%lx\n", area->Base(), + area->Size()); + kprintf("\tprotection: 0x%lx\n", area->protection); + kprintf("\towner: 0x%lx\n", area->address_space->ID()); + } + + kprintf(" consumers:\n"); + VMCache* consumer = NULL; + while ((consumer = (VMCache*)list_get_next_item((list*)&consumers, + consumer)) != NULL) { + kprintf("\t%p\n", consumer); + } + + kprintf(" pages:\n"); + if (showPages) { + for (VMCachePagesTree::ConstIterator it = pages.GetIterator(); + vm_page* page = it.Next();) { + if (!vm_page_is_dummy(page)) { + kprintf("\t%p ppn %#" B_PRIxPHYSADDR " offset %#" B_PRIxPHYSADDR + " state %u (%s) wired_count %u\n", page, + page->physical_page_number, page->cache_offset, + page->State(), page_state_to_string(page->State()), + page->wired_count); + } else { + kprintf("\t%p DUMMY PAGE state %u (%s)\n", + page, page->State(), page_state_to_string(page->State())); + } + } + } else + kprintf("\t%ld in cache\n", page_count); +} + + /*! Wakes up threads waiting for page events. \param page The page for which events occurred. \param events The mask of events that occurred. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2010-06-14 23:51:54 UTC (rev 37137) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2010-06-14 23:57:00 UTC (rev 37138) @@ -2818,8 +2818,8 @@ } -static const char* -cache_type_to_string(int32 type) +const char* +vm_cache_type_to_string(int32 type) { switch (type) { case CACHE_TYPE_RAM: @@ -2884,7 +2884,7 @@ kprintf(" "); kprintf("%p: type: %s, base: %lld, size: %lld, pages: %lu", cache, - cache_type_to_string(cache->type), cache->virtual_base, + vm_cache_type_to_string(cache->type), cache->virtual_base, cache->virtual_end, cache->page_count); if (level == 0) @@ -3023,53 +3023,8 @@ cache = (VMCache*)address; - kprintf("CACHE %p:\n", cache); - kprintf(" ref_count: %ld\n", cache->RefCount()); - kprintf(" source: %p\n", cache->source); - kprintf(" type: %s\n", cache_type_to_string(cache->type)); - kprintf(" virtual_base: 0x%Lx\n", cache->virtual_base); - kprintf(" virtual_end: 0x%Lx\n", cache->virtual_end); - kprintf(" temporary: %ld\n", cache->temporary); - kprintf(" scan_skip: %ld\n", cache->scan_skip); - kprintf(" lock: %p\n", cache->GetLock()); -#if KDEBUG - kprintf(" lock.holder: %ld\n", cache->GetLock()->holder); -#endif - kprintf(" areas:\n"); + cache->Dump(showPages); - for (VMArea* area = cache->areas; area != NULL; area = area->cache_next) { - kprintf(" area 0x%lx, %s\n", area->id, area->name); - kprintf("\tbase_addr: 0x%lx, size: 0x%lx\n", area->Base(), - area->Size()); - kprintf("\tprotection: 0x%lx\n", area->protection); - kprintf("\towner: 0x%lx\n", area->address_space->ID()); - } - - kprintf(" consumers:\n"); - VMCache* consumer = NULL; - while ((consumer = (VMCache*)list_get_next_item(&cache->consumers, - consumer)) != NULL) { - kprintf("\t%p\n", consumer); - } - - kprintf(" pages:\n"); - if (showPages) { - for (VMCachePagesTree::Iterator it = cache->pages.GetIterator(); - vm_page* page = it.Next();) { - if (!vm_page_is_dummy(page)) { - kprintf("\t%p ppn %#" B_PRIxPHYSADDR " offset %#" B_PRIxPHYSADDR - " state %u (%s) wired_count %u\n", page, - page->physical_page_number, page->cache_offset, - page->State(), page_state_to_string(page->State()), - page->wired_count); - } else { - kprintf("\t%p DUMMY PAGE state %u (%s)\n", - page, page->State(), page_state_to_string(page->State())); - } - } - } else - kprintf("\t%ld in cache\n", cache->page_count); - set_debug_variable("_sourceCache", (addr_t)cache->source); return 0; @@ -3089,7 +3044,7 @@ kprintf("wiring:\t\t0x%x\n", area->wiring); kprintf("memory_type:\t%#" B_PRIx32 "\n", area->MemoryType()); kprintf("cache:\t\t%p\n", area->cache); - kprintf("cache_type:\t%s\n", cache_type_to_string(area->cache_type)); + kprintf("cache_type:\t%s\n", vm_cache_type_to_string(area->cache_type)); kprintf("cache_offset:\t0x%Lx\n", area->cache_offset); kprintf("cache_next:\t%p\n", area->cache_next); kprintf("cache_prev:\t%p\n", area->cache_prev);