/* * This component exists to establish the memory hook support * level available on Solaris. By default Solaris does not * return memory to the system, i.e. does not unmap memory * from the process space, when a user calls free(). This allows * us to declare OPAL_MEMORY_FREE_SUPPORT. Additionally, by * intercepting munmap we can declare OPAL_MEMORY_MUNMAP_SUPPORT. * * NOTE: Not releasing memory back to the system when calling * free() may be unique to Solaris which is why this component * was created. */ static int opal_memory_malloc_open(void) { opal_mem_hooks_set_support( (OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT)); return OPAL_SUCCESS; }
static int patcher_open (void) { static int was_executed_already = 0; int rc; if (was_executed_already) { return OPAL_SUCCESS; } was_executed_already = 1; /* set memory hooks support level */ opal_mem_hooks_set_support (OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT); #if 0 /* NTH: the only reason to hook mmap would be to detect memory protection. this does not invalidate * any cache entries in the region. */ rc = opal_patcher->patch_symbol ("mmap", (uintptr_t) intercept_mmap, (uintptr_t *) &original_mmap); if (OPAL_SUCCESS != rc) { return rc; } #endif rc = opal_patcher->patch_symbol ("munmap", (uintptr_t)intercept_munmap, (uintptr_t *) &original_munmap); if (OPAL_SUCCESS != rc) { return rc; } #if defined (SYS_mremap) rc = opal_patcher->patch_symbol ("mremap",(uintptr_t)intercept_mremap, (uintptr_t *) &original_mremap); if (OPAL_SUCCESS != rc) { return rc; } #endif rc = opal_patcher->patch_symbol ("madvise", (uintptr_t)intercept_madvise, (uintptr_t *) &original_madvise); if (OPAL_SUCCESS != rc) { return rc; } #if defined(SYS_shmdt) && defined(__linux__) rc = opal_patcher->patch_symbol ("shmdt", (uintptr_t) intercept_shmdt, (uintptr_t *) &original_shmdt); if (OPAL_SUCCESS != rc) { return rc; } #endif #if defined (SYS_brk) rc = opal_patcher->patch_symbol ("brk", (uintptr_t)intercept_brk, (uintptr_t *) &original_brk); #endif return rc; }
static int patcher_open (void) { static int was_executed_already = 0; int rc; if (was_executed_already) { return OPAL_SUCCESS; } was_executed_already = 1; rc = opal_patcher_base_select (); if (OPAL_SUCCESS != rc) { mca_base_framework_close (&opal_patcher_base_framework); return OPAL_ERR_NOT_AVAILABLE; } /* set memory hooks support level */ opal_mem_hooks_set_support (OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT); #if 0 /* See above block to see why mmap() functionality is #if 0'ed out */ rc = opal_patcher->patch_symbol ("mmap", (uintptr_t) intercept_mmap, (uintptr_t *) &original_mmap); if (OPAL_SUCCESS != rc) { return rc; } #endif rc = opal_patcher->patch_symbol ("munmap", (uintptr_t)intercept_munmap, (uintptr_t *) &original_munmap); if (OPAL_SUCCESS != rc) { return rc; } #if defined (SYS_mremap) rc = opal_patcher->patch_symbol ("mremap",(uintptr_t)intercept_mremap, (uintptr_t *) &original_mremap); if (OPAL_SUCCESS != rc) { return rc; } #endif #if defined (SYS_madvise) rc = opal_patcher->patch_symbol ("madvise", (uintptr_t)intercept_madvise, (uintptr_t *) &original_madvise); if (OPAL_SUCCESS != rc) { return rc; } #endif #if defined(SYS_shmdt) && defined(__linux__) rc = opal_patcher->patch_symbol ("shmdt", (uintptr_t) intercept_shmdt, (uintptr_t *) &original_shmdt); if (OPAL_SUCCESS != rc) { return rc; } #endif #if defined (SYS_brk) rc = opal_patcher->patch_symbol ("brk", (uintptr_t)intercept_brk, (uintptr_t *) &original_brk); #endif return rc; }