Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 9baa314

Browse files
ggouaillardetigor-ivanov
authored andcommitted
memory/linux: make memory_linux_memalign an enum
Thanks Igor Ivanov for the review.
1 parent c2798a8 commit 9baa314

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

opal/mca/memory/linux/help-opal-memory-linux.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,3 @@ alternate memory hook manager *may* be used instead (if available).
4040
Local host: %s
4141
UMMU device: %s
4242
Error: %s (%d)
43-
#
44-
[invalid mca param value]
45-
WARNING: An invalid MCA parameter value was found for memory/linux
46-
component.
47-
48-
Problem: %s
49-
Resolution: %s

opal/mca/memory/linux/memory_linux_component.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ static void *(*prev_malloc_hook)(size_t, const void *);
135135
* memalign which will be called through __malloc_hook instead of malloc.
136136
*/
137137
static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller);
138+
139+
static mca_base_var_enum_value_t align_values[] = {
140+
{-1, "disabled"},
141+
{0, "0"},
142+
{32, "32"},
143+
{64, "64"},
144+
{0, NULL}
145+
};
138146
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
139147

140148

@@ -143,6 +151,9 @@ static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller)
143151
*/
144152
static int linux_register(void)
145153
{
154+
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
155+
mca_base_var_enum_t *new_enum;
156+
#endif
146157
int ret;
147158
/* Information only */
148159
ret = mca_base_component_var_register (&mca_memory_linux_component.super.memoryc_version,
@@ -205,17 +216,19 @@ static int linux_register(void)
205216
}
206217

207218
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
219+
(void)mca_base_var_enum_create("memory_linux_memalign", align_values, &new_enum);
208220
mca_memory_linux_component.use_memalign = -1;
209221
ret = mca_base_component_var_register(&mca_memory_linux_component.super.memoryc_version,
210222
"memalign",
211-
"[64 | 32 | 0] - Enable memory alignment for all malloc calls (default: disabled).",
223+
"[64 | 32 | 0] - Enable memory alignment for all malloc calls.",
212224
MCA_BASE_VAR_TYPE_INT,
213-
NULL,
225+
new_enum,
214226
0,
215227
0,
216228
OPAL_INFO_LVL_5,
217229
MCA_BASE_VAR_SCOPE_READONLY,
218230
&mca_memory_linux_component.use_memalign);
231+
OBJ_RELEASE(new_enum);
219232
if (0 > ret) {
220233
return ret;
221234
}
@@ -236,16 +249,6 @@ static int linux_register(void)
236249
if (0 > ret) {
237250
return ret;
238251
}
239-
240-
if (mca_memory_linux_component.use_memalign != -1
241-
&& mca_memory_linux_component.use_memalign != 32
242-
&& mca_memory_linux_component.use_memalign != 64
243-
&& mca_memory_linux_component.use_memalign != 0){
244-
opal_show_help("help-opal-memory-linux.txt", "invalid mca param value",
245-
true, "Wrong memalign parameter value. Allowed values: 64, 32, 0.",
246-
"memory_linux_memalign is reset to 32");
247-
mca_memory_linux_component.use_memalign = 32;
248-
}
249252
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
250253

251254
return (0 > ret) ? ret : OPAL_SUCCESS;

0 commit comments

Comments
 (0)