Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/rdmavt: Setting of QP timeout can overflow jiffies computation

Current computation of qp->timeout_jiffies in rvt_modify_qp() will cause
overflow due to the fact that the input to the function usecs_to_jiffies
is only 32-bit ( unsigned int). Overflow will occur when attr->timeout is
equal to or greater than 30. The consequence is unnecessarily excessive
retry and thus degradation of the system performance.

This patch fixes the problem by limiting the input to 5-bit and calling
usecs_to_jiffies() before multiplying the scaling factor.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by

Kaike Wan and committed by
Doug Ledford
a25ce427 266098b8

+15 -3
+1 -3
drivers/infiniband/sw/rdmavt/qp.c
··· 1258 1258 1259 1259 if (attr_mask & IB_QP_TIMEOUT) { 1260 1260 qp->timeout = attr->timeout; 1261 - qp->timeout_jiffies = 1262 - usecs_to_jiffies((4096UL * (1UL << qp->timeout)) / 1263 - 1000UL); 1261 + qp->timeout_jiffies = rvt_timeout_to_jiffies(qp->timeout); 1264 1262 } 1265 1263 1266 1264 if (attr_mask & IB_QP_QKEY)
+14
include/rdma/rdmavt_qp.h
··· 647 647 return len >> qp->log_pmtu; 648 648 } 649 649 650 + /** 651 + * rvt_timeout_to_jiffies - Convert a ULP timeout input into jiffies 652 + * @timeout - timeout input(0 - 31). 653 + * 654 + * Return a timeout value in jiffies. 655 + */ 656 + static inline unsigned long rvt_timeout_to_jiffies(u8 timeout) 657 + { 658 + if (timeout > 31) 659 + timeout = 31; 660 + 661 + return usecs_to_jiffies(1U << timeout) * 4096UL / 1000UL; 662 + } 663 + 650 664 extern const int ib_rvt_state_ops[]; 651 665 652 666 struct rvt_dev_info;