aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2015-07-09 10:21:08 -0400
committerDoug Ledford <dledford@redhat.com>2015-07-14 13:20:15 -0400
commitd9a047aeffcef5755952d18f2901d8777d84019d (patch)
tree2167b6bb6832d31bb7ba86ea4c4140ef4cd50bf6
parent9bbf282da87294e1bda0ccb4e351bfdf5fc076cd (diff)
IB/mlx4: Optimize do_slave_init
There is little chance our memory allocation will fail, so we can combine initializing the work structs with allocating them instead of looping through all of them once to allocate and again to initialize. Then when we need to actually find out if our device is up or in the process of going down, have all of our work structs batched up, take the spin_lock once and only once, and do all of the batch under the one spin_lock invocation instead of incurring all of the locked memory cycles we would otherwise incur to take/release the spin_lock over and over again. Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/infiniband/hw/mlx4/main.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 1c59e4749736..8be6db816460 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2681,20 +2681,22 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
2681 kfree(dm[i]); 2681 kfree(dm[i]);
2682 goto out; 2682 goto out;
2683 } 2683 }
2684 }
2685 /* initialize or tear down tunnel QPs for the slave */
2686 for (i = 0; i < ports; i++) {
2687 INIT_WORK(&dm[i]->work, mlx4_ib_tunnels_update_work); 2684 INIT_WORK(&dm[i]->work, mlx4_ib_tunnels_update_work);
2688 dm[i]->port = first_port + i + 1; 2685 dm[i]->port = first_port + i + 1;
2689 dm[i]->slave = slave; 2686 dm[i]->slave = slave;
2690 dm[i]->do_init = do_init; 2687 dm[i]->do_init = do_init;
2691 dm[i]->dev = ibdev; 2688 dm[i]->dev = ibdev;
2692 spin_lock_irqsave(&ibdev->sriov.going_down_lock, flags); 2689 }
2693 if (!ibdev->sriov.is_going_down) 2690 /* initialize or tear down tunnel QPs for the slave */
2691 spin_lock_irqsave(&ibdev->sriov.going_down_lock, flags);
2692 if (!ibdev->sriov.is_going_down) {
2693 for (i = 0; i < ports; i++)
2694 queue_work(ibdev->sriov.demux[i].ud_wq, &dm[i]->work); 2694 queue_work(ibdev->sriov.demux[i].ud_wq, &dm[i]->work);
2695 else
2696 kfree(dm[i]);
2697 spin_unlock_irqrestore(&ibdev->sriov.going_down_lock, flags); 2695 spin_unlock_irqrestore(&ibdev->sriov.going_down_lock, flags);
2696 } else {
2697 spin_unlock_irqrestore(&ibdev->sriov.going_down_lock, flags);
2698 for (i = 0; i < ports; i++)
2699 kfree(dm[i]);
2698 } 2700 }
2699out: 2701out:
2700 kfree(dm); 2702 kfree(dm);