* Decoupled block_cache_used_memory() from the sCachesLock - this should fix the
UI freezes (ActivityMonitor and ProcessController both use get_system_info() a lot), although this is only the symptom of another problem. * The downside is that the block cache usage information isn't as up to date as it was previously - it's updated by the block write/notifier thread now (worst case every 2 seconds). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31812 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5efec82035
commit
eb26e782f3
33
src/system/kernel/cache/block_cache.cpp
vendored
33
src/system/kernel/cache/block_cache.cpp
vendored
@ -552,8 +552,12 @@ static status_t write_cached_block(block_cache* cache, cached_block* block,
|
|||||||
|
|
||||||
static DoublyLinkedList<block_cache> sCaches;
|
static DoublyLinkedList<block_cache> sCaches;
|
||||||
static mutex sCachesLock = MUTEX_INITIALIZER("block caches");
|
static mutex sCachesLock = MUTEX_INITIALIZER("block caches");
|
||||||
|
static mutex sCachesMemoryUseLock
|
||||||
|
= MUTEX_INITIALIZER("block caches memory use");
|
||||||
|
static size_t sUsedMemory;
|
||||||
static sem_id sEventSemaphore;
|
static sem_id sEventSemaphore;
|
||||||
static mutex sNotificationsLock = MUTEX_INITIALIZER("block cache notifications");
|
static mutex sNotificationsLock
|
||||||
|
= MUTEX_INITIALIZER("block cache notifications");
|
||||||
static thread_id sNotifierWriterThread;
|
static thread_id sNotifierWriterThread;
|
||||||
static DoublyLinkedListLink<block_cache> sMarkCache;
|
static DoublyLinkedListLink<block_cache> sMarkCache;
|
||||||
// TODO: this only works if the link is the first entry of block_cache
|
// TODO: this only works if the link is the first entry of block_cache
|
||||||
@ -1916,6 +1920,7 @@ block_notifier_and_writer(void* /*data*/)
|
|||||||
// write 64 blocks of each block_cache every two seconds
|
// write 64 blocks of each block_cache every two seconds
|
||||||
// TODO: change this once we have an I/O scheduler
|
// TODO: change this once we have an I/O scheduler
|
||||||
timeout = kTimeout;
|
timeout = kTimeout;
|
||||||
|
size_t usedMemory = 0;
|
||||||
|
|
||||||
block_cache* cache = NULL;
|
block_cache* cache = NULL;
|
||||||
while ((cache = get_next_locked_block_cache(cache)) != NULL) {
|
while ((cache = get_next_locked_block_cache(cache)) != NULL) {
|
||||||
@ -1923,6 +1928,10 @@ block_notifier_and_writer(void* /*data*/)
|
|||||||
cached_block* blocks[kMaxCount];
|
cached_block* blocks[kMaxCount];
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
|
|
||||||
|
size_t cacheUsedMemory;
|
||||||
|
object_cache_get_usage(cache->buffer_cache, &cacheUsedMemory);
|
||||||
|
usedMemory += cacheUsedMemory;
|
||||||
|
|
||||||
if (cache->num_dirty_blocks) {
|
if (cache->num_dirty_blocks) {
|
||||||
// This cache is not using transactions, we'll scan the blocks
|
// This cache is not using transactions, we'll scan the blocks
|
||||||
// directly
|
// directly
|
||||||
@ -1976,6 +1985,9 @@ block_notifier_and_writer(void* /*data*/)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MutexLocker _(sCachesMemoryUseLock);
|
||||||
|
sUsedMemory = usedMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// never can get here
|
// never can get here
|
||||||
@ -2098,23 +2110,10 @@ block_cache_init(void)
|
|||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
block_cache_used_memory()
|
block_cache_used_memory(void)
|
||||||
{
|
{
|
||||||
size_t usedMemory = 0;
|
MutexLocker _(sCachesMemoryUseLock);
|
||||||
|
return sUsedMemory;
|
||||||
MutexLocker _(sCachesLock);
|
|
||||||
|
|
||||||
DoublyLinkedList<block_cache>::Iterator it = sCaches.GetIterator();
|
|
||||||
while (block_cache* cache = it.Next()) {
|
|
||||||
if (cache == (block_cache*)&sMarkCache)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
size_t cacheUsedMemory;
|
|
||||||
object_cache_get_usage(cache->buffer_cache, &cacheUsedMemory);
|
|
||||||
usedMemory += cacheUsedMemory;
|
|
||||||
}
|
|
||||||
|
|
||||||
return usedMemory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user