Finished renaming of vm_cache to VMCache.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34424 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-12-01 17:45:55 +00:00
parent a99eb6b56f
commit a477e3cf20
8 changed files with 83 additions and 86 deletions
+2 -2
View File
@@ -37,9 +37,9 @@ struct cache_module_info {
extern "C" { extern "C" {
#endif #endif
extern void cache_node_opened(struct vnode *vnode, int32 fdType, vm_cache *cache, extern void cache_node_opened(struct vnode *vnode, int32 fdType, VMCache *cache,
dev_t mountID, ino_t parentID, ino_t vnodeID, const char *name); dev_t mountID, ino_t parentID, ino_t vnodeID, const char *name);
extern void cache_node_closed(struct vnode *vnode, int32 fdType, vm_cache *cache, extern void cache_node_closed(struct vnode *vnode, int32 fdType, VMCache *cache,
dev_t mountID, ino_t vnodeID); dev_t mountID, ino_t vnodeID);
extern void cache_node_launched(size_t argCount, char * const *args); extern void cache_node_launched(size_t argCount, char * const *args);
extern void cache_prefetch_vnode(struct vnode *vnode, off_t offset, size_t size); extern void cache_prefetch_vnode(struct vnode *vnode, off_t offset, size_t size);
+1 -4
View File
@@ -267,12 +267,9 @@ private:
mutex fLock; mutex fLock;
}; };
typedef VMCache vm_cache;
// TODO: Remove!
#if DEBUG_CACHE_LIST #if DEBUG_CACHE_LIST
extern vm_cache* gDebugCacheList; extern VMCache* gDebugCacheList;
#endif #endif
+8 -8
View File
@@ -43,7 +43,7 @@
#define LAST_ACCESSES 3 #define LAST_ACCESSES 3
struct file_cache_ref { struct file_cache_ref {
vm_cache *cache; VMCache *cache;
struct vnode *vnode; struct vnode *vnode;
off_t last_access[LAST_ACCESSES]; off_t last_access[LAST_ACCESSES];
// TODO: it would probably be enough to only store the least // TODO: it would probably be enough to only store the least
@@ -286,7 +286,7 @@ static void
reserve_pages(file_cache_ref* ref, size_t reservePages, bool isWrite) reserve_pages(file_cache_ref* ref, size_t reservePages, bool isWrite)
{ {
if (low_resource_state(B_KERNEL_RESOURCE_PAGES) != B_NO_LOW_RESOURCE) { if (low_resource_state(B_KERNEL_RESOURCE_PAGES) != B_NO_LOW_RESOURCE) {
vm_cache* cache = ref->cache; VMCache* cache = ref->cache;
cache->Lock(); cache->Lock();
if (list_is_empty(&cache->consumers) && cache->areas == NULL if (list_is_empty(&cache->consumers) && cache->areas == NULL
@@ -374,7 +374,7 @@ read_into_cache(file_cache_ref* ref, void* cookie, off_t offset,
TRACE(("read_into_cache(offset = %Ld, pageOffset = %ld, buffer = %#lx, " TRACE(("read_into_cache(offset = %Ld, pageOffset = %ld, buffer = %#lx, "
"bufferSize = %lu\n", offset, pageOffset, buffer, bufferSize)); "bufferSize = %lu\n", offset, pageOffset, buffer, bufferSize));
vm_cache* cache = ref->cache; VMCache* cache = ref->cache;
// TODO: We're using way too much stack! Rather allocate a sufficiently // TODO: We're using way too much stack! Rather allocate a sufficiently
// large chunk on the heap. // large chunk on the heap.
@@ -720,7 +720,7 @@ cache_io(void* _cacheRef, void* cookie, off_t offset, addr_t buffer,
panic("cache_io() called with NULL ref!\n"); panic("cache_io() called with NULL ref!\n");
file_cache_ref* ref = (file_cache_ref*)_cacheRef; file_cache_ref* ref = (file_cache_ref*)_cacheRef;
vm_cache* cache = ref->cache; VMCache* cache = ref->cache;
off_t fileSize = cache->virtual_end; off_t fileSize = cache->virtual_end;
bool useBuffer = buffer != 0; bool useBuffer = buffer != 0;
@@ -945,7 +945,7 @@ cache_prefetch_vnode(struct vnode* vnode, off_t offset, size_t size)
if (size == 0) if (size == 0)
return; return;
vm_cache* cache; VMCache* cache;
if (vfs_get_vnode_cache(vnode, &cache, false) != B_OK) if (vfs_get_vnode_cache(vnode, &cache, false) != B_OK)
return; return;
@@ -1036,7 +1036,7 @@ cache_prefetch(dev_t mountID, ino_t vnodeID, off_t offset, size_t size)
extern "C" void extern "C" void
cache_node_opened(struct vnode* vnode, int32 fdType, vm_cache* cache, cache_node_opened(struct vnode* vnode, int32 fdType, VMCache* cache,
dev_t mountID, ino_t parentID, ino_t vnodeID, const char* name) dev_t mountID, ino_t parentID, ino_t vnodeID, const char* name)
{ {
if (sCacheModule == NULL || sCacheModule->node_opened == NULL) if (sCacheModule == NULL || sCacheModule->node_opened == NULL)
@@ -1055,7 +1055,7 @@ cache_node_opened(struct vnode* vnode, int32 fdType, vm_cache* cache,
extern "C" void extern "C" void
cache_node_closed(struct vnode* vnode, int32 fdType, vm_cache* cache, cache_node_closed(struct vnode* vnode, int32 fdType, VMCache* cache,
dev_t mountID, ino_t vnodeID) dev_t mountID, ino_t vnodeID)
{ {
if (sCacheModule == NULL || sCacheModule->node_closed == NULL) if (sCacheModule == NULL || sCacheModule->node_closed == NULL)
@@ -1118,7 +1118,7 @@ file_cache_create(dev_t mountID, ino_t vnodeID, off_t size)
ref->last_access_index = 0; ref->last_access_index = 0;
ref->disabled_count = 0; ref->disabled_count = 0;
// TODO: delay vm_cache creation until data is // TODO: delay VMCache creation until data is
// requested/written for the first time? Listing lots of // requested/written for the first time? Listing lots of
// files in Tracker (and elsewhere) could be slowed down. // files in Tracker (and elsewhere) could be slowed down.
// Since the file_cache_ref itself doesn't have a lock, // Since the file_cache_ref itself doesn't have a lock,
+4 -4
View File
@@ -269,7 +269,7 @@ private:
struct vnode : fs_vnode, DoublyLinkedListLinkImpl<vnode> { struct vnode : fs_vnode, DoublyLinkedListLinkImpl<vnode> {
struct vnode* next; struct vnode* next;
vm_cache* cache; VMCache* cache;
dev_t device; dev_t device;
list_link unused_link; list_link unused_link;
ino_t id; ino_t id;
@@ -1111,7 +1111,7 @@ free_vnode(struct vnode* vnode, bool reenter)
hash_remove(sVnodeTable, vnode); hash_remove(sVnodeTable, vnode);
mutex_unlock(&sVnodeMutex); mutex_unlock(&sVnodeMutex);
// if we have a vm_cache attached, remove it // if we have a VMCache attached, remove it
if (vnode->cache) if (vnode->cache)
vnode->cache->ReleaseRef(); vnode->cache->ReleaseRef();
@@ -4459,13 +4459,13 @@ vfs_write_pages(struct vnode* vnode, void* cookie, off_t pos, const iovec* vecs,
} }
/*! Gets the vnode's vm_cache object. If it didn't have one, it will be /*! Gets the vnode's VMCache object. If it didn't have one, it will be
created if \a allocate is \c true. created if \a allocate is \c true.
In case it's successful, it will also grab a reference to the cache In case it's successful, it will also grab a reference to the cache
it returns. it returns.
*/ */
extern "C" status_t extern "C" status_t
vfs_get_vnode_cache(struct vnode* vnode, vm_cache** _cache, bool allocate) vfs_get_vnode_cache(struct vnode* vnode, VMCache** _cache, bool allocate)
{ {
if (vnode->cache != NULL) { if (vnode->cache != NULL) {
vnode->cache->AcquireRef(); vnode->cache->AcquireRef();
+58 -58
View File
@@ -128,7 +128,7 @@ public:
VMAddressSpace** _space = NULL); VMAddressSpace** _space = NULL);
status_t AddAreaCacheAndLock(area_id areaID, bool writeLockThisOne, status_t AddAreaCacheAndLock(area_id areaID, bool writeLockThisOne,
bool writeLockOthers, VMArea*& _area, vm_cache** _cache = NULL); bool writeLockOthers, VMArea*& _area, VMCache** _cache = NULL);
status_t Lock(); status_t Lock();
void Unlock(); void Unlock();
@@ -158,33 +158,33 @@ private:
class AreaCacheLocking { class AreaCacheLocking {
public: public:
inline bool Lock(vm_cache* lockable) inline bool Lock(VMCache* lockable)
{ {
return false; return false;
} }
inline void Unlock(vm_cache* lockable) inline void Unlock(VMCache* lockable)
{ {
vm_area_put_locked_cache(lockable); vm_area_put_locked_cache(lockable);
} }
}; };
class AreaCacheLocker : public AutoLocker<vm_cache, AreaCacheLocking> { class AreaCacheLocker : public AutoLocker<VMCache, AreaCacheLocking> {
public: public:
inline AreaCacheLocker(vm_cache* cache = NULL) inline AreaCacheLocker(VMCache* cache = NULL)
: AutoLocker<vm_cache, AreaCacheLocking>(cache, true) : AutoLocker<VMCache, AreaCacheLocking>(cache, true)
{ {
} }
inline AreaCacheLocker(VMArea* area) inline AreaCacheLocker(VMArea* area)
: AutoLocker<vm_cache, AreaCacheLocking>() : AutoLocker<VMCache, AreaCacheLocking>()
{ {
SetTo(area); SetTo(area);
} }
inline void SetTo(VMArea* area) inline void SetTo(VMArea* area)
{ {
return AutoLocker<vm_cache, AreaCacheLocking>::SetTo( return AutoLocker<VMCache, AreaCacheLocking>::SetTo(
area != NULL ? vm_area_get_locked_cache(area) : NULL, true, true); area != NULL ? vm_area_get_locked_cache(area) : NULL, true, true);
} }
}; };
@@ -205,7 +205,7 @@ static uint32 sPageFaults;
#if DEBUG_CACHE_LIST #if DEBUG_CACHE_LIST
struct cache_info { struct cache_info {
vm_cache* cache; VMCache* cache;
addr_t page_count; addr_t page_count;
addr_t committed; addr_t committed;
}; };
@@ -222,7 +222,7 @@ static VMAddressSpace* get_address_space_by_area_id(area_id id);
static status_t vm_soft_fault(VMAddressSpace* addressSpace, addr_t address, static status_t vm_soft_fault(VMAddressSpace* addressSpace, addr_t address,
bool isWrite, bool isUser); bool isWrite, bool isUser);
static status_t map_backing_store(VMAddressSpace* addressSpace, static status_t map_backing_store(VMAddressSpace* addressSpace,
vm_cache* cache, void** _virtualAddress, off_t offset, addr_t size, VMCache* cache, void** _virtualAddress, off_t offset, addr_t size,
uint32 addressSpec, int wiring, int protection, int mapping, uint32 addressSpec, int wiring, int protection, int mapping,
VMArea** _area, const char* areaName, bool unmapAddressRange, bool kernel); VMArea** _area, const char* areaName, bool unmapAddressRange, bool kernel);
@@ -673,7 +673,7 @@ MultiAddressSpaceLocker::Unlock()
status_t status_t
MultiAddressSpaceLocker::AddAreaCacheAndLock(area_id areaID, MultiAddressSpaceLocker::AddAreaCacheAndLock(area_id areaID,
bool writeLockThisOne, bool writeLockOthers, VMArea*& _area, bool writeLockThisOne, bool writeLockOthers, VMArea*& _area,
vm_cache** _cache) VMCache** _cache)
{ {
// remember the original state // remember the original state
int originalCount = fCount; int originalCount = fCount;
@@ -687,7 +687,7 @@ MultiAddressSpaceLocker::AddAreaCacheAndLock(area_id areaID,
ArrayDeleter<lock_item> _(originalItems); ArrayDeleter<lock_item> _(originalItems);
// get the cache // get the cache
vm_cache* cache; VMCache* cache;
VMArea* area; VMArea* area;
status_t error; status_t error;
{ {
@@ -732,7 +732,7 @@ MultiAddressSpaceLocker::AddAreaCacheAndLock(area_id areaID,
} }
// lock the cache // lock the cache
vm_cache* oldCache = cache; VMCache* oldCache = cache;
cache = vm_area_get_locked_cache(area); cache = vm_area_get_locked_cache(area);
// If neither the area's cache has changed nor its area list we're // If neither the area's cache has changed nor its area list we're
@@ -1451,7 +1451,7 @@ cut_area(VMAddressSpace* addressSpace, VMArea* area, addr_t address,
} }
AreaCacheLocker cacheLocker(area); AreaCacheLocker cacheLocker(area);
vm_cache* cache = area->cache; VMCache* cache = area->cache;
// Cut the end only? // Cut the end only?
if (areaLast <= lastAddress) { if (areaLast <= lastAddress) {
@@ -1614,7 +1614,7 @@ unmap_address_range(VMAddressSpace* addressSpace, addr_t address, addr_t size,
Note, that in case of error your cache will be temporarily unlocked. Note, that in case of error your cache will be temporarily unlocked.
*/ */
static status_t static status_t
map_backing_store(VMAddressSpace* addressSpace, vm_cache* cache, map_backing_store(VMAddressSpace* addressSpace, VMCache* cache,
void** _virtualAddress, off_t offset, addr_t size, uint32 addressSpec, void** _virtualAddress, off_t offset, addr_t size, uint32 addressSpec,
int wiring, int protection, int mapping, VMArea** _area, int wiring, int protection, int mapping, VMArea** _area,
const char* areaName, bool unmapAddressRange, bool kernel) const char* areaName, bool unmapAddressRange, bool kernel)
@@ -1634,9 +1634,9 @@ map_backing_store(VMAddressSpace* addressSpace, vm_cache* cache,
// if this is a private map, we need to create a new cache // if this is a private map, we need to create a new cache
// to handle the private copies of pages as they are written to // to handle the private copies of pages as they are written to
vm_cache* sourceCache = cache; VMCache* sourceCache = cache;
if (mapping == REGION_PRIVATE_MAP) { if (mapping == REGION_PRIVATE_MAP) {
vm_cache* newCache; VMCache* newCache;
// create an anonymous cache // create an anonymous cache
status = VMCacheFactory::CreateAnonymousCache(newCache, status = VMCacheFactory::CreateAnonymousCache(newCache,
@@ -1739,7 +1739,7 @@ vm_block_address_range(const char* name, void* address, addr_t size)
VMAddressSpace* addressSpace = locker.AddressSpace(); VMAddressSpace* addressSpace = locker.AddressSpace();
// create an anonymous cache // create an anonymous cache
vm_cache* cache; VMCache* cache;
status = VMCacheFactory::CreateAnonymousCache(cache, false, 0, 0, false); status = VMCacheFactory::CreateAnonymousCache(cache, false, 0, 0, false);
if (status != B_OK) if (status != B_OK)
return status; return status;
@@ -1853,7 +1853,7 @@ vm_create_anonymous_area(team_id team, const char* name, void** address,
addr_t physicalAddress, uint32 flags, bool kernel) addr_t physicalAddress, uint32 flags, bool kernel)
{ {
VMArea* area; VMArea* area;
vm_cache* cache; VMCache* cache;
vm_page* page = NULL; vm_page* page = NULL;
bool isStack = (protection & B_STACK_AREA) != 0; bool isStack = (protection & B_STACK_AREA) != 0;
page_num_t guardPages; page_num_t guardPages;
@@ -2182,7 +2182,7 @@ vm_map_physical_memory(team_id team, const char* name, void** _address,
uint32 addressSpec, addr_t size, uint32 protection, addr_t physicalAddress) uint32 addressSpec, addr_t size, uint32 protection, addr_t physicalAddress)
{ {
VMArea* area; VMArea* area;
vm_cache* cache; VMCache* cache;
addr_t mapOffset; addr_t mapOffset;
TRACE(("vm_map_physical_memory(aspace = %ld, \"%s\", virtual = %p, " TRACE(("vm_map_physical_memory(aspace = %ld, \"%s\", virtual = %p, "
@@ -2295,7 +2295,7 @@ vm_map_physical_memory_vecs(team_id team, const char* name, void** _address,
} }
// create a device cache // create a device cache
vm_cache* cache; VMCache* cache;
status_t result = VMCacheFactory::CreateDeviceCache(cache, status_t result = VMCacheFactory::CreateDeviceCache(cache,
(addr_t)vecs[0].iov_base); (addr_t)vecs[0].iov_base);
if (result != B_OK) if (result != B_OK)
@@ -2360,7 +2360,7 @@ vm_create_null_area(team_id team, const char* name, void** address,
uint32 addressSpec, addr_t size) uint32 addressSpec, addr_t size)
{ {
VMArea* area; VMArea* area;
vm_cache* cache; VMCache* cache;
status_t status; status_t status;
AddressSpaceWriteLocker locker(team); AddressSpaceWriteLocker locker(team);
@@ -2523,7 +2523,7 @@ _vm_map_file(team_id team, const char* name, void** _address,
return B_BAD_TEAM_ID; return B_BAD_TEAM_ID;
// TODO: this only works for file systems that use the file cache // TODO: this only works for file systems that use the file cache
vm_cache* cache; VMCache* cache;
status = vfs_get_vnode_cache(vnode, &cache, false); status = vfs_get_vnode_cache(vnode, &cache, false);
if (status < B_OK) if (status < B_OK)
return status; return status;
@@ -2573,13 +2573,13 @@ vm_map_file(team_id aid, const char* name, void** address, uint32 addressSpec,
} }
vm_cache* VMCache*
vm_area_get_locked_cache(VMArea* area) vm_area_get_locked_cache(VMArea* area)
{ {
mutex_lock(&sAreaCacheLock); mutex_lock(&sAreaCacheLock);
while (true) { while (true) {
vm_cache* cache = area->cache; VMCache* cache = area->cache;
if (!cache->SwitchLock(&sAreaCacheLock)) { if (!cache->SwitchLock(&sAreaCacheLock)) {
// cache has been deleted // cache has been deleted
@@ -2602,7 +2602,7 @@ vm_area_get_locked_cache(VMArea* area)
void void
vm_area_put_locked_cache(vm_cache* cache) vm_area_put_locked_cache(VMCache* cache)
{ {
cache->ReleaseRefAndUnlock(); cache->ReleaseRefAndUnlock();
} }
@@ -2655,7 +2655,7 @@ vm_clone_area(team_id team, const char* name, void** address,
if (!kernel && (sourceArea->protection & B_KERNEL_AREA) != 0) if (!kernel && (sourceArea->protection & B_KERNEL_AREA) != 0)
return B_NOT_ALLOWED; return B_NOT_ALLOWED;
vm_cache* cache = vm_area_get_locked_cache(sourceArea); VMCache* cache = vm_area_get_locked_cache(sourceArea);
// TODO: for now, B_USER_CLONEABLE is disabled, until all drivers // TODO: for now, B_USER_CLONEABLE is disabled, until all drivers
// have been adapted. Maybe it should be part of the kernel settings, // have been adapted. Maybe it should be part of the kernel settings,
@@ -2830,9 +2830,9 @@ vm_delete_area(team_id team, area_id id, bool kernel)
- All of the cache's areas' address spaces must be read locked. - All of the cache's areas' address spaces must be read locked.
*/ */
static status_t static status_t
vm_copy_on_write_area(vm_cache* lowerCache) vm_copy_on_write_area(VMCache* lowerCache)
{ {
vm_cache* upperCache; VMCache* upperCache;
TRACE(("vm_copy_on_write_area(cache = %p)\n", lowerCache)); TRACE(("vm_copy_on_write_area(cache = %p)\n", lowerCache));
@@ -2909,7 +2909,7 @@ vm_copy_area(team_id team, const char* name, void** _address,
// the source cache, and the cache itself. // the source cache, and the cache itself.
MultiAddressSpaceLocker locker; MultiAddressSpaceLocker locker;
VMAddressSpace* targetAddressSpace; VMAddressSpace* targetAddressSpace;
vm_cache* cache; VMCache* cache;
VMArea* source; VMArea* source;
status_t status = locker.AddTeam(team, true, &targetAddressSpace); status_t status = locker.AddTeam(team, true, &targetAddressSpace);
if (status == B_OK) { if (status == B_OK) {
@@ -2962,7 +2962,7 @@ vm_copy_area(team_id team, const char* name, void** _address,
//! You need to hold the cache lock when calling this function //! You need to hold the cache lock when calling this function
static int32 static int32
count_writable_areas(vm_cache* cache, VMArea* ignoreArea) count_writable_areas(VMCache* cache, VMArea* ignoreArea)
{ {
struct VMArea* area = cache->areas; struct VMArea* area = cache->areas;
uint32 count = 0; uint32 count = 0;
@@ -2989,7 +2989,7 @@ vm_set_area_protection(team_id team, area_id areaID, uint32 newProtection,
// lock address spaces and cache // lock address spaces and cache
MultiAddressSpaceLocker locker; MultiAddressSpaceLocker locker;
vm_cache* cache; VMCache* cache;
VMArea* area; VMArea* area;
status_t status = locker.AddAreaCacheAndLock(areaID, true, false, area, status_t status = locker.AddAreaCacheAndLock(areaID, true, false, area,
&cache); &cache);
@@ -3620,8 +3620,8 @@ display_mem(int argc, char** argv)
static void static void
dump_cache_tree_recursively(vm_cache* cache, int level, dump_cache_tree_recursively(VMCache* cache, int level,
vm_cache* highlightCache) VMCache* highlightCache)
{ {
// print this cache // print this cache
for (int i = 0; i < level; i++) for (int i = 0; i < level; i++)
@@ -3632,8 +3632,8 @@ dump_cache_tree_recursively(vm_cache* cache, int level,
kprintf("%p\n", cache); kprintf("%p\n", cache);
// recursively print its consumers // recursively print its consumers
vm_cache* consumer = NULL; VMCache* consumer = NULL;
while ((consumer = (vm_cache*)list_get_next_item(&cache->consumers, while ((consumer = (VMCache*)list_get_next_item(&cache->consumers,
consumer)) != NULL) { consumer)) != NULL) {
dump_cache_tree_recursively(consumer, level + 1, highlightCache); dump_cache_tree_recursively(consumer, level + 1, highlightCache);
} }
@@ -3652,8 +3652,8 @@ dump_cache_tree(int argc, char** argv)
if (address == 0) if (address == 0)
return 0; return 0;
vm_cache* cache = (vm_cache*)address; VMCache* cache = (VMCache*)address;
vm_cache* root = cache; VMCache* root = cache;
// find the root cache (the transitive source) // find the root cache (the transitive source)
while (root->source != NULL) while (root->source != NULL)
@@ -3687,15 +3687,15 @@ cache_type_to_string(int32 type)
#if DEBUG_CACHE_LIST #if DEBUG_CACHE_LIST
static void static void
update_cache_info_recursively(vm_cache* cache, cache_info& info) update_cache_info_recursively(VMCache* cache, cache_info& info)
{ {
info.page_count += cache->page_count; info.page_count += cache->page_count;
if (cache->type == CACHE_TYPE_RAM) if (cache->type == CACHE_TYPE_RAM)
info.committed += cache->committed_size; info.committed += cache->committed_size;
// recurse // recurse
vm_cache* consumer = NULL; VMCache* consumer = NULL;
while ((consumer = (vm_cache*)list_get_next_item(&cache->consumers, while ((consumer = (VMCache*)list_get_next_item(&cache->consumers,
consumer)) != NULL) { consumer)) != NULL) {
update_cache_info_recursively(consumer, info); update_cache_info_recursively(consumer, info);
} }
@@ -3725,7 +3725,7 @@ cache_info_compare_committed(const void* _a, const void* _b)
static void static void
dump_caches_recursively(vm_cache* cache, cache_info& info, int level) dump_caches_recursively(VMCache* cache, cache_info& info, int level)
{ {
for (int i = 0; i < level; i++) for (int i = 0; i < level; i++)
kprintf(" "); kprintf(" ");
@@ -3759,8 +3759,8 @@ dump_caches_recursively(vm_cache* cache, cache_info& info, int level)
kputs("\n"); kputs("\n");
// recurse // recurse
vm_cache* consumer = NULL; VMCache* consumer = NULL;
while ((consumer = (vm_cache*)list_get_next_item(&cache->consumers, while ((consumer = (VMCache*)list_get_next_item(&cache->consumers,
consumer)) != NULL) { consumer)) != NULL) {
dump_caches_recursively(consumer, info, level + 1); dump_caches_recursively(consumer, info, level + 1);
} }
@@ -3791,7 +3791,7 @@ dump_caches(int argc, char** argv)
off_t totalCommitted = 0; off_t totalCommitted = 0;
page_num_t totalPages = 0; page_num_t totalPages = 0;
vm_cache* cache = gDebugCacheList; VMCache* cache = gDebugCacheList;
while (cache) { while (cache) {
totalCount++; totalCount++;
if (cache->source == NULL) { if (cache->source == NULL) {
@@ -3840,7 +3840,7 @@ dump_caches(int argc, char** argv)
static int static int
dump_cache(int argc, char** argv) dump_cache(int argc, char** argv)
{ {
vm_cache* cache; VMCache* cache;
bool showPages = false; bool showPages = false;
int i = 1; int i = 1;
@@ -3868,7 +3868,7 @@ dump_cache(int argc, char** argv)
if (address == 0) if (address == 0)
return 0; return 0;
cache = (vm_cache*)address; cache = (VMCache*)address;
kprintf("CACHE %p:\n", cache); kprintf("CACHE %p:\n", cache);
kprintf(" ref_count: %ld\n", cache->RefCount()); kprintf(" ref_count: %ld\n", cache->RefCount());
@@ -3892,8 +3892,8 @@ dump_cache(int argc, char** argv)
} }
kprintf(" consumers:\n"); kprintf(" consumers:\n");
vm_cache* consumer = NULL; VMCache* consumer = NULL;
while ((consumer = (vm_cache*)list_get_next_item(&cache->consumers, while ((consumer = (VMCache*)list_get_next_item(&cache->consumers,
consumer)) != NULL) { consumer)) != NULL) {
kprintf("\t%p\n", consumer); kprintf("\t%p\n", consumer);
} }
@@ -4545,11 +4545,11 @@ vm_init(kernel_args* args)
add_debugger_command("areas", &dump_area_list, "Dump a list of all areas"); add_debugger_command("areas", &dump_area_list, "Dump a list of all areas");
add_debugger_command("area", &dump_area, add_debugger_command("area", &dump_area,
"Dump info about a particular area"); "Dump info about a particular area");
add_debugger_command("cache", &dump_cache, "Dump vm_cache"); add_debugger_command("cache", &dump_cache, "Dump VMCache");
add_debugger_command("cache_tree", &dump_cache_tree, "Dump vm_cache tree"); add_debugger_command("cache_tree", &dump_cache_tree, "Dump VMCache tree");
#if DEBUG_CACHE_LIST #if DEBUG_CACHE_LIST
add_debugger_command_etc("caches", &dump_caches, add_debugger_command_etc("caches", &dump_caches,
"List all vm_cache trees", "List all VMCache trees",
"[ \"-c\" ]\n" "[ \"-c\" ]\n"
"All cache trees are listed sorted in decreasing order by number of\n" "All cache trees are listed sorted in decreasing order by number of\n"
"used pages or, if \"-c\" is specified, by size of committed memory.\n", "used pages or, if \"-c\" is specified, by size of committed memory.\n",
@@ -4845,7 +4845,7 @@ struct PageFaultContext {
VMCacheChainLocker cacheChainLocker; VMCacheChainLocker cacheChainLocker;
vm_translation_map* map; vm_translation_map* map;
vm_cache* topCache; VMCache* topCache;
off_t cacheOffset; off_t cacheOffset;
bool isWrite; bool isWrite;
@@ -4901,8 +4901,8 @@ struct PageFaultContext {
static inline status_t static inline status_t
fault_get_page(PageFaultContext& context) fault_get_page(PageFaultContext& context)
{ {
vm_cache* cache = context.topCache; VMCache* cache = context.topCache;
vm_cache* lastCache = NULL; VMCache* lastCache = NULL;
vm_page* page = NULL; vm_page* page = NULL;
while (cache != NULL) { while (cache != NULL) {
@@ -5387,7 +5387,7 @@ fill_area_info(struct VMArea* area, area_info* info, size_t size)
info->out_count = 0; info->out_count = 0;
// TODO: retrieve real values here! // TODO: retrieve real values here!
vm_cache* 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;
@@ -5434,7 +5434,7 @@ vm_resize_area(area_id areaID, size_t newSize, bool kernel)
// lock all affected address spaces and the cache // lock all affected address spaces and the cache
VMArea* area; VMArea* area;
vm_cache* cache; VMCache* cache;
MultiAddressSpaceLocker locker; MultiAddressSpaceLocker locker;
status_t status = locker.AddAreaCacheAndLock(areaID, true, true, area, status_t status = locker.AddAreaCacheAndLock(areaID, true, true, area,
@@ -6633,7 +6633,7 @@ _user_sync_memory(void* _address, size_t size, int flags)
AreaCacheLocker cacheLocker(area); AreaCacheLocker cacheLocker(area);
if (!cacheLocker) if (!cacheLocker)
return B_BAD_VALUE; return B_BAD_VALUE;
vm_cache* cache = area->cache; VMCache* cache = area->cache;
locker.Unlock(); locker.Unlock();
+4 -4
View File
@@ -40,7 +40,7 @@
#if DEBUG_CACHE_LIST #if DEBUG_CACHE_LIST
VMCache* gDebugCacheList; VMCache* gDebugCacheList;
#endif #endif
static mutex sCacheListLock = MUTEX_INITIALIZER("global vm_cache list"); static mutex sCacheListLock = MUTEX_INITIALIZER("global VMCache list");
// The lock is also needed when the debug feature is disabled. // The lock is also needed when the debug feature is disabled.
@@ -323,7 +323,7 @@ vm_cache_acquire_locked_page_cache(vm_page* page, bool dontWait)
mutex_lock(&sCacheListLock); mutex_lock(&sCacheListLock);
while (dontWait) { while (dontWait) {
vm_cache* cache = page->cache; VMCache* cache = page->cache;
if (cache == NULL || !cache->TryLock()) { if (cache == NULL || !cache->TryLock()) {
mutex_unlock(&sCacheListLock); mutex_unlock(&sCacheListLock);
return NULL; return NULL;
@@ -340,7 +340,7 @@ vm_cache_acquire_locked_page_cache(vm_page* page, bool dontWait)
} }
while (true) { while (true) {
vm_cache* cache = page->cache; VMCache* cache = page->cache;
if (cache == NULL) { if (cache == NULL) {
mutex_unlock(&sCacheListLock); mutex_unlock(&sCacheListLock);
return NULL; return NULL;
@@ -392,7 +392,7 @@ VMCache::~VMCache()
status_t status_t
VMCache::Init(uint32 cacheType) VMCache::Init(uint32 cacheType)
{ {
mutex_init(&fLock, "vm_cache"); mutex_init(&fLock, "VMCache");
VMCache dummyCache; VMCache dummyCache;
list_init_etc(&consumers, offset_of_member(dummyCache, consumer_link)); list_init_etc(&consumers, offset_of_member(dummyCache, consumer_link));
areas = NULL; areas = NULL;
+1 -1
View File
@@ -81,7 +81,7 @@ PageCacheLocker::Lock(vm_page* page, bool dontWait)
return false; return false;
// Grab a reference to this cache. // Grab a reference to this cache.
vm_cache* cache = vm_cache_acquire_locked_page_cache(page, dontWait); VMCache* cache = vm_cache_acquire_locked_page_cache(page, dontWait);
if (cache == NULL) if (cache == NULL)
return false; return false;
+5 -5
View File
@@ -1437,7 +1437,7 @@ page_writer(void* /*unused*/)
if (!cacheLocker.IsLocked()) if (!cacheLocker.IsLocked())
continue; continue;
vm_cache *cache = page->cache; VMCache *cache = page->cache;
// Don't write back wired (locked) pages and don't write RAM pages // Don't write back wired (locked) pages and don't write RAM pages
// until we're low on pages. Also avoid writing temporary pages that // until we're low on pages. Also avoid writing temporary pages that
@@ -1696,7 +1696,7 @@ steal_pages(vm_page **pages, size_t count, bool reserve)
/*! Writes a range of modified pages of a cache to disk. /*! Writes a range of modified pages of a cache to disk.
You need to hold the vm_cache lock when calling this function. You need to hold the VMCache lock when calling this function.
Note that the cache lock is released in this function. Note that the cache lock is released in this function.
\param cache The cache. \param cache The cache.
\param firstPage Offset (in page size units) of the first page in the range. \param firstPage Offset (in page size units) of the first page in the range.
@@ -1810,11 +1810,11 @@ vm_page_write_modified_page_range(struct VMCache* cache, uint32 firstPage,
} }
/*! You need to hold the vm_cache lock when calling this function. /*! You need to hold the VMCache lock when calling this function.
Note that the cache lock is released in this function. Note that the cache lock is released in this function.
*/ */
status_t status_t
vm_page_write_modified_pages(vm_cache *cache) vm_page_write_modified_pages(VMCache *cache)
{ {
return vm_page_write_modified_page_range(cache, 0, return vm_page_write_modified_page_range(cache, 0,
(cache->virtual_end + B_PAGE_SIZE - 1) >> PAGE_SHIFT); (cache->virtual_end + B_PAGE_SIZE - 1) >> PAGE_SHIFT);
@@ -2364,7 +2364,7 @@ vm_lookup_page(addr_t pageNumber)
if the page does not equal PAGE_STATE_MODIFIED. if the page does not equal PAGE_STATE_MODIFIED.
*/ */
void void
vm_page_free(vm_cache *cache, vm_page *page) vm_page_free(VMCache *cache, vm_page *page)
{ {
MutexLocker _(sPageLock); MutexLocker _(sPageLock);