Skip to content

Commit d0f2faf

Browse files
Mike Marciniszynrolandd
authored andcommitted
IB/qib: Precompute timeout jiffies to optimize latency
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 <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent af061a6 commit d0f2faf

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

drivers/infiniband/hw/qib/qib_qp.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,12 @@ int qib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
801801
if (attr_mask & IB_QP_MIN_RNR_TIMER)
802802
qp->r_min_rnr_timer = attr->min_rnr_timer;
803803

804-
if (attr_mask & IB_QP_TIMEOUT)
804+
if (attr_mask & IB_QP_TIMEOUT) {
805805
qp->timeout = attr->timeout;
806+
qp->timeout_jiffies =
807+
usecs_to_jiffies((4096UL * (1UL << qp->timeout)) /
808+
1000UL);
809+
}
806810

807811
if (attr_mask & IB_QP_QKEY)
808812
qp->qkey = attr->qkey;
@@ -1034,6 +1038,9 @@ struct ib_qp *qib_create_qp(struct ib_pd *ibpd,
10341038
goto bail_swq;
10351039
}
10361040
RCU_INIT_POINTER(qp->next, NULL);
1041+
qp->timeout_jiffies =
1042+
usecs_to_jiffies((4096UL * (1UL << qp->timeout)) /
1043+
1000UL);
10371044
if (init_attr->srq)
10381045
sz = 0;
10391046
else {

drivers/infiniband/hw/qib/qib_rc.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ static void start_timer(struct qib_qp *qp)
5959
qp->s_flags |= QIB_S_TIMER;
6060
qp->s_timer.function = rc_timeout;
6161
/* 4.096 usec. * (1 << qp->timeout) */
62-
qp->s_timer.expires = jiffies +
63-
usecs_to_jiffies((4096UL * (1UL << qp->timeout)) / 1000UL);
62+
qp->s_timer.expires = jiffies + qp->timeout_jiffies;
6463
add_timer(&qp->s_timer);
6564
}
6665

@@ -1519,9 +1518,7 @@ static void qib_rc_rcv_resp(struct qib_ibport *ibp,
15191518
* 4.096 usec. * (1 << qp->timeout)
15201519
*/
15211520
qp->s_flags |= QIB_S_TIMER;
1522-
mod_timer(&qp->s_timer, jiffies +
1523-
usecs_to_jiffies((4096UL * (1UL << qp->timeout)) /
1524-
1000UL));
1521+
mod_timer(&qp->s_timer, jiffies + qp->timeout_jiffies);
15251522
if (qp->s_flags & QIB_S_WAIT_ACK) {
15261523
qp->s_flags &= ~QIB_S_WAIT_ACK;
15271524
qib_schedule_send(qp);

drivers/infiniband/hw/qib/qib_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ struct qib_qp {
496496
u32 s_last; /* last completed entry */
497497
u32 s_ssn; /* SSN of tail entry */
498498
u32 s_lsn; /* limit sequence number (credit) */
499+
unsigned long timeout_jiffies; /* computed from timeout */
499500
struct qib_swqe *s_wq; /* send work queue */
500501
struct qib_swqe *s_wqe;
501502
struct qib_rq r_rq; /* receive work queue */

0 commit comments

Comments
 (0)