class representing a chunk of pages
allocating pages from the OS happens in chunks in order to not exhaust the maximum allowed number of memory mappings per process; this class takes care of such a chunk
a page chunk allows callers to obtain or release pages in groups of continuous pages of fixed size
Definition at line 44 of file BidirMMapPipe.h.
Public Types | |
enum | MMapVariety { Unknown , Copy , FileBacked , DevZero , Anonymous } |
type of mmap support found More... | |
Public Member Functions | |
PageChunk (PagePool *parent, unsigned length, unsigned nPgPerGroup) | |
constructor More... | |
~PageChunk () | |
destructor More... | |
bool | contains (const Pages &p) const |
return if p is contained in this PageChunk More... | |
bool | empty () const |
return true if no used page groups in this chunk More... | |
bool | full () const |
return true if no free page groups in this chunk More... | |
unsigned | len () const |
return length of chunk More... | |
unsigned | nPagesPerGroup () const |
return number of pages per page group More... | |
Pages | pop () |
pop a group of pages off the free list More... | |
void | push (const Pages &p) |
push a group of pages onto the free list More... | |
void | zap (Pages &p) |
free all pages except for those pointed to by p More... | |
Static Public Member Functions | |
static MMapVariety | mmapVariety () |
return mmap variety support found More... | |
static unsigned | pagesize () |
return the logical page size More... | |
static unsigned | physPgSz () |
return the physical page size of the system More... | |
Private Types | |
typedef BidirMMapPipeException | Exception |
convenience typedef More... | |
Private Member Functions | |
PageChunk (const PageChunk &) | |
forbid copying More... | |
PageChunk & | operator= (const PageChunk &) |
forbid assignment More... | |
Static Private Member Functions | |
static void * | dommap (unsigned len) |
mmap pages, len is length of mmapped area in bytes More... | |
static void | domunmap (void *p, unsigned len) |
munmap pages p, len is length of mmapped area in bytes More... | |
static unsigned | getPageSize () |
determine page size at run time More... | |
Private Attributes | |
void * | m_begin |
pointer to start of mmapped area More... | |
void * | m_end |
pointer one behind end of mmapped area More... | |
std::list< void * > | m_freelist |
free pages list More... | |
unsigned | m_nPgPerGrp |
number of pages per group More... | |
unsigned | m_nUsedGrp |
number of used page groups More... | |
PagePool * | m_parent |
parent page pool More... | |
Static Private Attributes | |
static MMapVariety | s_mmapworks = PageChunk::Unknown |
mmap variety that works on this system More... | |
static unsigned | s_pagesize = std::min(PageChunk::s_physpgsz, 16384u) |
logical page size (run-time determined) More... | |
static unsigned | s_physpgsz = PageChunk::getPageSize() |
system physical page size More... | |
|
private |
convenience typedef
Definition at line 62 of file BidirMMapPipe.h.
type of mmap support found
Enumerator | |
---|---|
Unknown | don't know yet what'll work |
Copy | mmap doesn't work, have to copy back and forth |
FileBacked | mmapping a temp file works |
DevZero | mmapping /dev/zero works |
Anonymous | anonymous mmap works |
Definition at line 47 of file BidirMMapPipe.h.
|
inlineprivate |
forbid copying
Definition at line 81 of file BidirMMapPipe.h.
BidirMMapPipe_impl::PageChunk::PageChunk | ( | PagePool * | parent, |
unsigned | length, | ||
unsigned | nPgPerGroup | ||
) |
constructor
Definition at line 344 of file BidirMMapPipe.cxx.
BidirMMapPipe_impl::PageChunk::~PageChunk | ( | ) |
destructor
Definition at line 360 of file BidirMMapPipe.cxx.
bool BidirMMapPipe_impl::PageChunk::contains | ( | const Pages & | p | ) | const |
return if p is contained in this PageChunk
Definition at line 366 of file BidirMMapPipe.cxx.
|
staticprivate |
mmap pages, len is length of mmapped area in bytes
Definition at line 392 of file BidirMMapPipe.cxx.
munmap pages p, len is length of mmapped area in bytes
Definition at line 532 of file BidirMMapPipe.cxx.
|
inline |
return true if no used page groups in this chunk
Definition at line 117 of file BidirMMapPipe.h.
|
inline |
return true if no free page groups in this chunk
Definition at line 120 of file BidirMMapPipe.h.
|
staticprivate |
determine page size at run time
Definition at line 330 of file BidirMMapPipe.cxx.
|
inline |
return length of chunk
Definition at line 108 of file BidirMMapPipe.h.
|
inlinestatic |
return mmap variety support found
Definition at line 90 of file BidirMMapPipe.h.
|
inline |
return number of pages per page group
Definition at line 114 of file BidirMMapPipe.h.
forbid assignment
Definition at line 83 of file BidirMMapPipe.h.
|
inlinestatic |
return the logical page size
Definition at line 86 of file BidirMMapPipe.h.
|
inlinestatic |
return the physical page size of the system
Definition at line 88 of file BidirMMapPipe.h.
Pages BidirMMapPipe_impl::PageChunk::pop | ( | ) |
pop a group of pages off the free list
Definition at line 369 of file BidirMMapPipe.cxx.
push a group of pages onto the free list
Definition at line 378 of file BidirMMapPipe.cxx.
free all pages except for those pointed to by p
Definition at line 546 of file BidirMMapPipe.cxx.
|
private |
pointer to start of mmapped area
Definition at line 64 of file BidirMMapPipe.h.
|
private |
pointer one behind end of mmapped area
Definition at line 65 of file BidirMMapPipe.h.
|
private |
free pages list
Definition at line 68 of file BidirMMapPipe.h.
|
private |
number of pages per group
Definition at line 70 of file BidirMMapPipe.h.
|
private |
number of used page groups
Definition at line 71 of file BidirMMapPipe.h.
|
private |
parent page pool
Definition at line 69 of file BidirMMapPipe.h.
|
staticprivate |
mmap variety that works on this system
Definition at line 59 of file BidirMMapPipe.h.
|
staticprivate |
logical page size (run-time determined)
Definition at line 57 of file BidirMMapPipe.h.
|
staticprivate |
system physical page size
Definition at line 56 of file BidirMMapPipe.h.