[openib-general] [PATCH] sa_query: avoid unnecessary list scan

Michael S. Tsirkin mst at mellanox.co.il
Thu Sep 1 00:25:30 PDT 2005


Here's a small cleanup patch for sa query.

---

Using ib_get_client_data on sa event performs a list scan.
Its better to use container_of to get the sa device directly.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: linux-2.6.12.2/drivers/infiniband/core/sa_query.c
===================================================================
--- linux-2.6.12.2.orig/drivers/infiniband/core/sa_query.c	2005-09-01 12:01:29.000000000 +0300
+++ linux-2.6.12.2/drivers/infiniband/core/sa_query.c	2005-09-01 12:15:57.000000000 +0300
@@ -431,8 +431,8 @@ static void ib_sa_event(struct ib_event_
 	    event->event == IB_EVENT_LID_CHANGE  ||
 	    event->event == IB_EVENT_PKEY_CHANGE ||
 	    event->event == IB_EVENT_SM_CHANGE) {
-		struct ib_sa_device *sa_dev =
-			ib_get_client_data(event->device, &sa_client);
+		struct ib_sa_device *sa_dev;
+		sa_dev = container_of(handler, typeof(*sa_dev), event_handler);
 
 		schedule_work(&sa_dev->port[event->element.port_num -
 					    sa_dev->start_port].update_task);

-- 
MST



More information about the general mailing list