Help the CPU branch predictor by rearranging two if-statements such
that the most likely code is in the if-part instead of the else-part.

Signed-off-by: Bart Van Assche <bvanass...@acm.org>
Cc: David Dillow <dillo...@ornl.gov>
Cc: Roland Dreier <rol...@purestorage.com>
---
 drivers/infiniband/ulp/srp/ib_srp.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c 
b/drivers/infiniband/ulp/srp/ib_srp.c
index a2624bf..e6d1aef 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1224,15 +1224,15 @@ static void srp_recv_completion(struct ib_cq *cq, void 
*target_ptr)
 
        ib_req_notify_cq(cq, IB_CQ_NEXT_COMP);
        while (ib_poll_cq(cq, 1, &wc) > 0) {
-               if (wc.status) {
+               if (wc.status == IB_WC_SUCCESS) {
+                       srp_handle_recv(target, &wc);
+               } else {
                        shost_printk(KERN_ERR, target->scsi_host,
                                     PFX "failed receive status %d\n",
                                     wc.status);
                        target->qp_in_error = 1;
                        break;
                }
-
-               srp_handle_recv(target, &wc);
        }
 }
 
@@ -1243,16 +1243,16 @@ static void srp_send_completion(struct ib_cq *cq, void 
*target_ptr)
        struct srp_iu *iu;
 
        while (ib_poll_cq(cq, 1, &wc) > 0) {
-               if (wc.status) {
+               if (wc.status == IB_WC_SUCCESS) {
+                       iu = (struct srp_iu *) (uintptr_t) wc.wr_id;
+                       list_add(&iu->list, &target->free_tx);
+               } else {
                        shost_printk(KERN_ERR, target->scsi_host,
                                     PFX "failed send status %d\n",
                                     wc.status);
                        target->qp_in_error = 1;
                        break;
                }
-
-               iu = (struct srp_iu *) (uintptr_t) wc.wr_id;
-               list_add(&iu->list, &target->free_tx);
        }
 }
 
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to