The Pedigree Project 0.1
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
SlamAllocator Class Reference
+ Collaboration diagram for SlamAllocator:

Classes

struct  AllocFooter
 
struct  AllocHeader
 
struct  AllocHeader_VigilantOverrunCheck
 
struct  AllocHeader_VigilantOverrunCheck_Empty
 
struct  OverrunCheck_Magic
 
struct  OverrunCheck_Magic_Empty
 

Public Member Functions

void initialise ()
 
void clearAll ()
 
uintptr_t allocate (size_t nBytes)
 
void free (uintptr_t mem)
 
size_t recovery (size_t maxSlabs=1)
 
bool isPointerValid (uintptr_t mem) const
 
bool isWithinHeap (uintptr_t mem) const
 
size_t allocSize (uintptr_t mem)
 
size_t heapPageCount () const
 
uintptr_t getSlab (size_t fullSize)
 
void freeSlab (uintptr_t address, size_t length)
 
size_t headerSize () const
 
size_t footerSize () const
 
void setVigilance (bool b)
 
bool getVigilance () const
 
SlamAllocator::AllocHeader pedigree_std::conditional ::type __attribute__ ((aligned(16)))
 
SlamAllocator::AllocFooter pedigree_std::conditional ::type __attribute__ ((aligned(16)))
 

Static Public Member Functions

static EXPORTED_PUBLIC SlamAllocator & instance ()
 

Private Member Functions

void freeSlabUnlocked (uintptr_t address, size_t length)
 
 SlamAllocator (const SlamAllocator &)
 
const SlamAllocator & operator= (const SlamAllocator &)
 
void wipe ()
 
bool isAllocatedPage (uintptr_t address) const
 
void markSlabReady (uintptr_t address, size_t length)
 

Private Attributes

SlamCache m_Caches [32]
 
bool m_bInitialised
 
bool m_bVigilant
 
Spinlock m_SlabRegionLock
 
size_t m_HeapPageCount
 
SlamBitmap m_SlabRegionBitmap
 
size_t m_SlabRegionBitmapEntries
 
size_t m_SlabRegionPages
 
uintptr_t m_Base
 
Spinlock m_Lock
 

Static Private Attributes

static SlamAllocator m_Instance
 

Friends

class SlamCache
 

Detailed Description

Definition at line 274 of file SlamAllocator.h.

Constructor & Destructor Documentation

◆ SlamAllocator()

SlamAllocator::SlamAllocator ( )

Definition at line 848 of file SlamAllocator.cc.

◆ ~SlamAllocator()

SlamAllocator::~SlamAllocator ( )
virtual

Definition at line 858 of file SlamAllocator.cc.

Member Function Documentation

◆ allocate()

uintptr_t SlamAllocator::allocate ( size_t  nBytes)
Note
Even 2G is a stretch on most systems. Use some other allocator to allocate such large buffers.

Definition at line 1170 of file SlamAllocator.cc.

References SlamCache::allocate(), Dec, EMIT_IF, Thread::getParent(), ProcessorBase::guardDeviceHardIrqOperation(), Hex, ProcessorBase::information(), ProcessorBase::m_Initialised, Backtrace::m_pReturnAddresses, panic(), Backtrace::performBpBacktrace(), and UNLIKELY.

◆ allocSize()

size_t SlamAllocator::allocSize ( uintptr_t  mem)

Definition at line 1306 of file SlamAllocator.cc.

◆ clearAll()

void SlamAllocator::clearAll ( )

Definition at line 920 of file SlamAllocator.cc.

◆ footerSize()

size_t SlamAllocator::footerSize ( ) const
inline

Definition at line 331 of file SlamAllocator.h.

◆ free()

void SlamAllocator::free ( uintptr_t  mem)

Definition at line 1357 of file SlamAllocator.cc.

◆ freeSlab()

void SlamAllocator::freeSlab ( uintptr_t  address,
size_t  length 
)

Definition at line 1101 of file SlamAllocator.cc.

◆ freeSlabUnlocked()

void SlamAllocator::freeSlabUnlocked ( uintptr_t  address,
size_t  length 
)
private

Variant of freeSlab that does not take the lock first. Dangerous if misused.

Definition at line 1107 of file SlamAllocator.cc.

References panic().

Referenced by wipe().

+ Here is the caller graph for this function:

◆ getSlab()

uintptr_t SlamAllocator::getSlab ( size_t  fullSize)

Definition at line 968 of file SlamAllocator.cc.

◆ getVigilance()

bool SlamAllocator::getVigilance ( ) const
inline

Definition at line 338 of file SlamAllocator.h.

◆ headerSize()

size_t SlamAllocator::headerSize ( ) const
inline

Definition at line 328 of file SlamAllocator.h.

◆ heapPageCount()

size_t SlamAllocator::heapPageCount ( ) const
inline

Definition at line 306 of file SlamAllocator.h.

◆ initialise()

void SlamAllocator::initialise ( )

Definition at line 864 of file SlamAllocator.cc.

◆ instance()

SlamAllocator & SlamAllocator::instance ( )
static

Definition at line 1347 of file SlamAllocator.cc.

◆ isAllocatedPage()

bool SlamAllocator::isAllocatedPage ( uintptr_t  address) const
private

Requires m_SlabRegionLock and checks that mapping is fully established.

Definition at line 1324 of file SlamAllocator.cc.

◆ isPointerValid()

bool SlamAllocator::isPointerValid ( uintptr_t  mem) const

Definition at line 1432 of file SlamAllocator.cc.

◆ isWithinHeap()

bool SlamAllocator::isWithinHeap ( uintptr_t  mem) const

Definition at line 1529 of file SlamAllocator.cc.

◆ markSlabReady()

void SlamAllocator::markSlabReady ( uintptr_t  address,
size_t  length 
)
private

Publishes allocator metadata only after the entire slab is mapped.

Definition at line 1082 of file SlamAllocator.cc.

References panic().

◆ recovery()

size_t SlamAllocator::recovery ( size_t  maxSlabs = 1)

Definition at line 1150 of file SlamAllocator.cc.

◆ setVigilance()

void SlamAllocator::setVigilance ( bool  b)
inline

Definition at line 335 of file SlamAllocator.h.

◆ wipe()

void SlamAllocator::wipe ( )
private

Wipe out all memory used by the allocator.

Definition at line 927 of file SlamAllocator.cc.

References freeSlabUnlocked().

Friends And Related Symbol Documentation

◆ SlamCache

friend class SlamCache
friend

Definition at line 343 of file SlamAllocator.h.

Member Data Documentation

◆ m_Base

uintptr_t SlamAllocator::m_Base
private

Definition at line 401 of file SlamAllocator.h.

◆ m_bInitialised

bool SlamAllocator::m_bInitialised
private

Definition at line 389 of file SlamAllocator.h.

◆ m_bVigilant

bool SlamAllocator::m_bVigilant
private

Definition at line 391 of file SlamAllocator.h.

◆ m_Caches

SlamCache SlamAllocator::m_Caches[32]
private

Definition at line 359 of file SlamAllocator.h.

◆ m_HeapPageCount

size_t SlamAllocator::m_HeapPageCount
private

Definition at line 395 of file SlamAllocator.h.

◆ m_Instance

SlamAllocator SlamAllocator::m_Instance
staticprivate

Definition at line 348 of file SlamAllocator.h.

◆ m_Lock

Spinlock SlamAllocator::m_Lock
private

Definition at line 408 of file SlamAllocator.h.

◆ m_SlabRegionBitmap

SlamBitmap SlamAllocator::m_SlabRegionBitmap
private

Definition at line 397 of file SlamAllocator.h.

◆ m_SlabRegionBitmapEntries

size_t SlamAllocator::m_SlabRegionBitmapEntries
private

Definition at line 398 of file SlamAllocator.h.

◆ m_SlabRegionLock

Spinlock SlamAllocator::m_SlabRegionLock
mutableprivate

Definition at line 393 of file SlamAllocator.h.

◆ m_SlabRegionPages

size_t SlamAllocator::m_SlabRegionPages
private

Definition at line 399 of file SlamAllocator.h.


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