enb - log warning when rnti-specific memory block is full

master
Francisco 4 years ago committed by Francisco Paisana
parent a890a22ccd
commit 71f1f1b556

@ -39,7 +39,8 @@ class circular_stack_pool
public: public:
circular_stack_pool(size_t nof_objs_per_batch, size_t stack_size, size_t batch_thres, int initial_size = -1) : circular_stack_pool(size_t nof_objs_per_batch, size_t stack_size, size_t batch_thres, int initial_size = -1) :
central_cache(std::min(NofStacks, nof_objs_per_batch), stack_size, batch_thres, initial_size) central_cache(std::min(NofStacks, nof_objs_per_batch), stack_size, batch_thres, initial_size),
logger(srslog::fetch_basic_logger("POOL"))
{} {}
circular_stack_pool(circular_stack_pool&&) = delete; circular_stack_pool(circular_stack_pool&&) = delete;
circular_stack_pool(const circular_stack_pool&) = delete; circular_stack_pool(const circular_stack_pool&) = delete;
@ -66,13 +67,18 @@ public:
if (not elem.alloc.is_init()) { if (not elem.alloc.is_init()) {
void* block = central_cache.allocate_node(central_cache.get_node_max_size()); void* block = central_cache.allocate_node(central_cache.get_node_max_size());
if (block == nullptr) { if (block == nullptr) {
logger.warning("Failed to allocate memory block from central cache");
return nullptr; return nullptr;
} }
elem.key = key; elem.key = key;
elem.alloc = linear_allocator(block, central_cache.get_node_max_size()); elem.alloc = linear_allocator(block, central_cache.get_node_max_size());
} }
void* ptr = elem.alloc.allocate(size, alignment); void* ptr = elem.alloc.allocate(size, alignment);
elem.count++; if (ptr == nullptr) {
logger.warning("No space left in memory block with key=%zd of circular stack pool", key);
} else {
elem.count++;
}
return ptr; return ptr;
} }
@ -98,6 +104,7 @@ public:
private: private:
srsran::circular_array<mem_block_elem_t, NofStacks> pools; srsran::circular_array<mem_block_elem_t, NofStacks> pools;
srsran::background_mem_pool central_cache; srsran::background_mem_pool central_cache;
srslog::basic_logger& logger;
}; };
} // namespace srsran } // namespace srsran

@ -43,12 +43,13 @@ public:
void* allocate(size_t sz, size_t alignment) void* allocate(size_t sz, size_t alignment)
{ {
void* alloc_start = align_to(cur, alignment); void* alloc_start = align_to(cur, alignment);
cur = static_cast<uint8_t*>(alloc_start) + sz; uint8_t* new_cur = static_cast<uint8_t*>(alloc_start) + sz;
srsran_assert(cur <= end, if (new_cur > end) {
"Linear Allocator buffer of size=%zd was exceeded (current size=%zd)", // Cannot fit allocation in memory block
size(), return nullptr;
nof_bytes_allocated()); }
cur = new_cur;
return alloc_start; return alloc_start;
} }

@ -514,6 +514,7 @@ int main(int argc, char* argv[])
srslog::init(); srslog::init();
srslog::fetch_basic_logger("ALL").set_level(srslog::basic_levels::warning); srslog::fetch_basic_logger("ALL").set_level(srslog::basic_levels::warning);
srslog::fetch_basic_logger("POOL").set_level(srslog::basic_levels::warning);
srsran::log_args(argc, argv, "ENB"); srsran::log_args(argc, argv, "ENB");
srsran::check_scaling_governor(args.rf.device_name); srsran::check_scaling_governor(args.rf.device_name);

Loading…
Cancel
Save