Rev 57: Added overload test scenario + fixed 1 send queue bug. in http://samba.org/~tridge/psomogyi/

psomogyi at gamax.hu psomogyi at gamax.hu
Tue Jan 30 17:47:27 GMT 2007


------------------------------------------------------------
revno: 57
revision-id: psomogyi at gamax.hu-20070130174726-v2l2oxyv3j9ozs9t
parent: psomogyi at gamax.hu-20070126154551-wtp1ufo5kfytcq74
committer: Peter Somogyi <psomogyi at gamax.hu>
branch nick: ctdb
timestamp: Tue 2007-01-30 18:47:26 +0100
message:
  Added overload test scenario + fixed 1 send queue bug.
  TODO: externize debug level
modified:
  ib/ibwrapper.c                 ibwrapper.c-20061204130028-0125b4f5a72f4b11
  include/includes.h             includes.h-20061117234101-o3qt14umlg9en8z0-17
  tests/ibwrapper_test.c         ibwrapper_test.c-20061214171730-h11a2z5ed6pt66hj-1
=== modified file 'ib/ibwrapper.c'
--- a/ib/ibwrapper.c	2007-01-25 10:01:59 +0000
+++ b/ib/ibwrapper.c	2007-01-30 17:47:26 +0000
@@ -455,7 +455,7 @@
 
 	case RDMA_CM_EVENT_ESTABLISHED:
 		/* expected after ibw_accept and ibw_connect[not directly] */
-		DEBUG(0, ("ESTABLISHED (conn: %u)\n", (unsigned int)cma_id->context));
+		DEBUG(0, ("ESTABLISHED (conn: %p)\n", cma_id->context));
 		conn = talloc_get_type(cma_id->context, struct ibw_conn);
 		assert(conn!=NULL); /* important assumption */
 
@@ -623,7 +623,7 @@
 	} else { /* "extra" request - not optimized */
 		DEBUG(10, ("ibw_wc_send#2 %u\n", (int)wc->wr_id));
 		for(p=pconn->extra_sent; p!=NULL; p=p->next)
-			if (p->wr_id==(int)wc->wr_id)
+			if ((p->wr_id + pctx->opts.max_recv_wr)==(int)wc->wr_id)
 				break;
 		if (p==NULL) {
 			sprintf(ibw_lasterr, "failed to find wr_id %d\n", (int)wc->wr_id);
@@ -1042,6 +1042,7 @@
 			}
 			*buf = (void *)p->msg_large;
 		}
+		/* p->wr_id is already filled in ibw_init_memory */
 	} else {
 		DEBUG(10, ("ibw_alloc_send_buf#2: cmid=%p, len=%d\n", pconn->cm_id, len));
 		/* not optimized */

=== modified file 'include/includes.h'
--- a/include/includes.h	2007-01-26 15:45:51 +0000
+++ b/include/includes.h	2007-01-30 17:47:26 +0000
@@ -12,7 +12,7 @@
 #define True 1
 #define False 0
 
-#define LogLevel 10
+#define LogLevel 0
 
 #define DEBUG(lvl, x) if ((lvl) <= LogLevel) (printf x)
 

=== modified file 'tests/ibwrapper_test.c'
--- a/tests/ibwrapper_test.c	2007-01-26 15:45:51 +0000
+++ b/tests/ibwrapper_test.c	2007-01-30 17:47:26 +0000
@@ -51,13 +51,15 @@
 	struct sockaddr_in *addrs; /* dynamic array of dest addrs */
 	int	naddrs;
 
-	unsigned int	nsec; /* nanosleep between messages */
+	unsigned int	nsec; /* delta times between messages in nanosec */
+	unsigned int	sleep_nsec; /* nanosleep in the main loop to emulate overloading */
 
 	int	cnt;
 
 	int	nmsg; /* number of messages to send (client) */
 
 	int	kill_me;
+	int	error;
 	struct ibw_ctx	*ibwctx;
 
 	struct timeval	start_time, end_time;
@@ -72,6 +74,26 @@
 	TESTOP_SEND_DATA = 2
 };
 
+int ibwtest_nanosleep(unsigned int sleep_nsec)
+{
+	int nanosleep(const struct timespec *req, struct timespec *rem);
+	struct timespec req, rem;
+
+	memset(&req, 0, sizeof(struct timespec));
+	memset(&rem, 0, sizeof(struct timespec));
+	req.tv_sec = 0;
+	req.tv_nsec = sleep_nsec;
+
+	while (nanosleep(&req, &rem) < 0) {
+		if (errno != EINTR) {
+			DEBUG(0, ("nanosleep ERROR: %d\n", errno));
+			return -1;
+		}
+		memcpy(&req, &rem, sizeof(struct timespec));
+	}
+	return 0;
+}
+
 int ibwtest_connect_everybody(struct ibwtest_ctx *tcx)
 {
 	struct ibwtest_conn	*pconn = talloc_zero(tcx, struct ibwtest_conn);
@@ -90,9 +112,9 @@
 
 int ibwtest_send_id(struct ibw_conn *conn)
 {
+	struct ibwtest_ctx *tcx = talloc_get_type(conn->ctx->ctx_userdata, struct ibwtest_ctx);
 	char *buf;
 	void *key;
-	struct ibwtest_ctx *tcx = talloc_get_type(conn->ctx->ctx_userdata, struct ibwtest_ctx);
 	uint32_t	len;
 
 	DEBUG(10, ("test IBWC_CONNECTED\n"));
@@ -240,7 +262,7 @@
 		if (tcx->nmsg) {
 			char	msg[26];
 			sprintf(msg, "hello world %d", tcx->nmsg--);
-			ibwtest_send_test_msg(tcx, conn, msg);
+			tcx->error = ibwtest_send_test_msg(tcx, conn, msg);
 			if (tcx->nmsg==0)
 				tcx->kill_me = 1;
 		}
@@ -263,7 +285,9 @@
 
 		/* send something to everybody... */
 		for(p=tcx->ibwctx->conn_list; p!=NULL; p=p->next) {
-			ibwtest_send_test_msg(tcx, p, msg);
+			if (p->state==IBWC_CONNECTED) {
+				tcx->error = ibwtest_send_test_msg(tcx, p, msg);
+			}
 		}
 	} /* else allow main loop run */
 }
@@ -375,6 +399,7 @@
 	printf("\t\t send message periodically and endless when nsec is non-zero\n");
 	printf("\t-s server mode (you have to give exactly one -d address:port in this case)\n");
 	printf("\t-n number of messages to send [default %d]\n", tcx->nmsg);
+	printf("\t-l nsec time to sleep in the main loop [default %d]\n", tcx->sleep_nsec);
 	printf("Press ctrl+C to stop the program.\n");
 }
 
@@ -395,7 +420,7 @@
 	testctx = tcx;
 	signal(SIGQUIT, ibwtest_sigquit_handler);
 
-	while ((op=getopt(argc, argv, "i:o:d:m:st:n:")) != -1) {
+	while ((op=getopt(argc, argv, "i:o:d:m:st:n:l:")) != -1) {
 		switch (op) {
 		case 'i':
 			tcx->id = talloc_strdup(tcx, optarg);
@@ -419,6 +444,9 @@
 		case 'n':
 			tcx->nmsg = atoi(optarg);
 			break;
+		case 'l':
+			tcx->sleep_nsec = (unsigned int)atoi(optarg);
+			break;
 		default:
 			fprintf(stderr, "ERROR: unknown option -%c\n", (char)op);
 			ibwtest_usage(tcx, argv[0]);
@@ -450,16 +478,23 @@
 	if (rc)
 		goto cleanup;
 
-	while(!tcx->kill_me) {
-		if (tcx->nsec)
+	while(!tcx->kill_me && !tcx->error) {
+		if (tcx->nsec) {
 			event_add_timed(ev, tcx, timeval_current_ofs(0, tcx->nsec),
 				ibwtest_timeout_handler, tcx);
+		}
+
 		event_loop_once(ev);
+
+		if (tcx->sleep_nsec) {
+			if (ibwtest_nanosleep(tcx->sleep_nsec))
+				goto cleanup;
+		}
 	}
 
-	if (!tcx->is_server && nmsg!=0) {
+	if (!tcx->is_server && nmsg!=0 && !tcx->error) {
 		if (gettimeofday(&tcx->end_time, NULL)) {
-			DEBUG(0, ("gettimeofday error %d", errno));
+			DEBUG(0, ("gettimeofday error %d\n", errno));
 			goto cleanup;
 		}
 		usec = (tcx->end_time.tv_sec - tcx->start_time.tv_sec) * 1000000 +
@@ -468,7 +503,8 @@
 			usec, nmsg, usec/(float)nmsg);
 	}
 
-	result = 0; /* everything OK */
+	if (!tcx->error)
+		result = 0; /* everything OK */
 
 cleanup:
 	if (tcx)



More information about the samba-cvs mailing list