The Pedigree Project 0.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes | List of all members
MemoryPressureManager Class Reference

#include <MemoryPressureManager.h>

+ Collaboration diagram for MemoryPressureManager:

Public Member Functions

bool compact ()
 
bool compactingForCurrentExecution () const
 
void registerHandler (size_t prio, MemoryPressureHandler *pHandler)
 
void removeHandler (MemoryPressureHandler *pHandler)
 

Static Public Member Functions

static MemoryPressureManager & instance ()
 
static size_t getHighWatermark ()
 
static size_t getLowWatermark ()
 

Static Public Attributes

static const size_t HighestPriority = 0
 
static const size_t HighPriority = MAX_MEMPRESSURE_PRIORITY / 3
 
static const size_t MediumPriority = MAX_MEMPRESSURE_PRIORITY / 2
 
static const size_t LowPriority = (MAX_MEMPRESSURE_PRIORITY * 2) / 3
 
static const size_t LowestPriority = MAX_MEMPRESSURE_PRIORITY - 1
 

Private Attributes

Spinlock m_Lock
 
MemoryPressureHandler * m_Handlers [MAX_MEMPRESSURE_PRIORITY]
 
MemoryPressureHandler * m_HandlerTails [MAX_MEMPRESSURE_PRIORITY]
 
size_t m_NextRegistrationSequence
 
Atomic< bool > m_bCompacting
 
const void * m_pCompactOwner
 
WaitQueue m_CompactWaiters
 

Static Private Attributes

static MemoryPressureManager m_Instance
 

Detailed Description

MemoryPressureManager: global memory pressure handling.

This class offers a central interface for the various mechanisms available to alleviate memory pressure to register themselves and be called, without requiring the kernel itself to know about them (eg, loadable modules).

Definition at line 80 of file MemoryPressureManager.h.

Constructor & Destructor Documentation

◆ MemoryPressureManager()

MemoryPressureManager::MemoryPressureManager ( )

Definition at line 199 of file MemoryPressureManager.cc.

Member Function Documentation

◆ compact()

bool MemoryPressureManager::compact ( )

Attempt to alleviate memory pressure by requesting registered handlers release pages that can be safely released.

Registry state is never locked across a callback. A callback may register or remove another handler. Removing the currently executing handler from its own callback is rejected because a synchronous removal cannot wait for itself to finish.

Definition at line 66 of file MemoryPressureManager.cc.

References assert, MemoryPressureHandler::compact(), ProcessorBase::getInterrupts(), MemoryPressureHandler::getMemoryPressureDescription(), ProcessorBase::information(), MemoryPressureHandler::m_CallbacksInFlight, and ProcessorBase::m_Initialised.

Referenced by HostedPhysicalMemoryManager::allocatePage(), and X86CommonPhysicalMemoryManager::allocatePage().

+ Here is the caller graph for this function:

◆ compactingForCurrentExecution()

bool MemoryPressureManager::compactingForCurrentExecution ( ) const

True while the current execution context is already inside compact(). Physical allocators use this to permit callback allocations without recursively starting another pressure pass.

Definition at line 194 of file MemoryPressureManager.cc.

Referenced by HostedPhysicalMemoryManager::allocatePage(), and X86CommonPhysicalMemoryManager::allocatePage().

+ Here is the caller graph for this function:

◆ getHighWatermark()

static size_t MemoryPressureManager::getHighWatermark ( )
inlinestatic

Definition at line 95 of file MemoryPressureManager.h.

◆ getLowWatermark()

static size_t MemoryPressureManager::getLowWatermark ( )
inlinestatic

Definition at line 103 of file MemoryPressureManager.h.

◆ instance()

static MemoryPressureManager & MemoryPressureManager::instance ( )
inlinestatic

Definition at line 91 of file MemoryPressureManager.h.

◆ registerHandler()

void MemoryPressureManager::registerHandler ( size_t  prio,
MemoryPressureHandler *  pHandler 
)

Register a new handler.

Definition at line 215 of file MemoryPressureManager.cc.

References MemoryPressureHandler::m_CallbacksInFlight.

Referenced by MemoryPool::initialise(), and MemoryMapManager::MemoryMapManager().

+ Here is the caller graph for this function:

◆ removeHandler()

void MemoryPressureManager::removeHandler ( MemoryPressureHandler *  pHandler)

Member Data Documentation

◆ HighestPriority

const size_t MemoryPressureManager::HighestPriority = 0
static

Definition at line 85 of file MemoryPressureManager.h.

◆ HighPriority

const size_t MemoryPressureManager::HighPriority = MAX_MEMPRESSURE_PRIORITY / 3
static

Definition at line 86 of file MemoryPressureManager.h.

◆ LowestPriority

const size_t MemoryPressureManager::LowestPriority = MAX_MEMPRESSURE_PRIORITY - 1
static

Definition at line 89 of file MemoryPressureManager.h.

◆ LowPriority

const size_t MemoryPressureManager::LowPriority = (MAX_MEMPRESSURE_PRIORITY * 2) / 3
static

Definition at line 88 of file MemoryPressureManager.h.

◆ m_bCompacting

Atomic<bool> MemoryPressureManager::m_bCompacting
private

Definition at line 145 of file MemoryPressureManager.h.

◆ m_CompactWaiters

WaitQueue MemoryPressureManager::m_CompactWaiters
private

Definition at line 148 of file MemoryPressureManager.h.

◆ m_Handlers

MemoryPressureHandler* MemoryPressureManager::m_Handlers[MAX_MEMPRESSURE_PRIORITY]
private

Definition at line 142 of file MemoryPressureManager.h.

◆ m_HandlerTails

MemoryPressureHandler* MemoryPressureManager::m_HandlerTails[MAX_MEMPRESSURE_PRIORITY]
private

Definition at line 143 of file MemoryPressureManager.h.

◆ m_Instance

MemoryPressureManager MemoryPressureManager::m_Instance
staticprivate

Definition at line 139 of file MemoryPressureManager.h.

◆ m_Lock

Spinlock MemoryPressureManager::m_Lock
private

Definition at line 141 of file MemoryPressureManager.h.

◆ m_NextRegistrationSequence

size_t MemoryPressureManager::m_NextRegistrationSequence
private

Definition at line 144 of file MemoryPressureManager.h.

◆ m_pCompactOwner

const void* MemoryPressureManager::m_pCompactOwner
private

Definition at line 146 of file MemoryPressureManager.h.

◆ MediumPriority

const size_t MemoryPressureManager::MediumPriority = MAX_MEMPRESSURE_PRIORITY / 2
static

Definition at line 87 of file MemoryPressureManager.h.


The documentation for this class was generated from the following files: