From 414774d79f46363826bae4776b04fd98315b9fdf Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 22 Jan 2025 16:19:33 -0500 Subject: [PATCH] kernel/vm: Rename VMCache::HasPage to StoreHasPage. It checks whether the page or page's data is present in an underlying "backing store", not whether the page is present in the cache itself. No functional change intended. --- headers/private/kernel/vm/VMCache.h | 4 ++-- src/system/kernel/cache/vnode_store.cpp | 4 ++-- src/system/kernel/cache/vnode_store.h | 2 +- src/system/kernel/vm/VMAnonymousCache.cpp | 6 +++--- src/system/kernel/vm/VMAnonymousCache.h | 4 ++-- src/system/kernel/vm/VMAnonymousNoSwapCache.cpp | 2 +- src/system/kernel/vm/VMAnonymousNoSwapCache.h | 2 +- src/system/kernel/vm/VMCache.cpp | 8 ++++---- src/system/kernel/vm/vm.cpp | 2 +- src/system/kernel/vm/vm_debug.cpp | 2 +- src/system/kernel/vm/vm_page.cpp | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/headers/private/kernel/vm/VMCache.h b/headers/private/kernel/vm/VMCache.h index 584f4919d5..7b9a83fec9 100644 --- a/headers/private/kernel/vm/VMCache.h +++ b/headers/private/kernel/vm/VMCache.h @@ -152,7 +152,7 @@ public: // backing store operations virtual bool CanOvercommit(); virtual status_t Commit(off_t size, int priority); - virtual bool HasPage(off_t offset); + virtual bool StoreHasPage(off_t offset); virtual status_t Read(off_t offset, const generic_io_vec *vecs, size_t count, uint32 flags, @@ -180,7 +180,7 @@ public: virtual void AcquireStoreRef(); virtual void ReleaseStoreRef(); - virtual bool DebugHasPage(off_t offset); + virtual bool DebugStoreHasPage(off_t offset); vm_page* DebugLookupPage(off_t offset); virtual void Dump(bool showPages) const; diff --git a/src/system/kernel/cache/vnode_store.cpp b/src/system/kernel/cache/vnode_store.cpp index 663135a9d0..c1f7472b15 100644 --- a/src/system/kernel/cache/vnode_store.cpp +++ b/src/system/kernel/cache/vnode_store.cpp @@ -47,7 +47,7 @@ VMVnodeCache::Commit(off_t size, int priority) bool -VMVnodeCache::HasPage(off_t offset) +VMVnodeCache::StoreHasPage(off_t offset) { return ROUNDUP(offset, B_PAGE_SIZE) >= virtual_base && offset < virtual_end; @@ -114,7 +114,7 @@ VMVnodeCache::WriteAsync(off_t offset, const generic_io_vec* vecs, size_t count, status_t VMVnodeCache::Fault(struct VMAddressSpace* aspace, off_t offset) { - if (!HasPage(offset)) + if (!StoreHasPage(offset)) return B_BAD_ADDRESS; // vm_soft_fault() reads the page in. diff --git a/src/system/kernel/cache/vnode_store.h b/src/system/kernel/cache/vnode_store.h index c7386c06bc..78b73014aa 100644 --- a/src/system/kernel/cache/vnode_store.h +++ b/src/system/kernel/cache/vnode_store.h @@ -19,7 +19,7 @@ public: uint32 allocationFlags); virtual status_t Commit(off_t size, int priority); - virtual bool HasPage(off_t offset); + virtual bool StoreHasPage(off_t offset); virtual status_t Read(off_t offset, const generic_io_vec* vecs, size_t count, uint32 flags, diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp b/src/system/kernel/vm/VMAnonymousCache.cpp index 8db5ba32c2..9b358abc58 100644 --- a/src/system/kernel/vm/VMAnonymousCache.cpp +++ b/src/system/kernel/vm/VMAnonymousCache.cpp @@ -750,7 +750,7 @@ VMAnonymousCache::CanOvercommit() bool -VMAnonymousCache::HasPage(off_t offset) +VMAnonymousCache::StoreHasPage(off_t offset) { if (_SwapBlockGetAddress(offset >> PAGE_SHIFT) != SWAP_SLOT_NONE) return true; @@ -760,7 +760,7 @@ VMAnonymousCache::HasPage(off_t offset) bool -VMAnonymousCache::DebugHasPage(off_t offset) +VMAnonymousCache::DebugStoreHasPage(off_t offset) { off_t pageIndex = offset >> PAGE_SHIFT; swap_hash_key key = { this, pageIndex }; @@ -991,7 +991,7 @@ VMAnonymousCache::Fault(struct VMAddressSpace* aspace, off_t offset) } } - if (fCanOvercommit && LookupPage(offset) == NULL && !HasPage(offset)) { + if (fCanOvercommit && LookupPage(offset) == NULL && !StoreHasPage(offset)) { if (fPrecommittedPages == 0) { // never commit more than needed if (committed_size / B_PAGE_SIZE > page_count) diff --git a/src/system/kernel/vm/VMAnonymousCache.h b/src/system/kernel/vm/VMAnonymousCache.h index 1409103714..00da13830f 100644 --- a/src/system/kernel/vm/VMAnonymousCache.h +++ b/src/system/kernel/vm/VMAnonymousCache.h @@ -51,8 +51,8 @@ public: virtual bool CanOvercommit(); virtual status_t Commit(off_t size, int priority); - virtual bool HasPage(off_t offset); - virtual bool DebugHasPage(off_t offset); + virtual bool StoreHasPage(off_t offset); + virtual bool DebugStoreHasPage(off_t offset); virtual int32 GuardSize() { return fGuardedSize; } virtual void SetGuardSize(int32 guardSize) diff --git a/src/system/kernel/vm/VMAnonymousNoSwapCache.cpp b/src/system/kernel/vm/VMAnonymousNoSwapCache.cpp index d5d7276f0f..3d31a3d21e 100644 --- a/src/system/kernel/vm/VMAnonymousNoSwapCache.cpp +++ b/src/system/kernel/vm/VMAnonymousNoSwapCache.cpp @@ -113,7 +113,7 @@ VMAnonymousNoSwapCache::CanOvercommit() bool -VMAnonymousNoSwapCache::HasPage(off_t offset) +VMAnonymousNoSwapCache::StoreHasPage(off_t offset) { return false; } diff --git a/src/system/kernel/vm/VMAnonymousNoSwapCache.h b/src/system/kernel/vm/VMAnonymousNoSwapCache.h index 8acda57f92..d8c034eb1b 100644 --- a/src/system/kernel/vm/VMAnonymousNoSwapCache.h +++ b/src/system/kernel/vm/VMAnonymousNoSwapCache.h @@ -26,7 +26,7 @@ public: virtual bool CanOvercommit(); virtual status_t Commit(off_t size, int priority); - virtual bool HasPage(off_t offset); + virtual bool StoreHasPage(off_t offset); virtual int32 GuardSize() { return fGuardedSize; } virtual void SetGuardSize(int32 guardSize) diff --git a/src/system/kernel/vm/VMCache.cpp b/src/system/kernel/vm/VMCache.cpp index e091f45947..ee61266ec3 100644 --- a/src/system/kernel/vm/VMCache.cpp +++ b/src/system/kernel/vm/VMCache.cpp @@ -1323,7 +1323,7 @@ VMCache::Commit(off_t size, int priority) changes in the meantime). */ bool -VMCache::HasPage(off_t offset) +VMCache::StoreHasPage(off_t offset) { // In accordance with Fault() the default implementation doesn't have a // backing store and doesn't allow faults. @@ -1425,14 +1425,14 @@ VMCache::ReleaseStoreRef() } -/*! Kernel debugger version of HasPage(). +/*! Kernel debugger version of StoreHasPage(). Does not do any locking. */ bool -VMCache::DebugHasPage(off_t offset) +VMCache::DebugStoreHasPage(off_t offset) { // default that works for all subclasses that don't lock anyway - return HasPage(offset); + return StoreHasPage(offset); } diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 908d07af7f..396ea5c62a 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -4316,7 +4316,7 @@ fault_get_page(PageFaultContext& context) // The current cache does not contain the page we're looking for. // see if the backing store has it - if (cache->HasPage(context.cacheOffset)) { + if (cache->StoreHasPage(context.cacheOffset)) { // insert a fresh page and mark it busy -- we're going to read it in page = vm_page_allocate_page(&context.reservation, PAGE_STATE_ACTIVE | VM_PAGE_ALLOC_BUSY); diff --git a/src/system/kernel/vm/vm_debug.cpp b/src/system/kernel/vm/vm_debug.cpp index caec6b85f2..a038bec6b8 100644 --- a/src/system/kernel/vm/vm_debug.cpp +++ b/src/system/kernel/vm/vm_debug.cpp @@ -809,7 +809,7 @@ vm_debug_copy_page_memory(team_id teamID, void* unsafeMemory, void* buffer, // Page not found in this cache -- if it is paged out, we must not try // to get it from lower caches. - if (cache->DebugHasPage(cacheOffset)) + if (cache->DebugStoreHasPage(cacheOffset)) break; cache = cache->source; diff --git a/src/system/kernel/vm/vm_page.cpp b/src/system/kernel/vm/vm_page.cpp index e103b31d46..67ee73797c 100644 --- a/src/system/kernel/vm/vm_page.cpp +++ b/src/system/kernel/vm/vm_page.cpp @@ -2587,7 +2587,7 @@ free_page_swap_space(int32 index) VMCache* cache = page->Cache(); if (cache->temporary && page->WiredCount() == 0 - && cache->HasPage(page->cache_offset << PAGE_SHIFT) + && cache->StoreHasPage(page->cache_offset << PAGE_SHIFT) && page->usage_count > 0) { // TODO: how to judge a page is highly active? if (swap_free_page_swap_space(page)) {