IB/qib: Precompute timeout jiffies to optimize latency
authorMike Marciniszyn <mike.marciniszyn@qlogic.com>
Fri, 23 Sep 2011 17:16:49 +0000 (13:16 -0400)
committerRoland Dreier <roland@purestorage.com>
Fri, 21 Oct 2011 16:38:56 +0000 (09:38 -0700)
A new field is added to qib_qp called timeout_jiffies. It is
initialized upon create and modify.

The field is now used instead of a computation based on qp->timeout.

Signed-off-by: Mike Marciniszyn <mike.marciniszyn@qlogic.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/qib/qib_qp.c
drivers/infiniband/hw/qib/qib_rc.c
drivers/infiniband/hw/qib/qib_verbs.h

index 500981bce9c0bdc0a26a1bb670fe96478780cf0a..7e7e16fbee990848d0f206aec041b596cf6c77bf 100644 (file)
@@ -801,8 +801,12 @@ int qib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
        if (attr_mask & IB_QP_MIN_RNR_TIMER)
                qp->r_min_rnr_timer = attr->min_rnr_timer;
 
-       if (attr_mask & IB_QP_TIMEOUT)
+       if (attr_mask & IB_QP_TIMEOUT) {
                qp->timeout = attr->timeout;
+               qp->timeout_jiffies =
+                       usecs_to_jiffies((4096UL * (1UL << qp->timeout)) /
+                               1000UL);
+       }
 
        if (attr_mask & IB_QP_QKEY)
                qp->qkey = attr->qkey;
@@ -1034,6 +1038,9 @@ struct ib_qp *qib_create_qp(struct ib_pd *ibpd,
                        goto bail_swq;
                }
                RCU_INIT_POINTER(qp->next, NULL);
+               qp->timeout_jiffies =
+                       usecs_to_jiffies((4096UL * (1UL << qp->timeout)) /
+                               1000UL);
                if (init_attr->srq)
                        sz = 0;
                else {
index 5d77cb8aa052f8c40ce4c2b28c29b4e6024430f3..ecfa087ad45eeb161342c4c448db22373fee8aba 100644 (file)
@@ -59,8 +59,7 @@ static void start_timer(struct qib_qp *qp)
        qp->s_flags |= QIB_S_TIMER;
        qp->s_timer.function = rc_timeout;
        /* 4.096 usec. * (1 << qp->timeout) */
-       qp->s_timer.expires = jiffies +
-               usecs_to_jiffies((4096UL * (1UL << qp->timeout)) / 1000UL);
+       qp->s_timer.expires = jiffies + qp->timeout_jiffies;
        add_timer(&qp->s_timer);
 }
 
@@ -1519,9 +1518,7 @@ read_middle:
                 * 4.096 usec. * (1 << qp->timeout)
                 */
                qp->s_flags |= QIB_S_TIMER;
-               mod_timer(&qp->s_timer, jiffies +
-                       usecs_to_jiffies((4096UL * (1UL << qp->timeout)) /
-                                        1000UL));
+               mod_timer(&qp->s_timer, jiffies + qp->timeout_jiffies);
                if (qp->s_flags & QIB_S_WAIT_ACK) {
                        qp->s_flags &= ~QIB_S_WAIT_ACK;
                        qib_schedule_send(qp);
index d7b6109528a4cd3904b34208570c054723c97d25..0c19ef0c41233de4efaf25db3eb1886213a3407b 100644 (file)
@@ -496,6 +496,7 @@ struct qib_qp {
        u32 s_last;             /* last completed entry */
        u32 s_ssn;              /* SSN of tail entry */
        u32 s_lsn;              /* limit sequence number (credit) */
+       unsigned long timeout_jiffies;  /* computed from timeout */
        struct qib_swqe *s_wq;  /* send work queue */
        struct qib_swqe *s_wqe;
        struct qib_rq r_rq;             /* receive work queue */