@@ -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 */
137137static 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 */
144152static 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