Skip to content

Commit 5a9b468

Browse files
committed
Add documentation to OS provider
1 parent 8a63b43 commit 5a9b468

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

include/umf/providers/provider_os_memory.h

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,56 @@ extern "C" {
1616

1717
#define UMF_OS_RESULTS_START_FROM 1000
1818

19+
/// @brief Protection of the memory allocations
1920
typedef enum umf_mem_protection_flags_t {
20-
UMF_PROTECTION_NONE = (1 << 0),
21-
UMF_PROTECTION_READ = (1 << 1),
22-
UMF_PROTECTION_WRITE = (1 << 2),
23-
UMF_PROTECTION_EXEC = (1 << 3),
21+
UMF_PROTECTION_NONE = (1 << 0), ///< Memory allocations can not be accessed
22+
UMF_PROTECTION_READ = (1 << 1), ///< Memory allocations can be read.
23+
UMF_PROTECTION_WRITE = (1 << 2), ///< Memory allocations can be written.
24+
UMF_PROTECTION_EXEC = (1 << 3), ///< Memory allocations can be executed.
2425

2526
UMF_PROTECTION_MAX // must be the last one
2627
} umf_mem_protection_flags_t;
2728

29+
/// @brief Visibility of the memory allocations
2830
typedef enum umf_mem_visibility_t {
29-
UMF_VISIBILITY_SHARED,
30-
UMF_VISIBILITY_PRIVATE,
31+
UMF_VISIBILITY_SHARED, ///< Updates to the memory allocated using OS provider are visible to other processes.
32+
/// TODO: need to expose functionality to share open the mapping in other process and explicit sync?
33+
UMF_VISIBILITY_PRIVATE, ///< Updates to the memory allocated using OS provider are not visible to other processes.
3134
} umf_mem_visibility_t;
3235

36+
/// @brief Memory binding mode
37+
///
38+
/// Specifies how memory is bound to NUMA nodes on systems that support NUMA.
39+
/// Not every mode is supported on every system.
3340
typedef enum umf_numa_mode_t {
34-
UMF_NUMA_MODE_DEFAULT,
35-
UMF_NUMA_MODE_BIND,
36-
UMF_NUMA_MODE_INTERLEAVE,
37-
UMF_NUMA_MODE_PREFERRED,
38-
UMF_NUMA_MODE_LOCAL,
41+
UMF_NUMA_MODE_DEFAULT, ///< Default binding mode. Actual binding policy is system-specific.
42+
/// On linux this corresponds to MPOL_DEFAULT. If this mode is specified,
43+
/// nodemask must be NULL and maxnode must be 0.
44+
UMF_NUMA_MODE_BIND, ///< Restricts memory allocation to nodes specified in nodemask. Allocations
45+
/// might come from any of the allowed nodes.
46+
UMF_NUMA_MODE_INTERLEAVE, ///< Interleaves memory allocations across the set of nodes specified in nodemask.
47+
UMF_NUMA_MODE_PREFERRED, ///< Specifies preferred node for allocation. If allocation cannot be fulfilled,
48+
/// memory will be allocated from other nodes.
49+
UMF_NUMA_MODE_LOCAL, ///< The memory is allocated on the node of the CPU that triggered the allocation.
50+
/// If this mode is specified, nodemask must be NULL and maxnode must be 0.
51+
/// TODO: should this be a hint or strict policy?
3952
} umf_numa_mode_t;
4053

41-
typedef enum umf_purge_advise_t {
42-
UMF_PURGE_LAZY,
43-
UMF_PURGE_FORCE,
44-
} umf_purge_advise_t;
45-
4654
/// @brief Memory provider settings struct
4755
typedef struct umf_os_memory_provider_params_t {
4856
/// combination of 'umf_mem_protection_flags_t' flags
4957
unsigned protection;
58+
5059
/// shared or private visibility of memory mapped by a provider
51-
/// sets MAP_SHARED and MAP_PRIVATE flags respectively on internal mmap() calls
5260
umf_mem_visibility_t visibility;
5361

5462
// NUMA config
55-
/// nodemask used in internal mbind() calls
63+
/// points to a bit mask of nodes containing up to maxnode bits, depending on
64+
/// selected numa_mode newly allocated memory will be bound to those nodes
5665
unsigned long *nodemask;
57-
/// maximum number of nodes in \p nodemask
66+
/// max number of bits in nodemask
5867
unsigned long maxnode;
59-
/// flag that relates to one of the MPOL_* flags used in internal mbind() calls
68+
/// describes how nodemask is interpreted
6069
umf_numa_mode_t numa_mode;
6170

6271
// others

src/provider/provider_os_memory_internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
extern "C" {
1616
#endif
1717

18+
typedef enum umf_purge_advise_t {
19+
UMF_PURGE_LAZY,
20+
UMF_PURGE_FORCE,
21+
} umf_purge_advise_t;
22+
1823
int os_translate_flags(unsigned in_flags, unsigned max,
1924
int (*translate_flag)(unsigned));
2025

0 commit comments

Comments
 (0)