summaryrefslogtreecommitdiff
path: root/Kernel/VM/VMObject.h
AgeCommit message (Collapse)Author
2021-08-06Kernel: Rename Kernel/VM/ to Kernel/Memory/Andreas Kling
This directory isn't just about virtual memory, it's about all kinds of memory management.
2021-07-25Kernel: Remove unnecessary counting of VMObject-attached RegionsAndreas Kling
VMObject already has an IntrusiveList of all the Regions that map it. We were keeping a counter in addition to this, and only using it in a single place to avoid iterating over the list in case it only had 1 entry. Simplify VMObject by removing this counter and always iterating the list even if there's only 1 entry. :^)
2021-07-25Kernel: Add missing locking when registering VMObjectDeletedHandlersAndreas Kling
2021-07-23Kernel: Simplify VMObject locking & page fault handlersAndreas Kling
This patch greatly simplifies VMObject locking by doing two things: 1. Giving VMObject an IntrusiveList of all its mapping Region objects. 2. Removing VMObject::m_paging_lock in favor of VMObject::m_lock Before (1), VMObject::for_each_region() was forced to acquire the global MM lock (since it worked by walking MemoryManager's list of all regions and checking for regions that pointed to itself.) With each VMObject having its own list of Regions, VMObject's own m_lock is all we need. Before (2), page fault handlers used a separate mutex for preventing overlapping work. This design required multiple temporary unlocks and was generally extremely hard to reason about. Instead, page fault handlers now use VMObject's own m_lock as well.
2021-07-22Kernel: Convert VMObject & subclasses to east-const styleAndreas Kling
2021-07-17Kernel: Rename Lock to MutexAndreas Kling
Let's be explicit about what kind of lock this is meant to be.
2021-07-11Kernel: Rename VMObject::clone() => try_clone()Andreas Kling
And fix an unsafe dereference in SharedInodeVMObject::try_clone() to make it OOM-safe.
2021-07-11Kernel: Make VMObject::class_name() return a StringViewAndreas Kling
2021-07-11Kernel: Store VMObject physical pages in a FixedArrayAndreas Kling
Let's enforce the invariant that VMObjects don't shrink or grow by storing the pages in a FixedArray.
2021-07-11Kernel: Make VMObject vend physical page range as a spanAndreas Kling
Stop exposing the internal data structure used for storing the physical pages and return a Span<RefPtr<PhysicalPage>> instead.
2021-07-11Kernel: Use Forward.h headers moreAndreas Kling
2021-06-02Kernel: Avoid allocations in the VMObject constructorGunnar Beutner
This avoids allocations in the VMObject constructor. The number of inline elements was determined empirically and covers most common cases including LibC malloc.
2021-05-26Kernel: Switch VMObject to IntrusiveList from InlineLinkedListBrian Gianforcaro
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-05Kernel: Add AnonymousVMObject constructor for a Vector of physical pagesLiav A
This will be used later on by the AHCI code to create a Region that spans over scattered DMA pages.
2021-02-28Kernel: Use default con/de-structorsBen Wiederhake
This may seem like a no-op change, however it shrinks down the Kernel by a bit: .text -432 .unmap_after_init -60 .data -480 .debug_info -673 .debug_aranges 8 .debug_ranges -232 .debug_line -558 .debug_str -308 .debug_frame -40 With '= default', the compiler can do more inlining, hence the savings. I intentionally omitted some opportunities for '= default', because they would increase the Kernel size.
2021-01-17Kernel: Some futex improvementsTom
This adds support for FUTEX_WAKE_OP, FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET, FUTEX_REQUEUE, and FUTEX_CMP_REQUEUE, as well well as global and private futex and absolute/relative timeouts against the appropriate clock. This also changes the implementation so that kernel resources are only used when a thread is blocked on a futex. Global futexes are implemented as offsets in VMObjects, so that different processes can share a futex against the same VMObject despite potentially being mapped at different virtual addresses.
2021-01-04Kernel: Specify default memory order for some non-synchronizing AtomicsTom
2021-01-02Kernel: If a VMObject is shared, broadcast page remappingsTom
If we remap pages (e.g. lazy allocation) inside a VMObject that is shared among more than one region, broadcast it to any other region that may be mapping the same page.
2021-01-01Kernel: Merge PurgeableVMObject into AnonymousVMObjectTom
This implements memory commitments and lazy-allocation of committed memory.
2021-01-01Kernel: Implement lazy committed page allocationTom
By designating a committed page pool we can guarantee to have physical pages available for lazy allocation in mappings. However, when forking we will overcommit. The assumption is that worst-case it's better for the fork to die due to insufficient physical memory on COW access than the parent that created the region. If a fork wants to ensure that all memory is available (trigger a commit) then it can use madvise. This also means that fork now can gracefully fail if we don't have enough physical pages available.
2021-01-01Kernel: Remove the limited use of AK::TypeTraits we had in the kernelAndreas Kling
This was only used for VMObject and we can do without it there. This is preparation for migrating to dynamic_cast-based helpers in userspace.
2020-09-08Refactor: Replace usages of FixedArray with Vector.asynts
2020-07-26Kernel: Switch to using AK::is and AK::downcastAndreas Kling
2020-05-08Kernel: Add for_each_vmobject_of_type<T>Andreas Kling
This makes iterating over a specific type of VMObjects a bit nicer.
2020-03-08Kernel: Allow contiguous allocations in physical memoryLiav A
For that, we have a new type of VMObject, called ContiguousVMObject, that is responsible for allocating contiguous physical pages.
2020-03-01Kernel: Add some InodeVMObject type assertions in Region::clone()Andreas Kling
Let's make sure that we're never cloning shared inode-backed objects as if they were private, and vice versa.
2020-02-28Kernel: Expose the VMObject type of each Region in /proc/PID/vmAndreas Kling
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-12-09Kernel: Start implementing purgeable memory supportAndreas Kling
It's now possible to get purgeable memory by using mmap(MAP_PURGEABLE). Purgeable memory has a "volatile" flag that can be set using madvise(): - madvise(..., MADV_SET_VOLATILE) - madvise(..., MADV_SET_NONVOLATILE) When in the "volatile" state, the kernel may take away the underlying physical memory pages at any time, without notifying the owner. This gives you a guilt discount when caching very large things. :^) Setting a purgeable region to non-volatile will return whether or not the memory has been taken away by the kernel while being volatile. Basically, if madvise(..., MADV_SET_NONVOLATILE) returns 1, that means the memory was purged while volatile, and whatever was in that piece of memory needs to be reconstructed before use.
2019-11-04Kernel: Move page fault handling from MemoryManager to RegionAndreas Kling
After the page fault handler has found the region in which the fault occurred, do the rest of the work in the region itself. This patch also makes all fault types consistently crash the process if a new page is needed but we're all out of pages.
2019-08-08Kernel: Put all VMObjects in an InlineLinkedList instead of a HashTableAndreas Kling
Using a HashTable to track "all instances of Foo" is only useful if we actually need to look up entries by some kind of index. And since they are HashTable (not HashMap), the pointer *is* the index. Since we have the pointer, we can just use it directly. Duh. This increase sizeof(VMObject) by two pointers, but removes a global table that had an entry for every VMObject, where the cost was higher. It also avoids all the general hash tabling business when creating or destroying VMObjects. Generally we should do more of this. :^)
2019-08-07Kernel: Use a FixedArray for VMObject::m_physical_pagesAndreas Kling
This makes VMObject 8 bytes smaller since we can use the array size as the page count. The size() is now also computed from the page count instead of being a separate value. This makes sizes always be a multiple of PAGE_SIZE, which is sane.
2019-08-07Kernel: Split VMObject into two classes: Anonymous- and InodeVMObjectAndreas Kling
InodeVMObject is a VMObject with an underlying Inode in the filesystem. AnonymousVMObject has no Inode. I'm happy that InodeVMObject::inode() can now return Inode& instead of VMObject::inode() return Inode*. :^)
2019-08-07Kernel: Remove "allow CPU caching" flag on VMObjectAndreas Kling
This wasn't really thought-through, I was just trying anything to see if it would make WindowServer faster. This doesn't seem to make much of a difference either way, so let's just not do it for now. It's easy to bring back if we think we need it in the future.
2019-08-07Kernel: Remove VMObject namesAndreas Kling
The VMObject name was always either the owning region's name, or the absolute path of the underlying inode. We can reconstitute this information if wanted, no need to keep copies of these strings around.
2019-07-09Kernel: Move PhysicalAddress.h into VM/Andreas Kling
2019-07-03AK: Rename the common integer typedefs to make it obvious what they are.Andreas Kling
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
2019-06-22Kernel: Fix all compiler warnings.Andreas Kling
2019-06-21AK: Rename Retainable.h => RefCounted.h.Andreas Kling
2019-06-21AK: Rename RetainPtr.h => RefPtr.h, Retained.h => NonnullRefPtr.h.Andreas Kling
2019-06-21AK: Rename RetainPtr => RefPtr and Retained => NonnullRefPtr.Andreas Kling
2019-06-21AK: Rename Retainable => RefCounted.Andreas Kling
(And various related renames that go along with it.)
2019-06-07Kernel: Tweak some String&& => const String&.Andreas Kling
String&& is just not very practical. Also return const String& when the returned string is a member variable. The call site is free to make a copy if he wants, but otherwise we can avoid the retain count churn.
2019-05-28Add clang-format fileRobin Burchell
Also run it across the whole tree to get everything using the One True Style. We don't yet run this in an automated fashion as it's a little slow, but there is a snippet to do so in makeall.sh.
2019-05-02Kernel: Simplify VMObject::is_anonymous().Andreas Kling
This doesn't need a separate flag. A VMObject is always anonymous if it has no backing inode.
2019-05-02Kernel: Assign Lock names in class member initializers.Andreas Kling
2019-04-06Kernel: Get rid of Kernel/types.h, separate LinearAddress/PhysicalAddress.Andreas Kling
2019-04-03Kernel: Move VM-related files into Kernel/VM/.Andreas Kling
Also break MemoryManager.{cpp,h} into one file per class.