perhaps this should use the unlikely() macro instead:

        if (unlikely(wc.status)) {
                ...
        }

        ...

On Thu, 1 Dec 2011 20:02:17 +0100
Bart Van Assche <[email protected]> wrote:

> 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 <[email protected]>
> Cc: David Dillow <[email protected]>
> Cc: Roland Dreier <[email protected]>
> ---
>  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);
>       }
>  }
>  

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

Reply via email to