>Did you commit this change to the librdmacm git?

I just pushed this upstream.

Also, here's what I've created so far for the libibcm.  I haven't tested
or completed it, but at least it's a starting point.  I stopped working
when I reached the event handling code in the libibcm.  If you don't get
to this, I'll try to finish it up early next week.

- Sean

diff --git a/configure.in b/configure.in
index e33a188..ae47451 100644
--- a/configure.in
+++ b/configure.in
@@ -9,6 +9,18 @@ AM_INIT_AUTOMAKE(libibcm, 1.0-1)
 
 AM_PROG_LIBTOOL
 
+AC_ARG_WITH([valgrind],
+    AC_HELP_STRING([--with-valgrind],
+                  [Enable valgrind annotations - default NO]))
+
+if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
+    AC_DEFINE([INCLUDE_VALGRIND], 1,
+             [Define to 1 to enable valgrind annotations])
+    if test -d $with_valgrind; then
+        CPPFLAGS="$CPPFLAGS -I$with_valgrind/include"
+    fi
+fi
+
 AC_ARG_ENABLE(libcheck, [  --disable-libcheck      do not test for presence of 
ib libraries],
 [       if test "$enableval" = "no"; then
                 disable_libcheck=yes
@@ -38,6 +50,12 @@ AC_CHECK_HEADER(infiniband/verbs.h, [],
     AC_MSG_ERROR([<infiniband/verbs.h> not found.  Is libibverbs installed?]))
 AC_CHECK_HEADER(infiniband/marshall.h, [],
     AC_MSG_ERROR([<infiniband/marshall.h> not found.  Is libibverbs 
installed?]))
+
+if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
+AC_CHECK_HEADER(valgrind/memcheck.h, [],
+    AC_MSG_ERROR([valgrind requested but <valgrind/memcheck.h> not found.]))
+fi
+
 fi
 
 AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
diff --git a/src/cm.c b/src/cm.c
index 2572972..1dba773 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -51,6 +51,17 @@
 #include <infiniband/driver.h>
 #include <infiniband/marshall.h>
 
+#ifdef INCLUDE_VALGRIND
+#   include <valgrind/memcheck.h>
+#   ifndef VALGRIND_MAKE_MEM_DEFINED
+#       warning "Valgrind requested, but VALGRIND_MAKE_MEM_DEFINED undefined"
+#   endif
+#endif
+
+#ifndef VALGRIND_MAKE_MEM_DEFINED
+#   define VALGRIND_MAKE_MEM_DEFINED(addr,len)
+#endif
+
 #define PFX "libibcm: "
 
 static int abi_ver;
@@ -226,6 +237,8 @@ int ib_cm_create_id(struct ib_cm_device *device,
        if (result != size)
                goto err;
 
+       VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
        cm_id_priv->id.handle = resp->id;
        *cm_id = &cm_id_priv->id;
        return 0;
@@ -250,6 +263,8 @@ int ib_cm_destroy_id(struct ib_cm_id *cm_id)
        if (result != size)
                return (result > 0) ? -ENODATA : result;
 
+       VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
        cm_id_priv = container_of(cm_id, struct cm_id_private, id);
 
        pthread_mutex_lock(&cm_id_priv->mut);
@@ -279,6 +294,8 @@ int ib_cm_attr_id(struct ib_cm_id *cm_id, struct 
ib_cm_attr_param *param)
        if (result != size)
                return (result > 0) ? -ENODATA : result;
 
+       VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
        param->service_id   = resp->service_id;
        param->service_mask = resp->service_mask;
        param->local_id     = resp->local_id;
@@ -307,6 +324,8 @@ int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
        if (result != size)
                return (result > 0) ? -ENODATA : result;
 
+       VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
        *qp_attr_mask = resp->qp_attr_mask;
        ibv_copy_qp_attr_from_kern(qp_attr, resp);
 
@@ -818,6 +837,9 @@ int ib_cm_get_event(struct ib_cm_device *device, struct 
ib_cm_event **event)
                result = (result > 0) ? -ENODATA : result;
                goto done;
        }
+
+       VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
        /*
         * decode event.
         */

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to