Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] IB/sa_query: avoid unnecessary list scan

Using ib_get_client_data in SA event handler performs a list scan.
It's better to use container_of to get the sa device directly.

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by

Michael S. Tsirkin and committed by
Roland Dreier
1d6801f9 06c56e44

+2 -2
+2 -2
drivers/infiniband/core/sa_query.c
··· 431 431 event->event == IB_EVENT_LID_CHANGE || 432 432 event->event == IB_EVENT_PKEY_CHANGE || 433 433 event->event == IB_EVENT_SM_CHANGE) { 434 - struct ib_sa_device *sa_dev = 435 - ib_get_client_data(event->device, &sa_client); 434 + struct ib_sa_device *sa_dev; 435 + sa_dev = container_of(handler, typeof(*sa_dev), event_handler); 436 436 437 437 schedule_work(&sa_dev->port[event->element.port_num - 438 438 sa_dev->start_port].update_task);