1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

Kernel: Put all VMObjects in an InlineLinkedList instead of a HashTable

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. :^)
This commit is contained in:
Andreas Kling 2019-08-08 10:43:44 +02:00
parent fffd3a67ad
commit a96d76fd90
4 changed files with 32 additions and 14 deletions

View file

@ -399,17 +399,19 @@ Optional<KBuffer> procfs$self(InodeIdentifier)
Optional<KBuffer> procfs$mm(InodeIdentifier)
{
// FIXME: Implement
InterruptDisabler disabler;
KBufferBuilder builder;
for (auto* vmo : MM.m_vmos) {
builder.appendf("VMO: %p %s(%u): p:%4u\n",
vmo,
vmo->is_anonymous() ? "anon" : "file",
vmo->ref_count(),
vmo->page_count());
}
builder.appendf("VMO count: %u\n", MM.m_vmos.size());
u32 vmobject_count = 0;
MemoryManager::for_each_vmobject([&](auto& vmobject) {
++vmobject_count;
builder.appendf("VMObject: %p %s(%u): p:%4u\n",
&vmobject,
vmobject.is_anonymous() ? "anon" : "file",
vmobject.ref_count(),
vmobject.page_count());
return IterationDecision::Continue;
});
builder.appendf("VMO count: %u\n", vmobject_count);
builder.appendf("Free physical pages: %u\n", MM.user_physical_pages() - MM.user_physical_pages_used());
builder.appendf("Free supervisor physical pages: %u\n", MM.super_physical_pages() - MM.super_physical_pages_used());
return builder.build();