Skip to content

Commit 27edb79

Browse files
committed
Cache page size of the provider in jemalloc pool
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent b3bbdd4 commit 27edb79

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/pool/pool_jemalloc.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
typedef struct jemalloc_memory_pool_t {
3838
umf_memory_provider_handle_t provider;
39+
size_t page_size; // cached page size of the provider
3940
unsigned int arena_index; // index of jemalloc arena
4041
// set to true if umfMemoryProviderFree() should never be called
4142
bool disable_provider_free;
@@ -401,6 +402,8 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
401402
assert(provider);
402403
assert(out_pool);
403404

405+
umf_result_t umf_result = UMF_RESULT_ERROR_UNKNOWN;
406+
404407
umf_jemalloc_pool_params_t *je_params =
405408
(umf_jemalloc_pool_params_t *)params;
406409

@@ -416,6 +419,13 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
416419

417420
pool->provider = provider;
418421

422+
umf_result =
423+
umfMemoryProviderGetMinPageSize(provider, NULL, &pool->page_size);
424+
if (umf_result != UMF_RESULT_SUCCESS) {
425+
LOG_ERR("umfMemoryProviderGetMinPageSize() failed");
426+
goto err_free_pool;
427+
}
428+
419429
if (je_params) {
420430
pool->disable_provider_free = je_params->disable_provider_free;
421431
} else {
@@ -427,6 +437,7 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
427437
NULL, 0);
428438
if (err) {
429439
LOG_ERR("Could not create arena.");
440+
umf_result = UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC;
430441
goto err_free_pool;
431442
}
432443

@@ -438,6 +449,7 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
438449
snprintf(cmd, sizeof(cmd), "arena.%u.destroy", arena_index);
439450
je_mallctl(cmd, NULL, 0, NULL, 0);
440451
LOG_ERR("Could not setup extent_hooks for newly created arena.");
452+
umf_result = UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC;
441453
goto err_free_pool;
442454
}
443455

@@ -452,7 +464,7 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
452464

453465
err_free_pool:
454466
umf_ba_global_free(pool);
455-
return UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC;
467+
return umf_result;
456468
}
457469

458470
static void op_finalize(void *pool) {

0 commit comments

Comments
 (0)