chenBright commented on code in PR #2965: URL: https://github.com/apache/brpc/pull/2965#discussion_r2217171429
########## src/brpc/rdma/block_pool.cpp: ########## @@ -178,23 +163,79 @@ static void* ExtendBlockPool(size_t region_size, int block_type) { for (size_t i = 0; i < g_buckets; ++i) { node[i]->start = (void*)(region->start + i * (region_size / g_buckets)); node[i]->len = region_size / g_buckets; - node[i]->next = NULL; + node[i]->next = g_info->idle_list[block_type][i]; g_info->idle_list[block_type][i] = node[i]; g_info->idle_size[block_type][i] += node[i]->len; } return region_base; } -void* InitBlockPool(RegisterCallback cb) { - if (!cb) { +// Extend the block pool with a new region (with different region ID) +static void* ExtendBlockPool(size_t region_size, int block_type) { + if (region_size < 1) { errno = EINVAL; return NULL; } + + if (FLAGS_rdma_memory_pool_user_specified_memory) { + LOG_EVERY_SECOND(ERROR) << "Fail to extend new region, " + "rdma_memory_pool_user_specified_memory is " + "true, ExtendBlockPool is disabled"; + return NULL; + } + + // Regularize region size + region_size = region_size * BYTES_IN_MB / g_block_size[block_type] / g_buckets; + region_size *= g_block_size[block_type] * g_buckets; + + LOG(INFO) << "Start extend rdma memory " << region_size / BYTES_IN_MB << "MB"; + + void* region_base = NULL; + if (posix_memalign(®ion_base, 4096, region_size) != 0) { + PLOG_EVERY_SECOND(ERROR) << "Memory not enough"; + return NULL; + } + + return ExtendBlockPoolImpl(region_base, region_size, block_type); +} + +void* ExtendBlockPoolByUser(void* region_base, size_t region_size, + int block_type) { + if (FLAGS_rdma_memory_pool_user_specified_memory == false) { Review Comment: `!FLAGS_rdma_memory_pool_user_specified_memory`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org