Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3297960lqo; Wed, 15 May 2024 05:56:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNAQowq2aoXjR+xDJ/zf/CwvknJBGG/1+IeirLf8m/MEoE35wKq0Qjmk2FfUippmdRCOJvPpkZgfJ2th59MzDL+1SgxBHbDjlmkj5+Yg== X-Google-Smtp-Source: AGHT+IHsd5Anzae7a1hEg5MoZQxBFICq2FhYnkOeXbSGt7wMBE2szmtEtYV642Ys7smnFBL72CSk X-Received: by 2002:aa7:c684:0:b0:573:5c3a:b063 with SMTP id 4fb4d7f45d1cf-5735c3ab06bmr13973190a12.22.1715777799757; Wed, 15 May 2024 05:56:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715777799; cv=pass; d=google.com; s=arc-20160816; b=rx6C5A151qX7giSVpmNW9velXjTktgCHVmE++MDn+9T7IJUlwHJlYP6tgRsNk6Q/bI wk9NKFE/9lo+cfOuBJbLTS4NWH4axy8ZIqzzdgX78s05E4jyCT9qVoI0aDqMF+4IcejG HJvVtyJNpfNkL8bMwWP7lSFIyEdRqFPVhHLwQvsITTy6pb96w1kuT6MZbJV7tFBxkAvY unnOuq7wNXmpl/a/YJzp9KXIVGrdN59QgbYaSfVq/bYFIdwkeNeYgvsyy8nJqvySGxzd bOT0r9x+x25rweB1OBf9V1lDtJDZMYud+AuDI0ly+PwDjzyPMopQ5R2QLOIPTnxFcanr vD3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=y5Ep9p+cIwPUrjX1dgCqftpNDUoKQDrgqAGsTqnOQGI=; fh=GaSAYfh5FLoTC6t2Xhg6bNmq0NjRUvBIE2VOTI0dJc4=; b=g6mZEjJ4TUpiWKElDAZH76c/BnyJodcbAiHJng/FtiXNF2ryTrRbXk1X3QBfI8m2nR Lka2ssGzO8PACouu6rmYoXt7Ey8iVPZdCGIPXZtEgYVFP4z/cX0fmT5aV48g/gL9r4YV NpDRK3Go/SKt+hspmN7nqQpoHvq7GUV8B2cUFGtPvn06yKSs2B/Z3mhsi5cMcZIB3i9S R76ecPbI46LMo/gu29E8J0ka0CikHN/mXyEhRbTezrgWUYs/AzR1FMK5jaPM/OPHX70S Od2XWM5Oj1XTA4bdNTn31dVr4P+NDyVA95cz1054F9bSR5/VhyLsGpuOJXSH9m5UDxFA uOIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=hx28RVeN; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-179866-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179866-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oracle.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c2d4e71si7922439a12.318.2024.05.15.05.56.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 05:56:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179866-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=hx28RVeN; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-179866-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179866-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 549111F24087 for ; Wed, 15 May 2024 12:56:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 653BF12BF2B; Wed, 15 May 2024 12:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hx28RVeN" 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 CE854101C8; Wed, 15 May 2024 12:54:56 +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=1715777698; cv=none; b=qhTleSnS7voAYGKp18OWs0rF7SZfLBu99ZeEmH/lZ+C1a3ORs+qzraRMr+Y0AEw0OTXG+eaHpuCcMsYSI7PXkB7xNQUEyx1Z80Kao3msQV7oGA60ImgehkdWEZUw3L0NYeVAouyBlv7jW7T7I/b23RcvMQfyQCvW0TTB+a6amDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715777698; c=relaxed/simple; bh=wUZJNekknAtY0xAkk6kJRnfr+7rn2D06aTHGKn1Bv90=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=PD77YI6FXUn1ZckuTvN+3gWrrJvfULeYM6v+nlYjUskfV+9ZuVDwsdnc/+e3dZeLdmSD7wTt5MlWDJNKtNyWY5TR3Wcphy9Kukb4RoDZ4voR3YBZr0dR/sfrVzSBF7oMHkEPdA/CEc2d3QxluY3oFqV5PrrjtY0VywM5hL6ZQaA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=hx28RVeN; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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 44F7n23v008505; Wed, 15 May 2024 12:54:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2023-11-20; bh=y5Ep9p+cIwPUrjX1dgCqftpNDUoKQDrgqAGsTqnOQGI=; b=hx28RVeNq/YVOuf09oBVYT2LGDZ5RQmlcJ5exnHEZEmvKviuAcO4xu2pE/SY7tWd+KhW 0NRNlenWkE2BUNbAhvA+pas1BbmelpDIak9pZ9ffNfBAHNBUQQBBGaiem9cNSlpPWgWd yms+HZo/6ueYLrBIcQwOq8w4qhTF0Xpj6oyFTeS4YGk8w2iChwoX7DeCoDVMl5BFOoss EDzRaJd9dSqKjbCXRU8Gf7kSFZ75/I0yE68XnyjTxRABN1LVG5cz0UYKtvE9lBsavfhl +ztZPU4XgKP7PP+OYoRjepJthWuAb4bFl0HNuspCz9HISsQok8RCAC6OkLHrrl+CjMce 8g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y3t4fcxkj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 May 2024 12:54:08 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44FBLBLx038451; Wed, 15 May 2024 12:54:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3y24pxguvp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 May 2024 12:54:07 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44FCmlrj038458; Wed, 15 May 2024 12:54:06 GMT Received: from lab61.no.oracle.com (lab61.no.oracle.com [10.172.144.82]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3y24pxgud9-5; Wed, 15 May 2024 12:54:06 +0000 From: =?UTF-8?q?H=C3=A5kon=20Bugge?= To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, rds-devel@oss.oracle.com Cc: Jason Gunthorpe , Leon Romanovsky , Saeed Mahameed , Tariq Toukan , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tejun Heo , Lai Jiangshan , Allison Henderson , Manjunath Patil , Mark Zhang , =?UTF-8?q?H=C3=A5kon=20Bugge?= , Chuck Lever , Shiraz Saleem , Yang Li Subject: [PATCH v2 4/6] RDMA/cm: Brute force GFP_NOIO Date: Wed, 15 May 2024 14:53:40 +0200 Message-Id: <20240515125342.1069999-5-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240515125342.1069999-1-haakon.bugge@oracle.com> References: <20240515125342.1069999-1-haakon.bugge@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-15_06,2024-05-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405150090 X-Proofpoint-ORIG-GUID: KnmR6otdKS4p2wIQ7YWGWGOG1z_IZBy2 X-Proofpoint-GUID: KnmR6otdKS4p2wIQ7YWGWGOG1z_IZBy2 In ib_cm_init(), we call memalloc_noio_{save,restore} in a parenthetic fashion when enabled by the module parameter force_noio. This in order to conditionally enable ib_cm to work aligned with block I/O devices. Any work queued later on work-queues created during module initialization will inherit the PF_MEMALLOC_{NOIO,NOFS} flag(s), due to commit ("workqueue: Inherit NOIO and NOFS alloc flags"). We do this in order to enable ULPs using the RDMA stack to be used as a network block I/O device. This to support a filesystem on top of a raw block device which uses said ULP(s) and the RDMA stack as the network transport layer. Under intense memory pressure, we get memory reclaims. Assume the filesystem reclaims memory, goes to the raw block device, which calls into the ULP in question, which calls the RDMA stack. Now, if regular GFP_KERNEL allocations in ULP or the RDMA stack require reclaims to be fulfilled, we end up in a circular dependency. We break this circular dependency by: 1. Force all allocations in the ULP and the relevant RDMA stack to use GFP_NOIO, by means of a parenthetic use of memalloc_noio_{save,restore} on all relevant entry points. 2. Make sure work-queues inherits current->flags wrt. PF_MEMALLOC_{NOIO,NOFS}, such that work executed on the work-queue inherits the same flag(s). Signed-off-by: HÃ¥kon Bugge --- drivers/infiniband/core/cm.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 07fb8d3c037f0..767eec38eb57d 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,11 @@ MODULE_DESCRIPTION("InfiniBand CM"); MODULE_LICENSE("Dual BSD/GPL"); #define CM_DESTROY_ID_WAIT_TIMEOUT 10000 /* msecs */ + +static bool cm_force_noio; +module_param_named(force_noio, cm_force_noio, bool, 0444); +MODULE_PARM_DESC(force_noio, "Force the use of GFP_NOIO (Y/N)"); + static const char * const ibcm_rej_reason_strs[] = { [IB_CM_REJ_NO_QP] = "no QP", [IB_CM_REJ_NO_EEC] = "no EEC", @@ -4504,6 +4510,10 @@ static void cm_remove_one(struct ib_device *ib_device, void *client_data) static int __init ib_cm_init(void) { int ret; + unsigned int noio_flags; + + if (cm_force_noio) + noio_flags = memalloc_noio_save(); INIT_LIST_HEAD(&cm.device_list); rwlock_init(&cm.device_lock); @@ -4527,10 +4537,13 @@ static int __init ib_cm_init(void) if (ret) goto error3; - return 0; + goto error2; error3: destroy_workqueue(cm.wq); error2: + if (cm_force_noio) + memalloc_noio_restore(noio_flags); + return ret; } -- 2.45.0