Skip to content

Commit 0890ebb

Browse files
committed
add umf split mode to os_memory_provider
split mode splits each allocation based on user provided partitions, across multiple numa nodes. If no partition defined then each allocation is split evenly, across all numa available. Signed-off-by: Łukasz Plewa <[email protected]>
1 parent c5735e4 commit 0890ebb

File tree

5 files changed

+514
-39
lines changed

5 files changed

+514
-39
lines changed

include/umf/providers/provider_os_memory.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,26 @@ typedef enum umf_numa_mode_t {
5757
/// fulfilled, memory will be allocated from other nodes.
5858
UMF_NUMA_MODE_PREFERRED,
5959

60+
/// Allocation will be split evenly across nodes specified in nodemask.
61+
/// umf_numa_split_partition_t can be passed in umf_os_memory_provider_params_t structure
62+
/// to specify other distribution.
63+
UMF_NUMA_MODE_SPLIT,
6064
/// The memory is allocated on the node of the CPU that triggered the
6165
/// allocation. If this mode is specified, nodemask must be NULL and
6266
/// maxnode must be 0.
6367
UMF_NUMA_MODE_LOCAL, // TODO: should this be a hint or strict policy?
6468
} umf_numa_mode_t;
6569

70+
/// @brief This structure specifies a user-defined page distribution
71+
/// within a single allocation in UMF_NUMA_MODE_SPLIT mode.
72+
typedef struct umf_numa_split_partition_t {
73+
/// The weight of the partition, representing the proportion of
74+
/// the allocation that should be assigned to this NUMA node.
75+
unsigned weight;
76+
/// The NUMA node where the pages assigned to this partition will be bound.
77+
unsigned target;
78+
} umf_numa_split_partition_t;
79+
6680
/// @brief Memory provider settings struct
6781
typedef struct umf_os_memory_provider_params_t {
6882
/// Combination of 'umf_mem_protection_flags_t' flags
@@ -81,6 +95,11 @@ typedef struct umf_os_memory_provider_params_t {
8195
/// part size for interleave mode - 0 means default (system specific)
8296
/// It might be rounded up because of HW constraints
8397
size_t part_size;
98+
99+
/// ordered list of the partitions for the split mode
100+
umf_numa_split_partition_t *partitions;
101+
/// len of the partitions array
102+
unsigned partitions_len;
84103
} umf_os_memory_provider_params_t;
85104

86105
/// @brief OS Memory Provider operation results
@@ -106,8 +125,9 @@ umfOsMemoryProviderParamsDefault(void) {
106125
NULL, /* numa_list */
107126
0, /* numa_list_len */
108127
UMF_NUMA_MODE_DEFAULT, /* numa_mode */
109-
0 /* part_size */
110-
};
128+
0, /* part_size */
129+
NULL, /* partitions */
130+
0}; /* partitions_len*/
111131

112132
return params;
113133
}

0 commit comments

Comments
 (0)