[openib-general] [PATCH] [MAD] optimize cancel MAD

Sean Hefty sean.hefty at intel.com
Mon May 23 15:44:33 PDT 2005


This patch optimizes the cancel MAD path.  It eliminates searching
the timeout list when setting a MAD's timeout to zero, removes
duplicates checks to insert a work item to process the timeout,
and avoids resending the MAD as it is canceled.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>


Index: mad.c
===================================================================
--- mad.c	(revision 2413)
+++ mad.c	(working copy)
@@ -1794,14 +1794,18 @@ static void wait_for_response(struct ib_
 	delay = mad_send_wr->timeout;
 	mad_send_wr->timeout += jiffies;
 
-	list_for_each_prev(list_item, &mad_agent_priv->wait_list) {
-		temp_mad_send_wr = list_entry(list_item,
-					      struct ib_mad_send_wr_private,
-					      agent_list);
-		if (time_after(mad_send_wr->timeout,
-			       temp_mad_send_wr->timeout))
-			break;
+	if (delay) {
+		list_for_each_prev(list_item, &mad_agent_priv->wait_list) {
+			temp_mad_send_wr = list_entry(list_item,
+						struct ib_mad_send_wr_private,
+						agent_list);
+			if (time_after(mad_send_wr->timeout,
+				       temp_mad_send_wr->timeout))
+				break;
+		}
 	}
+	else
+		list_item = &mad_agent_priv->wait_list;
 	list_add(&mad_send_wr->agent_list, list_item);
 
 	/* Reschedule a work item if we have a shorter timeout */
@@ -1817,7 +1821,6 @@ void ib_reset_mad_timeout(struct ib_mad_
 {
 	mad_send_wr->timeout = msecs_to_jiffies(timeout_ms);
 	wait_for_response(mad_send_wr);
-	adjust_timeout(mad_send_wr->mad_agent_priv);
 }
 
 /*
@@ -2266,7 +2269,8 @@ static void timeout_sends(void *data)
 		}
 
 		list_del(&mad_send_wr->agent_list);
-		if (!retry_send(mad_send_wr))
+		if (mad_send_wr->status == IB_WC_SUCCESS &&
+		    !retry_send(mad_send_wr))
 			continue;
 
 		spin_unlock_irqrestore(&mad_agent_priv->lock, flags);






More information about the general mailing list