The Pedigree Project
0.1
|
#include <SlamAllocator.h>
Classes | |
struct | Node |
Public Member Functions | |
struct SlamCache::Node | __attribute__ ((aligned(16))) |
SlamCache () | |
virtual | ~SlamCache () |
void | initialise (SlamAllocator *parent, size_t objectSize) |
uintptr_t | allocate () |
void | free (uintptr_t object) |
size_t | recovery (size_t maxSlabs) |
bool | isPointerValid (uintptr_t object) const |
size_t | objectSize () const |
size_t | slabSize () const |
Private Types | |
typedef volatile Node * | alignedNode |
Private Member Functions | |
SlamCache (const SlamCache &) | |
const SlamCache & | operator= (const SlamCache &) |
Node * | pop (alignedNode *head) |
void | push (alignedNode *head, Node *newTail, Node *newHead=0) |
uintptr_t | getSlab () |
void | freeSlab (uintptr_t slab) |
Node * | initialiseSlab (uintptr_t slab) |
Private Attributes | |
alignedNode | m_PartialLists [NUM_LISTS] |
size_t | m_ObjectSize |
size_t | m_SlabSize |
uintptr_t | m_FirstSlab |
Spinlock | m_RecoveryLock |
SlamAllocator * | m_pParentAllocator |
struct Node | m_EmptyNode |
A cache allocates objects of a constant size.
Definition at line 142 of file SlamAllocator.h.
SlamCache::SlamCache | ( | ) |
Default constructor, does nothing.
Definition at line 215 of file SlamAllocator.cc.
|
virtual |
Destructor is not designed to be called. There is no cleanup, this is a kernel heap!
Definition at line 224 of file SlamAllocator.cc.
uintptr_t SlamCache::allocate | ( | ) |
Allocates an object.
Definition at line 298 of file SlamAllocator.cc.
References assert, Processor::id(), m_pParentAllocator, and UNLIKELY.
void SlamCache::free | ( | uintptr_t | object | ) |
Frees an object.
Definition at line 342 of file SlamAllocator.cc.
References assert, Hex, Processor::id(), m_pParentAllocator, and WARNING.
Referenced by SlamAllocator::allocate().
void SlamCache::initialise | ( | SlamAllocator * | parent, |
size_t | objectSize | ||
) |
Main init function.
Definition at line 228 of file SlamAllocator.cc.
References assert, and m_pParentAllocator.
Referenced by SlamAllocator::allocate(), and recovery().
size_t SlamCache::recovery | ( | size_t | maxSlabs | ) |
Attempt to recover slabs from this cache.
Definition at line 446 of file SlamAllocator.cc.
References Spinlock::acquire(), assert, DEBUG_LOG, Dec, ERROR, VirtualAddressSpace::getKernelAddressSpace(), Hex, Processor::id(), Processor::information(), initialise(), Processor::m_Initialised, m_RecoveryLock, NOTICE, Spinlock::release(), and Processor::switchAddressSpace().
|
private |
Pointer back to the associated SlamAllocator.
Definition at line 232 of file SlamAllocator.h.
Referenced by allocate(), free(), and initialise().
|
private |
Recovery cannot be done trivially. Spinlock disables interrupts as part of its operation, so we can use it to ensure recovery isn't interrupted. Note recovery is a per-CPU thing.
Definition at line 228 of file SlamAllocator.h.
Referenced by recovery().