Received: by 2002:ab2:5d18:0:b0:1ef:7a0f:c32d with SMTP id j24csp33525lqk; Fri, 8 Mar 2024 22:33:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWJOO/nfPZ0Dw+JazFutACGndKIbI1Ms3Cgs2g0GR0b/jCi2p2EogjuVxta/Ts/lWfKtkCk+uskCmNyLr7IX7X5a0/s4SzzC/WCxutwqw== X-Google-Smtp-Source: AGHT+IGBLIIz3G3xeFxm7yvr71Gi3N7Sm6T0S94Bz/35p6ySetYpeyLY35ivz81vQV7H+cBYcS1S X-Received: by 2002:ad4:580f:0:b0:690:19d4:5eb7 with SMTP id dd15-20020ad4580f000000b0069019d45eb7mr1258477qvb.14.1709966021573; Fri, 08 Mar 2024 22:33:41 -0800 (PST) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id md11-20020a056214588b00b0068cc0945defsi1056256qvb.318.2024.03.08.22.33.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 22:33:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97786-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@oracle.com header.s=corp-2023-11-20 header.b=WwhADwvc; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-97786-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97786-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 42E221C20CB1 for ; Sat, 9 Mar 2024 06:33:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5851C32189; Sat, 9 Mar 2024 06:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="WwhADwvc" Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 710F61D558; Sat, 9 Mar 2024 06:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709966012; cv=none; b=myw2YeKhgXpJP0ysmUg5V1t393sDwF+pqbhiI35osa+z8p2YOT6MXnt3yBjQ73LUdHcnwK5URIvX65TSq86DrQ/8UtziCAwB2QE/voyg2Kq6FW9aF1ZvJYF7Q4SplSXY/cJvbi9oUN+TMJ11ONX2S22iimdYhF2z1zGNWD0bW0Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709966012; c=relaxed/simple; bh=41q6gcZmfcFK6eJeFeLdc6K76dfPJa1FbWOWR2tUh/k=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mg1fj7+er1qrp9sD+XymScbaseTUdop1TiNt27Va+8z0GgPJhntWN9NqZsmYrjWBVv01CShNpd6IkzMxdTt3pAHdFGL5GcraWRbCkpU5OJMapFb72xqy0iFenTGSrw24TDrbhS/+Qizbt5dR9SW21/dHL9KusBpuC0lbTorolIo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=WwhADwvc; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4293OM61011470; Sat, 9 Mar 2024 06:33:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=5sK91Va/rjEdBmKJjQeYKa2mWUAHUdpKSI4tVTyHaxo=; b=WwhADwvctf7oCM4ttIPTNpw1/m6tKWp6f8MHW0Ym1OLAPWBs8SMYocH+KvvspMFijdbu oRThYOEW9iGsLrdEgdbu2X0gqHCBlioyn2TgWYp8UjyLfrRke4Bk8bly2Udug00t4h/s 9wqEtWirjaDGtbFb3rhVI2zourf173owVWfHBVmTQG/xzivnUOEEARM39WYlCKITd6mx a2JwV7ZPLeFzka+UToe9yoyemAUZTyIxBF0fla4s9xe5Azx7766Cwbtk8znFWELjrK4M lyLeOfuh6+B7KC0hq0qLKHZzMk6etbcDll1gg0BUMoG2ikFCpWJZbNg/yxWQe5sSgPhL 6w== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wrftd838g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 Mar 2024 06:33:27 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 42960Vcl012259; Sat, 9 Mar 2024 06:33:26 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wre73w1aa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 09 Mar 2024 06:33:26 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4296XPTn027410; Sat, 9 Mar 2024 06:33:25 GMT Received: from mbpatil.us.oracle.com (mbpatil.us.oracle.com [10.211.44.53]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3wre73w1a3-1; Sat, 09 Mar 2024 06:33:25 +0000 From: Manjunath Patil To: dledford@redhat.com, jgg@ziepe.ca Cc: manjunath.b.patil@oracle.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, rama.nichanamatlu@oracle.com Subject: [PATCH v3] RDMA/cm: add timeout to cm_destroy_id wait Date: Fri, 8 Mar 2024 22:33:23 -0800 Message-Id: <20240309063323.458102-1-manjunath.b.patil@oracle.com> X-Mailer: git-send-email 2.31.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-08_08,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 adultscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403090051 X-Proofpoint-ORIG-GUID: Gnx-IliWHJ7kqe-PAoGcx2rRUY1-dE4U X-Proofpoint-GUID: Gnx-IliWHJ7kqe-PAoGcx2rRUY1-dE4U 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 Orabug: 36280065 Signed-off-by: Manjunath Patil --- v3: - added #define v2: - removed sysctl related code drivers/infiniband/core/cm.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index ff58058aeadc..793103cf8152 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -34,6 +34,7 @@ MODULE_AUTHOR("Sean Hefty"); MODULE_DESCRIPTION("InfiniBand CM"); MODULE_LICENSE("Dual BSD/GPL"); +#define CM_DESTORY_ID_WAIT_TIMEOUT 10000 /* msecs */ static const char * const ibcm_rej_reason_strs[] = { [IB_CM_REJ_NO_QP] = "no QP", [IB_CM_REJ_NO_EEC] = "no EEC", @@ -1025,10 +1026,20 @@ static void cm_reset_to_idle(struct cm_id_private *cm_id_priv) } } +static noinline void cm_destroy_id_wait_timeout(struct ib_cm_id *cm_id) +{ + struct cm_id_private *cm_id_priv; + + cm_id_priv = container_of(cm_id, struct cm_id_private, id); + pr_err("%s: cm_id=%p timed out. state=%d refcnt=%d\n", __func__, + cm_id, cm_id->state, refcount_read(&cm_id_priv->refcount)); +} + static void cm_destroy_id(struct ib_cm_id *cm_id, int err) { struct cm_id_private *cm_id_priv; struct cm_work *work; + int ret; cm_id_priv = container_of(cm_id, struct cm_id_private, id); spin_lock_irq(&cm_id_priv->lock); @@ -1135,7 +1146,14 @@ static void cm_destroy_id(struct ib_cm_id *cm_id, int err) xa_erase(&cm.local_id_table, cm_local_id(cm_id->local_id)); cm_deref_id(cm_id_priv); - wait_for_completion(&cm_id_priv->comp); + do { + ret = wait_for_completion_timeout(&cm_id_priv->comp, + msecs_to_jiffies( + CM_DESTORY_ID_WAIT_TIMEOUT)); + if (!ret) /* timeout happened */ + cm_destroy_id_wait_timeout(cm_id); + } while (!ret); + while ((work = cm_dequeue_work(cm_id_priv)) != NULL) cm_free_work(work); -- 2.31.1