From 5c685e2332dde23e7ff1fe592a400759aea4cefc Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 2 Mar 2016 14:19:06 +0900 Subject: [PATCH] memory/linux: make memory_linux_memalign an enum Thanks Igor Ivanov for the review. --- .../memory/linux/help-opal-memory-linux.txt | 7 ----- .../mca/memory/linux/memory_linux_component.c | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/opal/mca/memory/linux/help-opal-memory-linux.txt b/opal/mca/memory/linux/help-opal-memory-linux.txt index 4e16124dc0..b3327c7356 100644 --- a/opal/mca/memory/linux/help-opal-memory-linux.txt +++ b/opal/mca/memory/linux/help-opal-memory-linux.txt @@ -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 diff --git a/opal/mca/memory/linux/memory_linux_component.c b/opal/mca/memory/linux/memory_linux_component.c index 3319066bbb..d883f10f2a 100644 --- a/opal/mca/memory/linux/memory_linux_component.c +++ b/opal/mca/memory/linux/memory_linux_component.c @@ -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 */ @@ -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, @@ -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; } @@ -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;