[openib-general] segmentation fault in ibv_modify_srq

Sayantan Sur surs at cse.ohio-state.edu
Thu Oct 6 11:46:54 PDT 2005


Roland,

* On Oct,11 Sayantan Sur<surs at cse.ohio-state.edu> wrote :
> I will test out the limit event generation next.

I made some simple modifications to srq_pingpong.c to see if I am able
to generate the IBV_EVENT_SRQ_LIMIT_REACHED event. I have attached my
changes as a patch and the full file (for easy execution).

I noticed that the test re-posts buffers only when the outstanding recv
count is <= 1. I set a SRQ limit as max_recv - 5. So, I should get the
event when 5 WQEs are consumed from the SRQ, right?

As of now, I am not able to see the event happening. I'd be glad if you
could see if this issue can be resolved.

Thanks for your prompt help.

Sayantan.

-- 
http://www.cse.ohio-state.edu/~surs
-------------- next part --------------
Index: srq_pingpong.c
===================================================================
--- srq_pingpong.c	(revision 3676)
+++ srq_pingpong.c	(working copy)
@@ -36,6 +36,8 @@
 #  include <config.h>
 #endif /* HAVE_CONFIG_H */
 
+#define _GNU_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -62,6 +64,8 @@
 
 static int page_size;
 
+static pthread_t limit_thread;
+
 struct pingpong_context {
 	struct ibv_context	*context;
 	struct ibv_comp_channel *channel;
@@ -82,6 +86,25 @@
 	int psn;
 };
 
+
+static void asyncwatch(struct ibv_context *context)
+{
+	struct ibv_async_event event;
+
+	while (1) {
+
+		if (ibv_get_async_event(context, &event)) {
+            fprintf(stderr,"Error getting event!\n");
+        }
+
+		fprintf(stderr, "  event_type %d, port %d\n", event.event_type,
+		       event.element.port_num);
+        fflush(stderr);
+
+		ibv_ack_async_event(&event);
+	}
+}
+
 static uint16_t pp_get_local_lid(struct pingpong_context *ctx, int port)
 {
 	struct ibv_port_attr attr;
@@ -382,7 +405,11 @@
 		return NULL;
 	}
 
+    pthread_create(&limit_thread, NULL, (void *) asyncwatch, (void *)ctx->context);
+
 	{
+        struct ibv_srq_attr srq_attr;
+
 		struct ibv_srq_init_attr attr = {
 			.attr = {
 				.max_wr  = rx_depth,
@@ -395,6 +422,15 @@
 			fprintf(stderr, "Couldn't create SRQ\n");
 			return NULL;
 		}
+
+        srq_attr.max_wr = rx_depth;
+        srq_attr.max_sge = 1;
+        srq_attr.srq_limit = rx_depth-5;
+
+        if(ibv_modify_srq(ctx->srq, &srq_attr, IBV_SRQ_LIMIT)) {
+            fprintf(stderr,"Error modifying SRQ\n");
+            exit(-1);
+        }
 	}
 
 	for (i = 0; i < num_qp; ++i) {
@@ -434,6 +470,7 @@
 		}
 	}
 
+
 	return ctx;
 }
 
@@ -742,6 +779,8 @@
 						}
 					}
 
+                    fprintf(stderr,"routs %d\n", routs);
+
 					if (scnt < iters) {
 						j = find_qp(wc[i].qp_num, ctx, num_qp);
 						if (j < 0) {
@@ -784,5 +823,7 @@
 		       iters, usec / 1000000., usec / iters);
 	}
 
+    sleep(3);
+
 	return 0;
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: srq_pingpong.c
Type: text/x-csrc
Size: 19155 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20051006/4fea1505/attachment.c>


More information about the general mailing list