[openib-general] [patch] misc trivia nitpicks 03

Bernhard Fischer blist at aon.at
Thu May 5 12:26:14 PDT 2005


Hi,

What's the status of SDP_EXPECT ?
will it be submitted upstream or cleaned up beforehand? Just curious.


- s/conenct/connect/g
- s/conect/connect/g
- trim whitespace

- fold sdp_conn_internal_lock into sdp_conn_lock.
- fold sdp_conn_internal_unlock into sdp_conn_unlock.


PS: those folds are completely untested.. Libor, anyone else?
thank you,
-------------- next part --------------
diff -X excl -rduNp gen2.2257.oorig/trunk/src/userspace/management/doc/diagtools.txt gen2.2257/trunk/src/userspace/management/doc/diagtools.txt
--- gen2.2257.oorig/trunk/src/userspace/management/doc/diagtools.txt	2005-04-26 20:58:41.000000000 +0200
+++ gen2.2257/trunk/src/userspace/management/doc/diagtools.txt	2005-05-05 20:33:53.572745456 +0200
@@ -335,7 +335,7 @@ smpquery, smpquery output format, ibaddr
 16. ibnetchecknode
 
 Description:
-Check conectivity and do some simple sanity checks for the specified node.
+Check connectivity and do some simple sanity checks for the specified node.
 Port address is lid unless -G option is used to specify a GUID address. 
 
 Syntax:
-------------- next part --------------
diff -X excl -rduNp gen2.2257.oorig/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c gen2.2257/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c
--- gen2.2257.oorig/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c	2005-04-26 20:58:46.000000000 +0200
+++ gen2.2257/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c	2005-05-05 20:32:42.415562992 +0200
@@ -595,8 +595,8 @@ done:
 	return conn;
 }
 
-/* 
- * Functions to cancel IOCB requests in a conenctions queues.
+/*
+ * Functions to cancel IOCB requests in a connections queues.
  */
 static int sdp_desc_q_cancel_lookup_func(struct sdpc_desc *element, void *arg)
 {
-------------- next part --------------
diff -X excl -rduNp gen2.2257.oorig/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c gen2.2257/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c
--- gen2.2257.oorig/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c	2005-04-26 20:58:46.000000000 +0200
+++ gen2.2257/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c	2005-05-05 21:24:27.895458288 +0200
@@ -352,13 +352,13 @@ int sdp_inet_port_get(struct sdp_opt *co
 					    INADDR_ANY == look->src_addr ||
 					    conn->src_addr == look->src_addr) {
 
-						sdp_dbg_warn(conn, 
+						sdp_dbg_warn(conn,
 							     "port rejected. <%04x><%d:%d><%d:%d><%04x><%u:%u>",
 							 port,
 							 sk->sk_bound_dev_if,
 							 srch->sk_bound_dev_if,
 							 sk->sk_reuse,
-							 srch->sk_reuse, 
+							 srch->sk_reuse,
 							 look->state,
 							 conn->src_addr,
 							 look->src_addr);
@@ -670,6 +670,7 @@ void sdp_conn_destruct(struct sdp_opt *c
 
 	result = sdp_conn_stat_dump(conn);
 	SDP_EXPECT(result >= 0);
+
 	/*
 	 * really there shouldn't be anything in these tables, but it's
 	 * really bad if we leave a dangling reference here.
@@ -748,7 +749,7 @@ void sdp_conn_destruct(struct sdp_opt *c
 				     result);
 	}
 	/*
-	 * check consistancy
+	 * check consistency
 	 */
 	if (atomic_read(&conn->refcnt) < 0)
 		sdp_dbg_warn(conn, "destruct low ref count <%04x>",
@@ -812,7 +789,7 @@ void sdp_conn_relock(struct sdp_opt *con
 		if (1 == result_r) {
 			result = sdp_cq_event_locked(&entry, conn);
 			if (result < 0)
-				sdp_dbg_warn(conn, 
+				sdp_dbg_warn(conn,
 					     "Error <%d> from event handler.",
 					     result);
 
@@ -823,7 +800,7 @@ void sdp_conn_relock(struct sdp_opt *con
 		if (1 == result_s) {
 			result = sdp_cq_event_locked(&entry, conn);
 			if (result < 0)
-				sdp_dbg_warn(conn, 
+				sdp_dbg_warn(conn,
 					     "Error <%d> from event handler.",
 					     result);
 			rearm = 1;
@@ -836,17 +813,17 @@ void sdp_conn_relock(struct sdp_opt *con
 			result = ib_req_notify_cq(conn->recv_cq,
 						  IB_CQ_NEXT_COMP);
 			if (result)
-				sdp_dbg_warn(conn, 
+				sdp_dbg_warn(conn,
 					     "Error <%d> rearming recv CQ",
 					     result);
 
 			result = ib_req_notify_cq(conn->send_cq,
 						  IB_CQ_NEXT_COMP);
 			if (result)
-				sdp_dbg_warn(conn, 
+				sdp_dbg_warn(conn,
 					     "Error <%d> rearming send CQ",
 					     result);
-			
+
 			rearm = 0;
 		} else
 			break;  /* exit CQ handler routine */
@@ -858,18 +835,20 @@ void sdp_conn_relock(struct sdp_opt *con
 }
 
 /*
- * sdp_conn_cq_drain - drain one of the the connection's CQs
+ * sdp_conn_cq_drain - drain one of the connection's CQs
  */
+/*
+ * the function should only be called under the connection locks
+ * spinlock to ensure the call is serialized to avoid races.
+ */
+
 int sdp_conn_cq_drain(struct ib_cq *cq, struct sdp_opt *conn)
 {
 	struct ib_wc entry;
 	int result;
 	int rearm = 1;
 	int calls = 0;
-	/*
-	 * the function should only be called under the connection locks
-	 * spinlock to ensure the call is serialized to avoid races.
-	 */
+
 	for (;;) {
 		/*
 		 * poll for a completion
@@ -877,7 +856,7 @@ int sdp_conn_cq_drain(struct ib_cq *cq, 
 		result = ib_poll_cq(cq, 1, &entry);
 		if (1 == result) {
 			/*
-			 * dispatch completion, and mark that the CQ needs 
+			 * dispatch completion, and mark that the CQ needs
 			 * to be armed.
 			 */
 			result = sdp_cq_event_locked(&entry, conn);
@@ -895,7 +874,7 @@ int sdp_conn_cq_drain(struct ib_cq *cq, 
 			if (rearm > 0) {
 				result = ib_req_notify_cq(cq, IB_CQ_NEXT_COMP);
 				if (result)
-					sdp_dbg_warn(conn, 
+					sdp_dbg_warn(conn,
 						     "Error <%d> rearming CQ",
 						     result);
 				rearm = 0;
@@ -973,13 +931,13 @@ int sdp_conn_alloc_ib(struct sdp_opt *co
 		result = -ENOMEM;
 		goto error_attr;
 	}
-  
+
 	init_attr = kmalloc(sizeof(*init_attr), GFP_KERNEL);
 	if (!init_attr) {
 		result = -ENOMEM;
 		goto error_param;
 	}
-	
+
 	memset(qp_attr,   0, sizeof(*qp_attr));
 	memset(init_attr, 0, sizeof(*init_attr));
 	/*
@@ -1121,7 +1079,7 @@ struct sdp_opt *sdp_conn_alloc(int prior
 	struct sock *sk;
 	int result;
 
-	sk = sk_alloc(dev_root_s.proto, priority, 
+	sk = sk_alloc(dev_root_s.proto, priority,
 		      sizeof(struct inet_sock), dev_root_s.sock_cache);
 	if (!sk) {
 		sdp_dbg_warn(NULL, "socket alloc error for protocol. <%d:%d>",
@@ -1316,12 +1274,12 @@ error:
         "dst address:port src address:port  ID  comm_id  pid  " \
         "    dst guid         src guid     dlid slid dqpn   "   \
 	"sqpn   data sent buff'd data rcvd_buff'd "             \
-	"  data written      data read     src_serv snk_serv\n" 
+	"  data written      data read     src_serv snk_serv\n"
 #define SDP_PROC_CONN_MAIN_SEP  \
 	"---------------- ---------------- ---- -------- ---- " \
 	"---------------- ---------------- ---- ---- ------ "   \
 	"------ ---------------- ---------------- "             \
-	"---------------- ---------------- -------- --------\n" 
+	"---------------- ---------------- -------- --------\n"
 #define SDP_PROC_CONN_MAIN_FORM \
 	"%02x.%02x.%02x.%02x:%04x %02x.%02x.%02x.%02x:%04x "  \
 	"%04x %08x %04x %08x%08x %08x%08x %04x %04x "         \
@@ -1330,7 +1288,7 @@ error:
 /*
  * sdp_proc_dump_conn_main - dump the connection table to /proc
  */
-int sdp_proc_dump_conn_main(char *buffer, int max_size, off_t start_index, 
+int sdp_proc_dump_conn_main(char *buffer, int max_size, off_t start_index,
 			    long *end_index)
 {
 	struct sdp_opt *conn;
@@ -1360,7 +1318,7 @@ int sdp_proc_dump_conn_main(char *buffer
 	/*
 	 * loop across connections.
 	 */
-	for (counter = start_index; 
+	for (counter = start_index;
 	     counter < dev_root_s.sk_size &&
 		     !(SDP_CONN_PROC_MAIN_SIZE > (max_size - offset));
 	     counter++) {
@@ -1382,7 +1340,7 @@ int sdp_proc_dump_conn_main(char *buffer
 				  ((conn->src_addr >> 8) & 0xff),
 				  ((conn->src_addr >> 16) & 0xff),
 				  ((conn->src_addr >> 24) & 0xff),
-				  conn->src_port, 
+				  conn->src_port,
 				  conn->hashent,
 				  conn->cm_id ? conn->cm_id->local_id : 0,
 				  conn->pid,
@@ -1801,8 +1759,8 @@ static void sdp_device_init_one(struct i
 		port->next     = hca->port_list;
 		hca->port_list = port;
 
-		result = ib_query_gid(hca->ca, 
-				      port->index, 
+		result = ib_query_gid(hca->ca,
+				      port->index,
 				      0,	/* index */
 				      &port->gid);
 		if (result) {
@@ -1852,7 +1810,7 @@ static void sdp_device_remove_one(struct
 		sdp_warn("Device <%s> has no HCA info.", device->name);
 		return;
 	}
-	
+
 	while (hca->port_list) {
 		port = hca->port_list;
 		hca->port_list = port->next;
@@ -1909,7 +1867,7 @@ int sdp_conn_table_init(int proto_family
 	dev_root_s.recv_buff_max = recv_buff_max;
 	dev_root_s.send_post_max = send_post_max;
 	dev_root_s.send_buff_max = send_buff_max;
-	
+
 	dev_root_s.send_usig_max = send_usig_max;
 	/*
 	 * Get HCA/port list
@@ -1967,7 +1925,7 @@ int sdp_conn_table_init(int proto_family
 	}
 
         dev_root_s.sock_cache = kmem_cache_create("sdp_sock",
-						  sizeof(struct inet_sock), 
+						  sizeof(struct inet_sock),
 						  0, SLAB_HWCACHE_ALIGN,
 						  NULL, NULL);
         if (!dev_root_s.sock_cache) {

-------------- next part --------------
diff -X excl -rduNp gen2.2257.oorig/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c gen2.2257/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c
--- gen2.2257.oorig/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c	2005-04-26 20:58:46.000000000 +0200
+++ gen2.2257/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c	2005-05-05 21:24:27.895458288 +0200
@@ -770,30 +771,6 @@ void sdp_conn_destruct(struct sdp_opt *c
 }
 
 /*
- * sdp_conn_internal_lock - lock the connection (use only from macro)
- */
-void sdp_conn_internal_lock(struct sdp_opt *conn, unsigned long *flags)
-{
-	DECLARE_WAITQUEUE(wait, current);
-	unsigned long f = *flags;
-
-	add_wait_queue_exclusive(&(conn->lock.waitq), &wait);
-	for (;;) {
-		current->state = TASK_UNINTERRUPTIBLE;
-		spin_unlock_irqrestore(&(conn->lock.slock), f);
-		schedule();
-		spin_lock_irqsave(&(conn->lock.slock), f);
-		*flags = f;
-
-		if (!conn->lock.users)
-			break;
-	}
-
-	current->state = TASK_RUNNING;
-	remove_wait_queue(&(conn->lock.waitq), &wait);
-}
-
-/*
  * sdp_conn_relock - test the connection (use only from macro)
  */
 void sdp_conn_relock(struct sdp_opt *conn)
@@ -905,28 +884,7 @@ int sdp_conn_cq_drain(struct ib_cq *cq, 
 			sdp_dbg_warn(conn, "Unexpected error <%d> from CQ",
 				     result);
 	}
-
-return calls;
-}
-
-/*
- * sdp_conn_internal_unlock - lock the connection (use only from macro)
- */
-void sdp_conn_internal_unlock(struct sdp_opt *conn)
-{
-	int calls = 0;
-	/*
-	 * poll CQs for events.
-	 */
-	if (conn) {
-		if (conn->flags & SDP_CONN_F_RECV_CQ_PEND)
-			calls += sdp_conn_cq_drain(conn->recv_cq, conn);
-
-		if (conn->flags & SDP_CONN_F_SEND_CQ_PEND)
-			calls += sdp_conn_cq_drain(conn->send_cq, conn);
-
-		conn->flags &= ~SDP_CONN_F_MASK_EVENT;
-	}
+	return /* finished # of */calls;
 }
 
 /*
diff -X excl -rduNp gen2.2257.oorig/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.h gen2.2257/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.h
--- gen2.2257.oorig/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.h	2005-04-26 20:58:46.000000000 +0200
+++ gen2.2257/trunk/src/linux-kernel/infiniband/ulp/sdp/sdp_conn.h	2005-05-05 21:21:53.964859296 +0200
@@ -462,8 +462,6 @@ struct sdp_opt {
 /*
  * SDP connection lock
  */
-extern void sdp_conn_internal_lock(struct sdp_opt *conn, unsigned long *flags);
-extern void sdp_conn_internal_unlock(struct sdp_opt *conn);
 extern void sdp_conn_relock(struct sdp_opt *conn);
 extern void sdp_conn_destruct(struct sdp_opt *conn);
 extern int sdp_conn_cq_drain(struct ib_cq *cq, struct sdp_opt *conn);
@@ -482,7 +480,18 @@ static inline void sdp_conn_lock(struct 
 	spin_lock_irqsave(&conn->lock.slock, flags);
 	if (conn->lock.users != 0) {
 
-		sdp_conn_internal_lock(conn, &flags);
+		DECLARE_WAITQUEUE(wait, current);
+		add_wait_queue_exclusive(&(conn->lock.waitq), &wait);
+		for (;;) {
+			current->state = TASK_UNINTERRUPTIBLE;
+			spin_unlock_irqrestore(&(conn->lock.slock), flags);
+			schedule();
+			spin_lock_irqsave(&(conn->lock.slock), flags);
+																	                if (!conn->lock.users)
+				break;
+		}
+		current->state = TASK_RUNNING;
+		remove_wait_queue(&(conn->lock.waitq), &wait);
 	}
 
 	conn->lock.users = 1;
@@ -497,7 +506,16 @@ static inline void sdp_conn_unlock(struc
 	if ((conn->flags & SDP_CONN_F_MASK_EVENT) &&
 	    (SDP_ST_MASK_EVENTS & conn->state)) {
 
-		sdp_conn_internal_unlock(conn);
+		/*
+		 * poll CQs for events.
+		 */
+		if (conn->flags & SDP_CONN_F_RECV_CQ_PEND)
+			sdp_conn_cq_drain(conn->recv_cq, conn);
+
+		if (conn->flags & SDP_CONN_F_SEND_CQ_PEND)
+			sdp_conn_cq_drain(conn->send_cq, conn);
+
+		conn->flags &= ~SDP_CONN_F_MASK_EVENT;
 	}
 
 	conn->lock.users = 0;

-------------- next part --------------
diff -X excl -rduNp gen2.2257.oorig/trunk/src/userspace/management/doc/diagtools.txt gen2.2257/trunk/src/userspace/management/doc/diagtools.txt
--- gen2.2257.oorig/trunk/src/userspace/management/doc/diagtools.txt	2005-04-26 20:58:41.000000000 +0200
+++ gen2.2257/trunk/src/userspace/management/doc/diagtools.txt	2005-05-05 20:33:53.572745456 +0200
@@ -335,7 +335,7 @@ smpquery, smpquery output format, ibaddr
 16. ibnetchecknode
 
 Description:
-Check conectivity and do some simple sanity checks for the specified node.
+Check connectivity and do some simple sanity checks for the specified node.
 Port address is lid unless -G option is used to specify a GUID address. 
 
 Syntax:


More information about the general mailing list