Skip to content

Commit 5c685e2

Browse files
committed
memory/linux: make memory_linux_memalign an enum
Thanks Igor Ivanov for the review.
1 parent 5a85a03 commit 5c685e2

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

-7
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,3 @@ alternate memory hook manager *may* be used instead (if available).
2727
Local host: %s
2828
UMMU device: %s
2929
Error: %s (%d)
30-
#
31-
[invalid mca param value]
32-
WARNING: An invalid MCA parameter value was found for memory/linux
33-
component.
34-
35-
Problem: %s
36-
Resolution: %s

opal/mca/memory/linux/memory_linux_component.c

+15-12
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ static void *(*prev_malloc_hook)(size_t, const void *);
129129
* memalign which will be called through __malloc_hook instead of malloc.
130130
*/
131131
static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller);
132+
133+
static mca_base_var_enum_value_t align_values[] = {
134+
{-1, "disabled"},
135+
{0, "0"},
136+
{32, "32"},
137+
{64, "64"},
138+
{0, NULL}
139+
};
132140
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
133141

134142

@@ -137,6 +145,9 @@ static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller)
137145
*/
138146
static int linux_register(void)
139147
{
148+
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
149+
mca_base_var_enum_t *new_enum;
150+
#endif
140151
int ret;
141152
/* Information only */
142153
ret = mca_base_component_var_register (&mca_memory_linux_component.super.memoryc_version,
@@ -199,17 +210,19 @@ static int linux_register(void)
199210
}
200211

201212
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
213+
(void)mca_base_var_enum_create("memory_linux_memalign", align_values, &new_enum);
202214
mca_memory_linux_component.use_memalign = -1;
203215
ret = mca_base_component_var_register(&mca_memory_linux_component.super.memoryc_version,
204216
"memalign",
205-
"[64 | 32 | 0] - Enable memory alignment for all malloc calls (default: disabled).",
217+
"[64 | 32 | 0] - Enable memory alignment for all malloc calls.",
206218
MCA_BASE_VAR_TYPE_INT,
207-
NULL,
219+
new_enum,
208220
0,
209221
0,
210222
OPAL_INFO_LVL_5,
211223
MCA_BASE_VAR_SCOPE_READONLY,
212224
&mca_memory_linux_component.use_memalign);
225+
OBJ_RELEASE(new_enum);
213226
if (0 > ret) {
214227
return ret;
215228
}
@@ -230,16 +243,6 @@ static int linux_register(void)
230243
if (0 > ret) {
231244
return ret;
232245
}
233-
234-
if (mca_memory_linux_component.use_memalign != -1
235-
&& mca_memory_linux_component.use_memalign != 32
236-
&& mca_memory_linux_component.use_memalign != 64
237-
&& mca_memory_linux_component.use_memalign != 0){
238-
opal_show_help("help-opal-memory-linux.txt", "invalid mca param value",
239-
true, "Wrong memalign parameter value. Allowed values: 64, 32, 0.",
240-
"memory_linux_memalign is reset to 32");
241-
mca_memory_linux_component.use_memalign = 32;
242-
}
243246
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
244247

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

0 commit comments

Comments
 (0)