Skip to content

memory/linux: make memory_linux_memalign an enum #1420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions opal/mca/memory/linux/help-opal-memory-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,3 @@ alternate memory hook manager *may* be used instead (if available).
Local host: %s
UMMU device: %s
Error: %s (%d)
#
[invalid mca param value]
WARNING: An invalid MCA parameter value was found for memory/linux
component.

Problem: %s
Resolution: %s
27 changes: 15 additions & 12 deletions opal/mca/memory/linux/memory_linux_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ static void *(*prev_malloc_hook)(size_t, const void *);
* memalign which will be called through __malloc_hook instead of malloc.
*/
static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller);

static mca_base_var_enum_value_t align_values[] = {
{-1, "disabled"},
{0, "0"},
{32, "32"},
{64, "64"},
{0, NULL}
};
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */


Expand All @@ -137,6 +145,9 @@ static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller)
*/
static int linux_register(void)
{
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
mca_base_var_enum_t *new_enum;
#endif
int ret;
/* Information only */
ret = mca_base_component_var_register (&mca_memory_linux_component.super.memoryc_version,
Expand Down Expand Up @@ -199,17 +210,19 @@ static int linux_register(void)
}

#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
(void)mca_base_var_enum_create("memory_linux_memalign", align_values, &new_enum);
mca_memory_linux_component.use_memalign = -1;
ret = mca_base_component_var_register(&mca_memory_linux_component.super.memoryc_version,
"memalign",
"[64 | 32 | 0] - Enable memory alignment for all malloc calls (default: disabled).",
"[64 | 32 | 0] - Enable memory alignment for all malloc calls.",
MCA_BASE_VAR_TYPE_INT,
NULL,
new_enum,
0,
0,
OPAL_INFO_LVL_5,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_memory_linux_component.use_memalign);
OBJ_RELEASE(new_enum);
if (0 > ret) {
return ret;
}
Expand All @@ -230,16 +243,6 @@ static int linux_register(void)
if (0 > ret) {
return ret;
}

if (mca_memory_linux_component.use_memalign != -1
&& mca_memory_linux_component.use_memalign != 32
&& mca_memory_linux_component.use_memalign != 64
&& mca_memory_linux_component.use_memalign != 0){
opal_show_help("help-opal-memory-linux.txt", "invalid mca param value",
true, "Wrong memalign parameter value. Allowed values: 64, 32, 0.",
"memory_linux_memalign is reset to 32");
mca_memory_linux_component.use_memalign = 32;
}
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */

return (0 > ret) ? ret : OPAL_SUCCESS;
Expand Down