20 #include <glog/logging.h>
41 : control_block_(nullptr),
45 rigorous_page_boundary_check_(false) {}
52 bool rigorous_page_boundary_check) {
69 if (rigorous_page_boundary_check) {
83 if (!rigorous_page_boundary_check_) {
97 bool error_reported =
false;
103 boundary->
reset(std::to_string(index));
107 error_reported =
true;
112 <<
" pages in " << watch.
elapsed_ms() <<
"ms";
158 bool error_reported =
false;
166 error_reported =
true;
173 <<
" pages in " << watch.
elapsed_ms() <<
"ms";
180 <<
" - Page Pool has not received back all free pages by its uninitialization!!"
184 <<
" - Page Pool has received back all free pages. No suspicious behavior.";
208 uint64_t grab_count = std::min<uint64_t>(desired_grab_count, free_count);
213 chunk->
push_back(head, head + wrap_count);
216 grab_count -= wrap_count;
223 chunk->
push_back(head, head + grab_count);
258 template <
typename CHUNK>
260 ASSERT_ND(chunk->size() >= desired_release_count);
270 <<
" - PagePoolPimpl::release() More than full free-pool. inconsistent state!"
272 <<
"/" << desired_release_count;
282 uint64_t release_count = std::min<uint64_t>(desired_release_count, chunk->size());
290 chunk->move_to(
free_pool_ + tail, wrap_count);
292 release_count -= wrap_count;
298 chunk->move_to(
free_pool_ + tail, release_count);
303 release_impl<PagePoolOffsetChunk>(desired_release_count, chunk);
306 release_impl<PagePoolOffsetDynamicChunk>(desired_release_count, chunk);
309 release_impl<PagePoolOffsetAndEpochChunk>(desired_release_count, chunk);
322 <<
" - PagePoolPimpl::release_one() More than full free-pool. inconsistent state!";
346 <<
"<memory_>" << v.
memory_ <<
"</memory_>"
347 <<
"<memory_size>" << v.
memory_size_ <<
"</memory_size>"
348 <<
"<owns_>" << v.
owns_ <<
"</owns_>"
349 <<
"<rigorous_page_boundary_check_>"
353 <<
"<free_pool_head_>" << v.
free_pool_head() <<
"</free_pool_head_>"
std::string get_boundary_name() const
void attach(PagePoolControlBlock *control_block, void *memory, uint64_t memory_size, bool owns, bool rigorous_page_boundary_check)
uint64_t allocated_pages_
void increase_free_pool_count(uint64_t op)
A 4kb dummy data placed between separate memory regions so that we can check if/where a bogus memory ...
#define ERROR_STACK(e)
Instantiates ErrorStack with the given foedus::error_code, creating an error stack with the current f...
void reset(const std::string &boundary_name)
Fills the block with magic words.
std::string get_debug_pool_name() const
bool rigorous_page_boundary_check_
Whether to use mprotect() for page boundaries to detect bogus memory accesses.
void * memory_
The whole memory region of the pool.
uint64_t get_free_pool_count() const
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
uint32_t PagePoolOffset
Offset in PagePool that compactly represents the page address (unlike 8 bytes pointer).
double elapsed_ms() const
storage::Page * pool_base_
Just an auxiliary variable to the beginning of the pool.
Brings error stacktrace information as return value of functions.
uint64_t free_pool_capacity_
Size of free_pool_.
void release_one(PagePoolOffset offset)
uint64_t & free_pool_head()
soc::SharedMutex lock_
grab()/release() are protected with this lock.
PagePoolControlBlock * control_block_
ErrorCode grab(uint32_t desired_grab_count, PagePoolOffsetChunk *chunk)
#define COERCE_ERROR(x)
This macro calls x and aborts if encounters an error.
uint64_t pool_size_
Just an auxiliary variable of the size of pool.
PagePool::Stat get_stat() const
void release_impl(uint32_t desired_release_count, CHUNK *chunk)
ErrorStack initialize_once() override
void decrease_free_pool_count(uint64_t op)
void assert_free_pool() const
Not thread safe.
Pimpl object of PagePool.
0x0302 : "MEMORY : Duplicate entry in free-page pool." .
uint64_t stop()
Take another current time tick.
void release(uint32_t desired_release_count, PagePoolOffsetChunk *chunk)
ErrorStack uninitialize_once() override
Auto-lock scope object for SharedMutex.
Just a marker to denote that the memory region represents a data page.
uint64_t free_pool_head_
Inclusive head of the circular queue.
ErrorCode grab_one(PagePoolOffset *offset)
bool owns_
Whether this engine owns this page pool.
std::ostream & operator<<(std::ostream &o, const AlignedMemory &v)
LocalPageResolver resolver_
An object to resolve an offset in this page pool (thus local) to an actual pointer and vice versa...
0x0301 : "MEMORY : Not enough free volatile pages. Check the config of MemoryOptions" ...
Used to point to an already existing array.
uint64_t free_pool_count_
Number of free pages.
Shared data in PagePoolPimpl.
assorted::FixedString< 60 > debug_pool_name_
just for debugging/logging.
std::string os_error()
Thread-safe strerror(errno).
void assert_boundary() const
Called at shutdown to check whether these boundaries were not accessed.
void push_back(PagePoolOffset pointer)
To reduce the overhead of grabbing/releasing pages from pool, we pack this many pointers for each gra...
uint64_t pages_for_free_pool_
This many first pages are used for free page maintainance.
const ErrorStack kRetOk
Normal return value for no-error case.
int64_t int_div_ceil(int64_t dividee, int64_t dividor)
Efficient ceil(dividee/dividor) for integer.
void clear() noexcept
Clear string.
Used to store an epoch value with each entry in PagePoolOffsetChunk.
uint32_t capacity() const
#define UNLIKELY(x)
Hints that x is highly likely false.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
ErrorCode release_protect()
Removes all access restrictions via mprotect().
A high-resolution stop watch.
const uint16_t kPageSize
A constant defining the page size (in bytes) of both snapshot pages and volatile pages.
ErrorCode
Enum of error codes defined in error_code.xmacro.
ErrorCode acquire_protect()
Puts a strict access prohibition via mprotect().
bool is_initialized() const override final
Returns whether the object has been already initialized or not.
uint64_t memory_size_
Byte size of this page pool.
PagePoolOffset * free_pool_
We maintain free pages as a simple circular queue.