mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
Kernel: Make purgeable memory a VMObject level concept (again)
This patch changes the semantics of purgeable memory. - AnonymousVMObject now has a "purgeable" flag. It can only be set when constructing the object. (Previously, all anonymous memory was effectively purgeable.) - AnonymousVMObject now has a "volatile" flag. It covers the entire range of physical pages. (Previously, we tracked ranges of volatile pages, effectively making it a page-level concept.) - Non-volatile objects maintain a physical page reservation via the committed pages mechanism, to ensure full coverage for page faults. - When an object is made volatile, it relinquishes any unused committed pages immediately. If later made non-volatile again, we then attempt to make a new committed pages reservation. If this fails, we return ENOMEM to userspace. mmap() now creates purgeable objects if passed the MAP_PURGEABLE option together with MAP_ANONYMOUS. anon_create() memory is always purgeable.
This commit is contained in:
parent
6bb53d6a80
commit
2d1a651e0a
17 changed files with 189 additions and 1004 deletions
|
@ -17,7 +17,6 @@
|
|||
#include <Kernel/Sections.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
#include <Kernel/VM/PageFaultResponse.h>
|
||||
#include <Kernel/VM/PurgeablePageRanges.h>
|
||||
#include <Kernel/VM/RangeAllocator.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -28,8 +27,7 @@ enum class ShouldFlushTLB {
|
|||
};
|
||||
|
||||
class Region final
|
||||
: public Weakable<Region>
|
||||
, public PurgeablePageRanges {
|
||||
: public Weakable<Region> {
|
||||
friend class MemoryManager;
|
||||
|
||||
MAKE_SLAB_ALLOCATED(Region)
|
||||
|
@ -201,15 +199,11 @@ public:
|
|||
|
||||
void remap();
|
||||
|
||||
bool remap_vmobject_page_range(size_t page_index, size_t page_count);
|
||||
|
||||
bool is_volatile(VirtualAddress vaddr, size_t size) const;
|
||||
enum class SetVolatileError {
|
||||
Success = 0,
|
||||
NotPurgeable,
|
||||
OutOfMemory
|
||||
};
|
||||
SetVolatileError set_volatile(VirtualAddress vaddr, size_t size, bool is_volatile, bool& was_purged);
|
||||
|
||||
RefPtr<Process> get_owner();
|
||||
|
||||
|
@ -219,7 +213,8 @@ public:
|
|||
private:
|
||||
Region(Range const&, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, OwnPtr<KString>, Region::Access access, Cacheable, bool shared);
|
||||
|
||||
bool do_remap_vmobject_page_range(size_t page_index, size_t page_count);
|
||||
bool remap_vmobject_page(size_t page_index, bool with_flush = true);
|
||||
bool do_remap_vmobject_page(size_t page_index, bool with_flush = true);
|
||||
|
||||
void set_access_bit(Access access, bool b)
|
||||
{
|
||||
|
@ -229,18 +224,12 @@ private:
|
|||
m_access &= ~access;
|
||||
}
|
||||
|
||||
bool do_remap_vmobject_page(size_t index, bool with_flush = true);
|
||||
bool remap_vmobject_page(size_t index, bool with_flush = true);
|
||||
|
||||
PageFaultResponse handle_cow_fault(size_t page_index);
|
||||
PageFaultResponse handle_inode_fault(size_t page_index);
|
||||
PageFaultResponse handle_zero_fault(size_t page_index);
|
||||
|
||||
bool map_individual_page_impl(size_t page_index);
|
||||
|
||||
void register_purgeable_page_ranges();
|
||||
void unregister_purgeable_page_ranges();
|
||||
|
||||
RefPtr<PageDirectory> m_page_directory;
|
||||
Range m_range;
|
||||
size_t m_offset_in_vmobject { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue