mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
Kernel: Avoid O(n) loop over zones when allocating from PhysicalRegion
We now keep all the PhysicalZones on one of two intrusive lists within the PhysicalRegion. The "usable" list contains all zones that can be allocated from, and the "full" list contains all zones with no free pages.
This commit is contained in:
parent
9ae067aa7f
commit
379bcd26e4
3 changed files with 38 additions and 10 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/Bitmap.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Forward.h>
|
||||
|
||||
|
@ -32,6 +33,8 @@ public:
|
|||
void dump() const;
|
||||
size_t available() const { return m_page_count - (m_used_chunks / 2); }
|
||||
|
||||
bool is_empty() const { return !available(); }
|
||||
|
||||
PhysicalAddress base() const { return m_base_address; }
|
||||
bool contains(PhysicalAddress paddr) const
|
||||
{
|
||||
|
@ -82,6 +85,11 @@ private:
|
|||
PhysicalAddress m_base_address { 0 };
|
||||
size_t m_page_count { 0 };
|
||||
size_t m_used_chunks { 0 };
|
||||
|
||||
IntrusiveListNode<PhysicalZone> m_list_node;
|
||||
|
||||
public:
|
||||
using List = IntrusiveList<PhysicalZone, RawPtr<PhysicalZone>, &PhysicalZone::m_list_node>;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue