| 211 | } |
| 212 | |
| 213 | void* ExtendBlockPoolByUser(void* region_base, size_t region_size, int block_type) { |
| 214 | auto region_base_guard = butil::MakeScopeGuard([region_base]() { |
| 215 | free(region_base); |
| 216 | }); |
| 217 | |
| 218 | if (!FLAGS_rdma_memory_pool_user_specified_memory) { |
| 219 | LOG_EVERY_SECOND(ERROR) << "User extend memory is disabled"; |
| 220 | return NULL; |
| 221 | } |
| 222 | if (reinterpret_cast<uintptr_t>(region_base) % 4096 != 0) { |
| 223 | LOG_EVERY_SECOND(ERROR) << "region_base must be 4096 aligned"; |
| 224 | errno = EINVAL; |
| 225 | return NULL; |
| 226 | } |
| 227 | |
| 228 | region_size = |
| 229 | region_size * BYTES_IN_MB / g_block_size[block_type] / g_buckets; |
| 230 | region_size *= g_block_size[block_type] * g_buckets; |
| 231 | |
| 232 | region_base_guard.dismiss(); |
| 233 | BAIDU_SCOPED_LOCK(g_info->extend_lock); |
| 234 | return ExtendBlockPoolImpl(region_base, region_size, block_type); |
| 235 | } |
| 236 | |
| 237 | bool InitBlockPool(RegisterCallback cb) { |
| 238 | if (!cb) { |
no test coverage detected