MCPcopy Create free account
hub / github.com/apache/brpc / ExtendBlockPool

Function ExtendBlockPool

src/brpc/rdma/block_pool.cpp:185–211  ·  view source on GitHub ↗

Extend the block pool with a new region (with different region ID)

Source from the content-addressed store, hash-verified

183
184// Extend the block pool with a new region (with different region ID)
185static void* ExtendBlockPool(size_t region_size, int block_type) {
186 if (region_size < 1) {
187 errno = EINVAL;
188 return NULL;
189 }
190
191 if (FLAGS_rdma_memory_pool_user_specified_memory) {
192 LOG_EVERY_SECOND(ERROR) << "Fail to extend new region, "
193 "rdma_memory_pool_user_specified_memory is "
194 "true, ExtendBlockPool is disabled";
195 return NULL;
196 }
197
198 // Regularize region size
199 region_size = region_size * BYTES_IN_MB / g_block_size[block_type] / g_buckets;
200 region_size *= g_block_size[block_type] * g_buckets;
201
202 LOG(INFO) << "Start extend rdma memory " << region_size / BYTES_IN_MB << "MB";
203
204 void* region_base = NULL;
205 if (posix_memalign(&region_base, 4096, region_size) != 0) {
206 PLOG_EVERY_SECOND(ERROR) << "Memory not enough";
207 return NULL;
208 }
209
210 return ExtendBlockPoolImpl(region_base, region_size, block_type);
211}
212
213void* ExtendBlockPoolByUser(void* region_base, size_t region_size, int block_type) {
214 auto region_base_guard = butil::MakeScopeGuard([region_base]() {

Callers 2

InitBlockPoolFunction · 0.85
AllocBlockFromFunction · 0.85

Calls 1

ExtendBlockPoolImplFunction · 0.85

Tested by

no test coverage detected