Skip to content

Commit a8eb899

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

File tree

9 files changed

+264
-55
lines changed

9 files changed

+264
-55
lines changed

docs/config/ctl.rst

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Every ``{}`` in the path is replaced with an extra argument passed to the CTL
3737
function. Alternative addressing methods are described below.
3838

3939
Pool / Provider addressing
40-
==========================
40+
============================
4141

4242
Two addressing schemes are provided: ``by_handle`` and ``by_name``. Each pool
4343
and provider has a unique handle and an optional user-defined name that can be
@@ -56,7 +56,7 @@ appending an index after the name::
5656
The number of pools with a given name can be obtained with the ``count`` node.
5757

5858
Wildcards
59-
=========
59+
===========
6060

6161
A ``{}`` in the path acts as a wildcard and is replaced with successive
6262
arguments of ``umfCtlGet``, ``umfCtlSet`` or ``umfCtlExec``. Wildcards can
@@ -74,18 +74,21 @@ replace any node, not only handles. For example::
7474
Ensure that the types of wildcard arguments match the expected node types.
7575

7676
Default addressing
77-
==================
77+
===================
7878

7979
``umf.provider.default`` and ``umf.pool.default`` store default values applied
8080
to providers or pools created after the defaults are set. For example::
8181

82-
const char *name = "custom";
83-
umfCtlSet("umf.pool.default.disjoint.name", (void *)name, strlen(name)+1);
82+
size_t capacity = 16;
83+
umfCtlSet("umf.pool.default.disjoint.params.capacity", &capacity,
84+
sizeof(capacity));
8485

85-
Every subsequently created disjoint pool will use ``custom`` as its name unless
86-
overridden by explicit parameters. Defaults may be supplied programmatically or
87-
via configuration and are saved internally and applied during initalization of
88-
a matching provider or pool.
86+
Every subsequently created disjoint pool will use ``16`` as its starting
87+
capacity overriding it's creation parameters. Defaults are keyed by the
88+
name returned from the provider or pool ``get_name`` callback, so if pool/provider
89+
has custom name it must be addressed explicitly. Defaults may be supplied programmatically
90+
or via environment variable and are saved internally and applied during initialization of a
91+
matching provider or pool.
8992

9093
Environment variables
9194
=====================
@@ -116,7 +119,7 @@ Within each subsystem the path continues with an addressing scheme followed by
116119
the module or leaf of interest.
117120

118121
Reading this reference
119-
----------------------
122+
------------------------
120123

121124
Parameter annotations describe the values stored in the node rather than the
122125
pointer types passed to ``umfCtlGet``/``umfCtlSet``/``umfCtlExec``. The
@@ -186,7 +189,7 @@ Logger nodes
186189
187190
:param path: Receives the currently selected sink on reads. On writes, pass
188191
``"stdout"`` or ``"stderr"`` to redirect to standard streams, a
189-
NUL-terminated file path to append to a file, or ``NULL`` to disable
192+
NULL-terminated file path to append to a file, or ``NULL`` to disable
190193
logging altogether.
191194
:type path: ``char *`` when reading, ``const char *`` when writing
192195

@@ -207,14 +210,14 @@ Provider entries are organized beneath ``umf.provider``. Use
207210
``umf.provider.by_handle.{provider}`` with a
208211
:type:`umf_memory_provider_handle_t` argument to reach a specific provider.
209212
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.
211-
Defaults for future providers live under ``umf.provider.default.{provider_name}``,
212-
where ``{provider_name}`` matches the canonical provider identifier (``OS``,
213-
``FILE``, ``DEVDAX``, ``FIXED``, ``CUDA`` or ``LEVEL_ZERO``). Values written to
214-
the default tree are saved until a matching provider is created and applied
215-
during provider initialization. Defaults can be supplied programmatically or
216-
through configuration strings. The entries below list only the suffix of each
217-
node; prefix them with the appropriate ``umf.provider`` path.
213+
append ``.{index}`` to address specific provider when multiple providers share the same label.
214+
Defaults for future providers reside under ``umf.provider.default.{provider}`` and track the
215+
name returned by each provider's ``get_name`` implementation. Providers have their
216+
default names (``OS``, ``FILE``, ``DEVDAX``, ``FIXED``, ``CUDA`` or ``LEVEL_ZERO``),
217+
unless their name was changed during creation, those renamed providers must be addressed explicitly.
218+
Defaults can be written via ``umf.provider.default.<name>`` either programmatically or through
219+
configuration strings. The entries below list only the suffix of each node;
220+
prefix them with the appropriate ``umf.provider`` path.
218221

219222
Common provider statistics
220223
--------------------------
@@ -316,11 +319,13 @@ Pool nodes
316319
Pool entries mirror the provider layout. ``umf.pool.by_handle.{pool}`` accepts a
317320
:type:`umf_memory_pool_handle_t`, while ``umf.pool.by_name.{pool}`` addresses
318321
pools by name with an optional ``.{index}`` suffix when names are reused.
319-
Defaults for future pools reside under ``umf.pool.default.{pool}``, where
320-
canonical names include ``disjoint``, ``scalable`` and ``jemalloc``. Defaults
321-
can be written via ``umf.pool.default.<pool>`` either programmatically or
322-
through configuration strings. The entries below list only the suffix of each
323-
node; prefix them with the appropriate ``umf.pool`` path.
322+
Defaults for future pools reside under ``umf.pool.default.{pool}`` and track the
323+
name returned by each pool's ``get_name`` implementation. Pools that keep their
324+
default names (``disjoint``, ``scalable`` and ``jemalloc``) continue to match
325+
those entries, while renamed pools must be addressed explicitly. Defaults can be
326+
written via ``umf.pool.default.<pool>`` either programmatically or through
327+
configuration strings. The entries below list only the suffix of each node;
328+
prefix them with the appropriate ``umf.pool`` path.
324329

325330
Common pool statistics
326331
--------------------------
@@ -346,7 +351,7 @@ Disjoint pool (``disjoint``)
346351
provider.
347352
:type bytes: ``size_t``
348353

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

352357
Governs how much memory the pool grabs in each slab. Lower values reduce
@@ -359,7 +364,7 @@ Disjoint pool (``disjoint``)
359364
cached by the pool.
360365
:type bytes: ``size_t``
361366

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

365370
Sets the cut-off for pooling allocations. Requests larger than this value are
@@ -372,7 +377,7 @@ Disjoint pool (``disjoint``)
372377
may retain.
373378
:type count: ``size_t``
374379

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

378383
Caps the pool's cached slabs per bucket to limit memory retention. Shrinking
@@ -385,7 +390,7 @@ Disjoint pool (``disjoint``)
385390
serve.
386391
:type bytes: ``size_t``
387392

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

391396
Controls the smallest chunk size kept in the pool, which in turn affects the
@@ -397,7 +402,7 @@ Disjoint pool (``disjoint``)
397402
:param level: Receives or supplies the tracing level for the pool.
398403
:type level: ``int`` (``0`` disables tracing)
399404

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

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

docs/config/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. Copyright 2023 Intel Corporation
1+
.. Copyright 2023-2025 Intel Corporation
22
Intel Unified Memory Framework documentation
33
44
Intel Unified Memory Framework documentation
@@ -10,4 +10,6 @@ Intel Unified Memory Framework documentation
1010
introduction.rst
1111
examples.rst
1212
api.rst
13+
ctl.rst
1314
glossary.rst
15+

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

0 commit comments

Comments
 (0)