Skip to content

Commit 96d9cbe

Browse files
mbpatil369rleon
authored andcommitted
RDMA/cm: add timeout to cm_destroy_id wait
Add timeout to cm_destroy_id, so that userspace can trigger any data collection that would help in analyzing the cause of delay in destroying the cm_id. New noinline function helps dtrace/ebpf programs to hook on to it. Existing functionality isn't changed except triggering a probe-able new function at every timeout interval. We have seen cases where CM messages stuck with MAD layer (either due to software bug or faulty HCA), leading to cm_id getting stuck in the following call stack. This patch helps in resolving such issues faster. kernel: ... INFO: task XXXX:56778 blocked for more than 120 seconds. ... Call Trace: __schedule+0x2bc/0x895 schedule+0x36/0x7c schedule_timeout+0x1f6/0x31f ? __slab_free+0x19c/0x2ba wait_for_completion+0x12b/0x18a ? wake_up_q+0x80/0x73 cm_destroy_id+0x345/0x610 [ib_cm] ib_destroy_cm_id+0x10/0x20 [ib_cm] rdma_destroy_id+0xa8/0x300 [rdma_cm] ucma_destroy_id+0x13e/0x190 [rdma_ucm] ucma_write+0xe0/0x160 [rdma_ucm] __vfs_write+0x3a/0x16d vfs_write+0xb2/0x1a1 ? syscall_trace_enter+0x1ce/0x2b8 SyS_write+0x5c/0xd3 do_syscall_64+0x79/0x1b9 entry_SYSCALL_64_after_hwframe+0x16d/0x0 Signed-off-by: Manjunath Patil <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 2d5c008 commit 96d9cbe

File tree

1 file changed

+19
-1
lines changed
  • drivers/infiniband/core

1 file changed

+19
-1
lines changed

drivers/infiniband/core/cm.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ MODULE_AUTHOR("Sean Hefty");
3434
MODULE_DESCRIPTION("InfiniBand CM");
3535
MODULE_LICENSE("Dual BSD/GPL");
3636

37+
#define CM_DESTROY_ID_WAIT_TIMEOUT 10000 /* msecs */
3738
static const char * const ibcm_rej_reason_strs[] = {
3839
[IB_CM_REJ_NO_QP] = "no QP",
3940
[IB_CM_REJ_NO_EEC] = "no EEC",
@@ -1025,10 +1026,20 @@ static void cm_reset_to_idle(struct cm_id_private *cm_id_priv)
10251026
}
10261027
}
10271028

1029+
static noinline void cm_destroy_id_wait_timeout(struct ib_cm_id *cm_id)
1030+
{
1031+
struct cm_id_private *cm_id_priv;
1032+
1033+
cm_id_priv = container_of(cm_id, struct cm_id_private, id);
1034+
pr_err("%s: cm_id=%p timed out. state=%d refcnt=%d\n", __func__,
1035+
cm_id, cm_id->state, refcount_read(&cm_id_priv->refcount));
1036+
}
1037+
10281038
static void cm_destroy_id(struct ib_cm_id *cm_id, int err)
10291039
{
10301040
struct cm_id_private *cm_id_priv;
10311041
struct cm_work *work;
1042+
int ret;
10321043

10331044
cm_id_priv = container_of(cm_id, struct cm_id_private, id);
10341045
spin_lock_irq(&cm_id_priv->lock);
@@ -1135,7 +1146,14 @@ static void cm_destroy_id(struct ib_cm_id *cm_id, int err)
11351146

11361147
xa_erase(&cm.local_id_table, cm_local_id(cm_id->local_id));
11371148
cm_deref_id(cm_id_priv);
1138-
wait_for_completion(&cm_id_priv->comp);
1149+
do {
1150+
ret = wait_for_completion_timeout(&cm_id_priv->comp,
1151+
msecs_to_jiffies(
1152+
CM_DESTROY_ID_WAIT_TIMEOUT));
1153+
if (!ret) /* timeout happened */
1154+
cm_destroy_id_wait_timeout(cm_id);
1155+
} while (!ret);
1156+
11391157
while ((work = cm_dequeue_work(cm_id_priv)) != NULL)
11401158
cm_free_work(work);
11411159

0 commit comments

Comments
 (0)