Skip to content

Commit a078bc7

Browse files
committed
use actual pool name instead of default name
1 parent d1ce946 commit a078bc7

File tree

7 files changed

+33
-34
lines changed

7 files changed

+33
-34
lines changed

docs/config/ctl.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ appending an index after the name::
5555

5656
The number of pools with a given name can be obtained with the ``count`` node.
5757

58-
Wildcards
58+
wildcarded
5959
=========
6060

6161
A ``{}`` in the path acts as a wildcard and is replaced with successive
@@ -84,7 +84,7 @@ to providers or pools created after the defaults are set. For example::
8484

8585
Every subsequently created disjoint pool will use ``custom`` as its name unless
8686
overridden by explicit parameters. Defaults may be supplied programmatically or
87-
via configuration and are saved internally and applied during initalization of
87+
via configuration and are saved internally and applied during initialization of
8888
a matching provider or pool.
8989

9090
Environment variables
@@ -186,7 +186,7 @@ Logger nodes
186186
187187
:param path: Receives the currently selected sink on reads. On writes, pass
188188
``"stdout"`` or ``"stderr"`` to redirect to standard streams, a
189-
NUL-terminated file path to append to a file, or ``NULL`` to disable
189+
NULL-terminated file path to append to a file, or ``NULL`` to disable
190190
logging altogether.
191191
:type path: ``char *`` when reading, ``const char *`` when writing
192192

@@ -207,7 +207,7 @@ Provider entries are organized beneath ``umf.provider``. Use
207207
``umf.provider.by_handle.{provider}`` with a
208208
:type:`umf_memory_provider_handle_t` argument to reach a specific provider.
209209
Providers can also be addressed by name through ``umf.provider.by_name.{provider}``;
210-
append ``.{index}`` to address specyfic provider when multiple providers share the same label.
210+
append ``.{index}`` to address specific provider when multiple providers share the same label.
211211
Defaults for future providers live under ``umf.provider.default.{provider_name}``,
212212
where ``{provider_name}`` matches the canonical provider identifier (``OS``,
213213
``FILE``, ``DEVDAX``, ``FIXED``, ``CUDA`` or ``LEVEL_ZERO``). Values written to
@@ -346,7 +346,7 @@ Disjoint pool (``disjoint``)
346346
provider.
347347
:type bytes: ``size_t``
348348

349-
**Access:** read-write. (write is only avaiable through defaults)
349+
**Access:** read-write. (write is only available through defaults)
350350
**Defaults / Env:** supported.
351351

352352
Governs how much memory the pool grabs in each slab. Lower values reduce
@@ -359,7 +359,7 @@ Disjoint pool (``disjoint``)
359359
cached by the pool.
360360
:type bytes: ``size_t``
361361

362-
**Access:** read-write. (write is only avaiable through defaults)
362+
**Access:** read-write. (write is only available through defaults)
363363
**Defaults / Env:** supported.
364364

365365
Sets the cut-off for pooling allocations. Requests larger than this value are
@@ -372,7 +372,7 @@ Disjoint pool (``disjoint``)
372372
may retain.
373373
:type count: ``size_t``
374374

375-
**Access:** read-write. (write is only avaiable through defaults)
375+
**Access:** read-write. (write is only available through defaults)
376376
**Defaults / Env:** supported.
377377

378378
Caps the pool's cached slabs per bucket to limit memory retention. Shrinking
@@ -385,7 +385,7 @@ Disjoint pool (``disjoint``)
385385
serve.
386386
:type bytes: ``size_t``
387387

388-
**Access:** read-write. (write is only avaiable through defaults)
388+
**Access:** read-write. (write is only available through defaults)
389389
**Defaults / Env:** supported.
390390

391391
Controls the smallest chunk size kept in the pool, which in turn affects the
@@ -397,7 +397,7 @@ Disjoint pool (``disjoint``)
397397
:param level: Receives or supplies the tracing level for the pool.
398398
:type level: ``int`` (``0`` disables tracing)
399399

400-
**Access:** read-write. (write is only avaiable through defaults)
400+
**Access:** read-write. (write is only available through defaults)
401401
**Defaults / Env:** supported.
402402

403403
Controls the disjoint pool's tracing features. ``0`` disables tracing.

docs/config/spelling_exceptions.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ partList
5050
pid
5151
poolable
5252
preallocated
53+
programmatically
5354
propertyId
5455
providential
5556
providerIpcData
5657
ptr
5758
realloc
59+
runnables
5860
Scalable
5961
scalable
6062
stdout
@@ -82,5 +84,6 @@ umfMemspaceUserFilter
8284
umfMemspaceMemtargetAdd
8385
unfreed
8486
usm
87+
wildcarded
8588
zA
8689
ze

examples/ctl/ctl_example.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static umf_result_t ctl_ctl(void *provider, umf_ctl_query_source_t source,
204204
return UMF_RESULT_SUCCESS;
205205
}
206206
if (queryType == CTL_QUERY_RUNNABLE &&
207-
strcmp(formatted, "substraction") == 0) {
207+
strcmp(formatted, "subtraction") == 0) {
208208
if (p->m) {
209209
p->c = (p->a - p->b) % p->m;
210210
} else {
@@ -300,9 +300,9 @@ int main(void) {
300300

301301
// Execute subtraction and fetch the result
302302
res =
303-
umfCtlExec("umf.provider.by_handle.{}.substraction", NULL, 0, provider);
303+
umfCtlExec("umf.provider.by_handle.{}.subtraction", NULL, 0, provider);
304304
if (res != UMF_RESULT_SUCCESS) {
305-
fprintf(stderr, "Failed to execute substraction!\n");
305+
fprintf(stderr, "Failed to execute subtraction!\n");
306306
goto out;
307307
}
308308
res = umfCtlGet("umf.provider.by_handle.{}.c", &result, sizeof(result),
@@ -311,7 +311,7 @@ int main(void) {
311311
fprintf(stderr, "Failed to get c!\n");
312312
goto out;
313313
}
314-
printf("substraction result: %d\n", result);
314+
printf("subtraction result: %d\n", result);
315315

316316
out:
317317
umfMemoryProviderDestroy(provider);

examples/ctl/ctl_statistics_example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ int main(void) {
201201
goto cleanup;
202202
}
203203

204-
/* set name of the pool so we can easly ref it by using name */
204+
/* set name of the pool so we can easily ref it by using name */
205205
res = umfDisjointPoolParamsSetName(disjoint_params, pool_name);
206206
if (res != UMF_RESULT_SUCCESS) {
207207
fprintf(stderr, "Failed to name disjoint pool (error %d)\n", (int)res);

src/memory_pool.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -469,15 +469,14 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
469469
goto err_pool_init;
470470
}
471471

472-
// Set default property "name" to pool if exists
473472
const char *pname = NULL;
474-
ret = ops->get_name(NULL, &pname);
473+
ret = ops->get_name(pool->pool_priv, &pname);
475474
if (ret != UMF_RESULT_SUCCESS) {
476475
LOG_ERR("Failed to get pool name");
477476
goto err_pool_init;
478477
}
479478
assert(pname != NULL);
480-
479+
utils_warn_invalid_name("Memory pool", pname);
481480
ctl_default_apply(pool_default_list, pname, ops->ext_ctl, pool->pool_priv);
482481

483482
ret = umfPoolPostInitialize(&pool->ops, pool->pool_priv);
@@ -489,12 +488,6 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
489488
*hPool = pool;
490489
pools_by_name_add(pool);
491490

492-
const char *pool_name = NULL;
493-
if (ops->get_name(pool->pool_priv, &pool_name) == UMF_RESULT_SUCCESS &&
494-
pool_name) {
495-
utils_warn_invalid_name("Memory pool", pool_name);
496-
}
497-
498491
LOG_INFO("Memory pool created: %p", (void *)pool);
499492
return UMF_RESULT_SUCCESS;
500493

src/memory_provider.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,20 @@ umf_result_t umfMemoryProviderCreate(const umf_memory_provider_ops_t *ops,
345345

346346
utils_init_once(&mem_provider_ctl_initialized, provider_ctl_init);
347347
const char *pname = NULL;
348-
if (provider->ops.get_name(NULL, &pname) == UMF_RESULT_SUCCESS && pname) {
349-
ctl_default_apply(provider_default_list, pname, provider->ops.ext_ctl,
350-
provider->provider_priv);
348+
349+
ret = provider->ops.get_name(provider->provider_priv, &pname);
350+
if (ret != UMF_RESULT_SUCCESS) {
351+
LOG_ERR("Failed to get pool name");
352+
umf_ba_global_free(provider);
353+
return ret;
351354
}
355+
356+
assert(pname != NULL);
357+
utils_warn_invalid_name("Memory provider", pname);
358+
359+
ctl_default_apply(provider_default_list, pname, provider->ops.ext_ctl,
360+
provider->provider_priv);
361+
352362
ret = umfProviderPostInitialize(&provider->ops, provider_priv);
353363
if (ret != UMF_RESULT_SUCCESS && ret != UMF_RESULT_ERROR_INVALID_CTL_PATH) {
354364
LOG_ERR("Failed to post-initialize provider");
@@ -358,13 +368,6 @@ umf_result_t umfMemoryProviderCreate(const umf_memory_provider_ops_t *ops,
358368

359369
*hProvider = provider;
360370

361-
const char *provider_name = NULL;
362-
if (provider->ops.get_name(provider->provider_priv, &provider_name) ==
363-
UMF_RESULT_SUCCESS &&
364-
provider_name) {
365-
utils_warn_invalid_name("Memory provider", provider_name);
366-
}
367-
368371
return UMF_RESULT_SUCCESS;
369372
}
370373

test/ctl/ctl_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class CtlTest : public ::testing::Test {
6161
private:
6262
};
6363

64-
// setting default modyfies global state -
64+
// setting default modifies global state -
6565
// tests doing so should run in fork to ensure correct test isolation
6666
TEST_F(CtlTest, ctlDefault) {
6767
umf_test::run_in_fork([] {

0 commit comments

Comments
 (0)