- 
                Notifications
    
You must be signed in to change notification settings  - Fork 929
 
Closed
Description
@hjelmn I notice that there is a compiler warning with memory_patcher_component.c on the v2.x branch:
  CC       memory_patcher_component.lo
memory_patcher_component.c: In function 'intercept_shmdt':
memory_patcher_component.c:370:34: warning: passing argument 1 of 'opal_mem_hooks_release_hook' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     opal_mem_hooks_release_hook (shmaddr, memory_patcher_get_shm_seg_size (shmaddr), false);
                                  ^
In file included from ../../../../opal/memoryhooks/memory.h:42:0,
                 from memory_patcher_component.c:33:
../../../../opal/memoryhooks/memory_internal.h:37:20: note: expected 'void *' but argument is of type 'const void *'
 OPAL_DECLSPEC void opal_mem_hooks_release_hook(void *buf, size_t length, bool from_alloc);
                    ^
I did a diff between the memory patcher component on master and v2.x and found a bunch of changes between the two -- do these need to be reconciled?
diff --unified opal/mca/memory/patcher/configure.m4 /home/jsquyres/git/ompi/opal
/mca/memory/patcher/configure.m4
--- opal/mca/memory/patcher/configure.m4        2016-06-17 08:46:04.646978465 -0
700
+++ /home/jsquyres/git/ompi/opal/mca/memory/patcher/configure.m4        2016-06-
07 18:54:08.761627149 -0700
@@ -10,7 +10,7 @@
 #                         University of Stuttgart.  All rights reserved.
 # Copyright (c) 2004-2005 The Regents of the University of California.
 #                         All rights reserved.
-# Copyright (c) 2008-2010 Cisco Systems, Inc.  All rights reserved.
+# Copyright (c) 2008-2016 Cisco Systems, Inc.  All rights reserved.
 # Copyright (c) 2015      Research Organization for Information Science
 #                         and Technology (RIST). All rights reserved.
 # Copyright (c) 2016      Los Alamos National Security, LLC. All rights
@@ -84,7 +84,7 @@
     AC_DEFINE_UNQUOTED([OPAL_MEMORY_PATCHER_HAVE___SYSCALL], [$memory_patcher_h
ave___syscall],
                        [Whether the internal __syscall call exists])
-    AC_CHECK_HEADERS([linux/mman.h])
+    AC_CHECK_HEADERS([linux/mman.h sys/syscall.h])
     [$1]
diff --unified opal/mca/memory/patcher/memory_patcher_component.c /home/jsquyres
/git/ompi/opal/mca/memory/patcher/memory_patcher_component.c
--- opal/mca/memory/patcher/memory_patcher_component.c  2016-06-17 08:46:04.6469
78465 -0700
+++ /home/jsquyres/git/ompi/opal/mca/memory/patcher/memory_patcher_component.c  
2016-06-07 18:54:08.761627149 -0700
@@ -31,6 +31,7 @@
 #include "opal/mca/memory/base/empty.h"
 #include "opal/mca/memory/base/base.h"
 #include "opal/memoryhooks/memory.h"
+#include "opal/mca/patcher/base/base.h"  
 #include <stdlib.h>
 #include <stdint.h>
@@ -41,8 +42,9 @@
 #include <dlfcn.h>
 #include <assert.h>
 #include <sys/time.h>
+#if defined(HAVE_SYS_SYSCALL_H)
 #include <sys/syscall.h>
-
+#endif
 #if defined(HAVE_LINUX_MMAN_H)
 #include <linux/mman.h>
 #endif
@@ -367,7 +369,9 @@
     OPAL_PATCHER_BEGIN;
     int result;
-    opal_mem_hooks_release_hook (shmaddr, memory_patcher_get_shm_seg_size (shmaddr), false);
+    /* opal_mem_hooks_release_hook should probably be updated to take a const void *.
+     * for now just cast away the const */
+    opal_mem_hooks_release_hook ((void *) shmaddr, memory_patcher_get_shm_seg_size (shmaddr), false);
     if (original_shmdt) {
         result = original_shmdt (shmaddr);
@@ -393,11 +397,16 @@
 static int patcher_query (int *priority)
 {
-    if (opal_patcher->patch_symbol) {
-        *priority = mca_memory_patcher_priority;
-    } else {
+    int rc;
+
+    rc = mca_base_framework_open (&opal_patcher_base_framework, 0);
+    if (OPAL_SUCCESS != rc) {
         *priority = -1;
+        return OPAL_SUCCESS;
     }
+
+    *priority = mca_memory_patcher_priority;
+
     return OPAL_SUCCESS;
 }
@@ -412,6 +421,12 @@
     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);
@@ -459,6 +474,8 @@
 static int patcher_close(void)
 {
+    mca_base_framework_close (&opal_patcher_base_framework);
+
     /* Note that we don't need to unpatch any symbols here; the
        patcher framework will take care of all of that for us. */
     return OPAL_SUCCESS;