kernel/vm: Preparations for VMCache::committed_size removal.
Includes some cleanup to the organization of VMCache.h.
This commit is contained in:
@@ -99,6 +99,13 @@ public:
|
||||
inline void ReleaseRef();
|
||||
inline void ReleaseRefAndUnlock(
|
||||
bool consumerLocked = false);
|
||||
int32 RefCount() const
|
||||
{ return fRefCount; }
|
||||
|
||||
void* UserData() { return fUserData; }
|
||||
void SetUserData(void* data) { fUserData = data; }
|
||||
// Settable by the lock owner and valid as
|
||||
// long as the lock is owned.
|
||||
|
||||
inline VMCacheRef* CacheRef() const { return fCacheRef; }
|
||||
|
||||
@@ -129,9 +136,6 @@ public:
|
||||
void TakeAreasFrom(VMCache* fromCache);
|
||||
uint32 CountWritableAreas(VMArea* ignoreArea) const;
|
||||
|
||||
status_t WriteModified();
|
||||
status_t SetMinimalCommitment(off_t commitment,
|
||||
int priority);
|
||||
virtual status_t Resize(off_t newSize, int priority);
|
||||
virtual status_t Rebase(off_t newBase, int priority);
|
||||
virtual status_t Adopt(VMCache* source, off_t offset, off_t size,
|
||||
@@ -141,20 +145,14 @@ public:
|
||||
|
||||
status_t FlushAndRemoveAllPages();
|
||||
|
||||
void* UserData() { return fUserData; }
|
||||
void SetUserData(void* data) { fUserData = data; }
|
||||
// Settable by the lock owner and valid as
|
||||
// long as the lock is owned.
|
||||
|
||||
// for debugging only
|
||||
int32 RefCount() const
|
||||
{ return fRefCount; }
|
||||
|
||||
// backing store operations
|
||||
status_t SetMinimalCommitment(off_t commitment,
|
||||
int priority);
|
||||
off_t Commitment() const;
|
||||
virtual bool CanOvercommit();
|
||||
virtual status_t Commit(off_t size, int priority);
|
||||
virtual bool StoreHasPage(off_t offset);
|
||||
|
||||
// backing store operations
|
||||
virtual bool StoreHasPage(off_t offset);
|
||||
virtual status_t Read(off_t offset, const generic_io_vec *vecs,
|
||||
size_t count, uint32 flags,
|
||||
generic_size_t *_numBytes);
|
||||
@@ -166,6 +164,7 @@ public:
|
||||
generic_size_t numBytes, uint32 flags,
|
||||
AsyncIOCallback* callback);
|
||||
virtual bool CanWritePage(off_t offset);
|
||||
status_t WriteModified();
|
||||
|
||||
virtual int32 MaxPagesPerWrite() const
|
||||
{ return -1; } // no restriction
|
||||
|
||||
@@ -256,7 +256,7 @@ off_t
|
||||
DataContainer::GetCommittedSize() const
|
||||
{
|
||||
if (_IsCacheMode())
|
||||
return sizeof(VMForVnodeCache) + fCache->committed_size;
|
||||
return sizeof(VMForVnodeCache) + fCache->Commitment();
|
||||
else
|
||||
return fSmallBufferSize;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class SetMinimalCommitment : public VMCacheTraceEntry {
|
||||
SetMinimalCommitment(VMCache* cache, off_t commitment)
|
||||
:
|
||||
VMCacheTraceEntry(cache),
|
||||
fOldCommitment(cache->committed_size),
|
||||
fOldCommitment(cache->Commitment()),
|
||||
fCommitment(commitment)
|
||||
{
|
||||
Initialized();
|
||||
@@ -1080,7 +1080,7 @@ VMCache::SetMinimalCommitment(off_t commitment, int priority)
|
||||
|
||||
// If we don't have enough committed space to cover through to the new end
|
||||
// of the area...
|
||||
if (committed_size < commitment) {
|
||||
if (Commitment() < commitment) {
|
||||
#if KDEBUG
|
||||
const off_t size = PAGE_ALIGN(virtual_end - virtual_base);
|
||||
ASSERT_PRINT(commitment <= size, "cache %p, commitment %" B_PRIdOFF ", size %" B_PRIdOFF,
|
||||
@@ -1307,6 +1307,13 @@ VMCache::FlushAndRemoveAllPages()
|
||||
}
|
||||
|
||||
|
||||
off_t
|
||||
VMCache::Commitment() const
|
||||
{
|
||||
return committed_size;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
VMCache::CanOvercommit()
|
||||
{
|
||||
|
||||
@@ -1175,7 +1175,7 @@ discard_area_range(VMArea* area, addr_t address, addr_t size)
|
||||
cache->Discard(area->cache_offset + offset, size);
|
||||
|
||||
if (commitmentChange != 0)
|
||||
cache->Commit(cache->committed_size + commitmentChange, VM_PRIORITY_USER);
|
||||
cache->Commit(cache->Commitment() + commitmentChange, VM_PRIORITY_USER);
|
||||
|
||||
cache->ReleaseRefAndUnlock();
|
||||
return B_OK;
|
||||
@@ -6567,7 +6567,7 @@ _user_set_memory_protection(void* _address, size_t size, uint32 protection)
|
||||
}
|
||||
|
||||
if (commitmentChange != 0) {
|
||||
off_t newCommitment = topCache->committed_size + commitmentChange;
|
||||
off_t newCommitment = topCache->Commitment() + commitmentChange;
|
||||
const ssize_t topCacheSize = topCache->virtual_end - topCache->virtual_base;
|
||||
if (newCommitment > topCacheSize) {
|
||||
// This should only happen in the case where this process fork()ed,
|
||||
|
||||
@@ -278,7 +278,7 @@ update_cache_info_recursively(VMCache* cache, cache_info& info)
|
||||
{
|
||||
info.page_count += cache->page_count;
|
||||
if (cache->type == CACHE_TYPE_RAM)
|
||||
info.committed += cache->committed_size;
|
||||
info.committed += cache->Commitment();
|
||||
|
||||
// recurse
|
||||
for (VMCache::ConsumerList::Iterator it = cache->consumers.GetIterator();
|
||||
@@ -324,7 +324,7 @@ dump_caches_recursively(VMCache* cache, cache_info& info, int level)
|
||||
kprintf("/%lu", info.page_count);
|
||||
|
||||
if (cache->type == CACHE_TYPE_RAM || (level == 0 && info.committed > 0)) {
|
||||
kprintf(", committed: %" B_PRIdOFF, cache->committed_size);
|
||||
kprintf(", committed: %" B_PRIdOFF, cache->Commitment());
|
||||
|
||||
if (level == 0)
|
||||
kprintf("/%lu", info.committed);
|
||||
|
||||
Reference in New Issue
Block a user