From patchwork Thu Aug 8 18:33:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13758060 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2130.outbound.protection.outlook.com [40.107.96.130]) (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 4E08814659C; Thu, 8 Aug 2024 18:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.130 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723142035; cv=fail; b=i6ee4hzJPkAFOBUT+REeirRP0ILnFvo528fgkGbt+Ifkui9CfHiQFqfkd2y/edSOta8bvWR2PKNBTI1ASanlfhokY88PMeYSpMQbrgcxnKybmB4ZYF8qFLinuhG3fLWnQNWNuJWXT2RDeZ59WEhuRGCUdnIPnHZ3nsKx/wbZLmA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723142035; c=relaxed/simple; bh=RjeCSzCGxnOSVEcFpY03afi0pc0ccHNEt0bQzkNpncc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=DIdirZzJsL+r1aZvBM5V23+qwa6pHWXefTbHFO/WZU+y3w2w+3LKgfWgYAtQIBL/i25qkkOUNB7u8jNrtiJ2J1imHeNM7OY6mVW6Yvd8OccFMEREjadPzW3X/ZGECtbw6vhyXrF2fCYjX9+MXk6aWystz4tSfwuzl+eAq4Vah4Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com; spf=pass smtp.mailfrom=eideticom.com; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b=pCt6/GQM; arc=fail smtp.client-ip=40.107.96.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=eideticom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b="pCt6/GQM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ujKbGVM/axt7s2s03Kq0Dx2ivf1QCazH56D+jlb1s/edim5b0r+zROzuq4EvRz2JH4NnsL9tL4TQju5iWEZsMPC2F86AL25Ph8BenIyR8BWvyAoKiB1Wu/Dle6UiwkXihtWes9RWpQ1Fa0jLTKTucu5wVCYT4lA3DW2ju02nFf3d7vt4zwJtBE6WEFR0gurW9Rz+sliK1TGcK76lLlhBc4JoulsnGRFHhBBA1QKlU0g7/kwaStFrZMYTk63y8VErAjUBX9Qs6Cz7oL4oMEg0k7silWB2UZ3NLw4/iFzro/6wYo3Wq7xlqCaZF6RJjJaGzzjpbJ7VtC+aXYbDZpc5pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EQhK3ka/BH1jfrlP7Pg1JtnFuCDr3tWdul7G2/wv3bQ=; b=RzQgEDzw2wzQsXciaxIfsLzqXrFbq/ptQSy0LvYOBAQ5jiFBupM85qoXqoT1MXAFFnn7/R8gjx0UHnlUmpEN+/drpA+vjiA38jNPa3ulqHJtdbMxLKE1uITz7qUQJIrZyW/Xh49C3Qxp9fEobWyDtFfxJT/I+nKeCVATDaYniwV7azmnG1x5DeqkftqiIVIL9nMyYTIIqrJJAwCTxBI23CaBvV6sgUo5Q70FmqpCorKHXuViN9xxtz+VcP36RVw+4zfxGM+OGH5YnxCljYRzfgiR+QxtgvNkGvR1YQxXeeLKvJWlVUZHNTRTZa9pncThfF0eaLoPFYdL0QcYauJ0FQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eideticom.com; dmarc=pass action=none header.from=eideticom.com; dkim=pass header.d=eideticom.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eideticcom.onmicrosoft.com; s=selector2-eideticcom-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EQhK3ka/BH1jfrlP7Pg1JtnFuCDr3tWdul7G2/wv3bQ=; b=pCt6/GQMCb9KY3IQvgT3Zjn3GZqxZa9WNtmMOz8ofyX+7K219UKQq9fWoOF+gihMoScigvn0LwnGWqbD8emKuu7PUlQL+zjwEteou+E622CcNRSQpLIxaI88HS65W9gimlimr19Qn2ECIinNXufzMj4N91hLwtTymj1DVzBNWo4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) by IA1PR19MB6348.namprd19.prod.outlook.com (2603:10b6:208:3e4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 18:33:51 +0000 Received: from PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849]) by PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849%3]) with mapi id 15.20.7828.023; Thu, 8 Aug 2024 18:33:51 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , Artemy Kovalyov , Greg Kroah-Hartman , Jason Gunthorpe , Leon Romanovsky , Logan Gunthorpe , Michael Guralnik , Mike Marciniszyn , Shiraz Saleem , Tejun Heo , John Hubbard , Dan Williams , David Sloan , Martin Oliveira Subject: [PATCH v5 1/4] kernfs: add a WARN_ON_ONCE if ->close is set Date: Thu, 8 Aug 2024 12:33:37 -0600 Message-ID: <20240808183340.483468-2-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808183340.483468-1-martin.oliveira@eideticom.com> References: <20240808183340.483468-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0072.namprd04.prod.outlook.com (2603:10b6:303:6b::17) To PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR19MB6828:EE_|IA1PR19MB6348:EE_ X-MS-Office365-Filtering-Correlation-Id: bda6de14-1593-4c29-67bb-08dcb7d8a682 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: CEhCZS9sMTJ1esH9bk0rVDVeNdGLF9TSe5mwNJL8zjXfcW5r9KSzbLUWM+yva0tPV4rSXrGvJK6xYv3SEqoBffMN3Z7swGR2JaZAvJ3p/deqKhvQOIlZ/2ToRK9EDV8aEqA7L6PNwd29R3IBahJmix90TnmlxhSZ+ZC44RC5er8V95gYRfaC3cdv+H7t0eay2NRFPsYinbcJLBzdsiJ8Os3NTbq0X5XRrLhglWQ+GUdXG8YXlGeT+6ANGvhBDGO7zFu7K4jo4jLk76WvadXbq85S0SfMmAjGVgLDggMrRPt+n1pHwU9CewrmFu7AxX4BtMbBYjw0F40JEWM/BUpFanexI4fRRfEYOUsEgQvV87884mTQA+zHr+NCbXGcon2sZtWeekwk6niKzihS30sBkvMr0r297TmcBK+XgVommeJMMd7l8sdb6iUM9NetvAqgWihGwYZq7BjgoJoU+e1Zc8H56nEaS/K74UFrq6ZqYZnk2+toexRT6qSEV3//IyYIPuVfg68QZFmY1c0uaZytiTp/j8YAhzCevSXLaaxsWd6tMcBUkD3SoKHYnXyxl18+/dMscKKdSdm6l56zzrkVyh6JJBh0F1mAfPano0zsNr8Ikr8BhQby5q2X92/pcrxv8GESGB9aLkbDZC5laRSPmrII0QpmKjXxvj3Rs53hTmclaGCP/gTVxf9ihXyFQHUK3KBh1GHLFmyXhMcK4OJkeb7rSyCSsx5K1m5gQnwFysHA9hujuslXlmh1FT2Gkn5ouDfK5o275/1qmoQ0Bwcon74Kbjo6JQtTKhPscBYcLbVcQG4rH9b41wew/CsurNullwVl4JJA92nkvd61rpurSfGhBOxGOjrWgvn0PT0UUX4slmrL5aJx920j4YoGRWwSMJCPkxd/5QObEUNvamk1H8yGjAt7D1X/q5yQIPBO5qDcN+bPe2s/1cIkJdKvdoo18NICRewq14homDHKY2vjosXLFTvPW1bTLIhatmAAURnfs6+yThiSsQ/6knxI/AZR2bSv86+hHQ3/pnaheU1J49pBCfSTkjDJPZ0oOLHO2db++A4DdX06OXDhDYd5ipReuAvnmghxTOscZ+ZouWUkwkItW66qIJBVTiuzKvsP0Ea+hT2SKzhGyIyLsiefxAEdZ7hkRp2GAHWKi8hXSxhV6rHTFodvIbUyWbM+HfJODSyVv1vrlleHoAXBGnijJ3wrXf7ttIAK3WjS/at+Dl+TL/DsTE6YR988+iW/TU6Qwv+emJtEZoRIOPjbxVJnszq+uCfEAMSl+zpnF7zHI9TOliuBjif9cQuVMh8oepDnchjd/DkbHtMLWsfHC2WjxTLQrmDaslnwecNYvyft5LJrso48es47RETd6RVYoRjT0mK3Bk2saIpVCBLhnlOlHhvUUW+t5uXBrF8aGLbDovOU0A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR19MB6828.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fi/gFOVZMYxQh1NqESXyi2ZuokP7jcoRykqQh+XKoIUWxoxkQiSP8u44FfgVDr+LMFJcQ4vlqiHM4Ww34ITkmsgOHXpxremA3f/GB8e4ds5EwNxvlKpRdZRQPHYCx7Dv9rESbJZC45B8ArdgngvQDKcNBatLR9jwybzKOix6AZHGrdwi5+YJpr9iU4HkdBCjK7CMhEYfKvV2NCZWxyJ4nF8CWMzbaD5UBOt3F3zZC43qXlG5YSZQmOyyxNs8v45L3Ma+01ubKnahmS0gQTSf7wbY9Jg2DGSVSS6qcISEnFzU6YvXf+/8QUcpGsTk8ziUZ99AaO3CVuI9P97HTaHBq2zuGpNybAIyYC2LVIrInDDy+oSG1BZygGGVjTYnA6sHP0oR77+ZiilV33qxwKS7HECfS8UX3PAS1j0xTumi/X/fBtPk9PedNKygblo94wJaS+mpK98b/bIvX2zKJWT67wV88A8m1MVFURBUfeVAS4+hkf9ZOaollpJH+3BqjDyW3fSQSOtMxesy5jPArDIQcZFON6ljHMzIe6OCfe+qE5OGpQxiUK63Plc2hFSOXDaUMmetDLatsRJBE2AA7MP6GuiiZWP1TPvvbncb3eesK3LII5CaOMAj2oRkrh+cnAeduiOJw86jgZ686ovtv+Ob2pe22RZMSmq2uR50NQl2yX3B6LGvaT+Qvl07awfBFLZ8dn76F4mNCC62XZoknx6XhDaojj+tOwU8/CxR1IVL6a4jIF7RJuYipQeBUWy44DdzQKWTlXSeyqp25+pREbMqsUwXsBPQZtXiyG9a4w1ivCQwx7Y7dj/DsRNao9/5Ihd9w8T7/hK77+OZ+3T30MW9mwTaD04JR9I/RHWVe79p/dIZNmrtxrxqI1j5JrjGn4dE/BF1KCKGCt6Y7vw58JBsapOo0K09wTGfSGALbdRO3teOHiwJWodYBQ8/9Uo0+M+khEO9vtBqMwzIpo/YcYX4ybjX08Umi4gHqGQ6KJRVQLpW3wGtm6FUZx3su4Um5GGH4rLm7zZrb87E1aBj9ftoeUduhFP22IvNUvmyly5UJk1G0pbnCWdkY7DJVB+J5vMA51gn+franN041upSCRotdwWO6jAcN+aQ6cOXwba4t0RGIe11gDPqZWFrZsEoIUvRTPoZKRwkcXpjN2YTSGU1UsnCe4niR4zLVxdQFn2uSBzBCaLhzKbOOsw7mNxTxrzBj/lACfDTSQGpRNWxYBRl2voPXg0Qqhns3mSulS0Epi7F4BeBb3CyvA7NOAnmZinL3FxwPkEll9v+D24yOkRqqHou7AGCgi+Hc7zDRn/NAzwXZvV+NRrY96Dhqavd/RKq3jMk3dMayqVN4vQQ9HRYyNhsBkPArphAx2QXrAoWbiaTDmA96cvnVSvrJ5p7g03SlmwVP93o1aKhumlf3NODBXUDBPpWF+fSJWNJ6isxs93cRRlz90KcrCFdpu1vYlcKfpmqgWkGwzMmMBHGUFLlOovQGjqJz+2TSdM4DVH+6bNrdXqN9hiV7/AzB3rYpc/n+9v9GO6fimIBM6xaEvUcAR9J6bWdhTyROWDNiJpVC8iCu01tYj5P9rwApLVT2vllkCa4l57uUgJqzp+C1SrHjbKegtZkhcyRTuXL770qktM= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: bda6de14-1593-4c29-67bb-08dcb7d8a682 X-MS-Exchange-CrossTenant-AuthSource: PH7PR19MB6828.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2024 18:33:51.6167 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3490cd4b-0360-4377-abb1-15f8c5af8fc2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2XB5/nzF0dz+IwSzCdRb7Um9IuYaSHhy+VBs0E8fwLwC7IjC6enFdTxHKYEWlEyLxVxurt5xZ5DBz0Ro4TFqzqob/KF+zJYEtI0pmJf0HuU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6348 The next patch is going to remove .page_mkwrite from kernfs and will WARN if an mmap implementation sets .page_mkwrite. In preparation for that change, and to make it consistent, add a WARN to the ->close check. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira Reviewed-by: Christoph Hellwig --- fs/kernfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 8502ef68459b..72cc51dcf870 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -479,7 +479,7 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) * It is not possible to successfully wrap close. * So error if someone is trying to use close. */ - if (vma->vm_ops && vma->vm_ops->close) + if (WARN_ON_ONCE(vma->vm_ops && vma->vm_ops->close)) goto out_put; rc = 0; From patchwork Thu Aug 8 18:33:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13758061 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2130.outbound.protection.outlook.com [40.107.96.130]) (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 EEF35149C41; Thu, 8 Aug 2024 18:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.130 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723142037; cv=fail; b=EP5hRPJNe99k3W137Chb6FCorsMngLH4COCsUW6RtUibWurrctCXu+YcIqMKzKJY8Craus5pM5etHMzFAOj9FiEMKRmnxhLvZT5zICnioON1K2GrKPoL1ZodytxYqtYoI6VgKGgk5XwUPFbhdRgxjamuNOuSrepxqNyneHkNe3Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723142037; c=relaxed/simple; bh=dJITM5iRkORZTtRo4geLShzgnFCU72cs+uqaIBmPhQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=TxKwynLx+T4q7FV2ZmdLsr2ufKIoUncV3w6Zu60SNYamFpt4OFjetgDzKSwTVpbaoYyxOdcFBjNsrsQqa/caIaHUKdEfLF0GujCPSGVo87lP5jCmNh040+jduXZuJ/qbeLysTHt1QGQRSqILvsmkdRF1K0WUU2XM2KXWtXjQeTw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com; spf=pass smtp.mailfrom=eideticom.com; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b=RB8UnFDp; arc=fail smtp.client-ip=40.107.96.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=eideticom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b="RB8UnFDp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wb3gPNuFAKfM3kob2T7fs3Mg/zNlEz61+NUZl4pUxpqfvDQfcy6Y9ufdlV8Nyed5wcXnGPvSL/CHPtvooG/kmaU21gsVYIh3/+ewSKhVYiF+ItOt0N9/7DrwvjBNr0WYA/s4sGNjv0mUJtxfjoD2S9eni0o0Md/+qBjCtPXzMNH3OaZm1ryDjF7n45jiDYobB0dNUpbK4HCgLZg9iEw079KlHqwkuLGBCiJDIvJ7Zz1f7VQet5SrT84a5EvWk80pdpAdudyklLkxjVEBX/efjCMYC5zNho+hnwtAvsBcVoAWuKkpN+Iacd7ie4Eu182kA76vRdw7MyAoCozyg568pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pRUDFAbvP4Wci+R7KuxCrccwPqV5quWpHJXtfd77Uvs=; b=kw9djgDsYwDoxd2C4VjVcqoMLa4iilRJAt2ATAU/qlIhgOzXhOX/z1tBKnImTlgXh2uNdU64MVYxVRRXn/Jszsp4rjWRbw7vILA6tBK/6bR2ga0CJ1g8WSruz612//R0hlDUnWF/JQcTUjd04lnyFnSM5AuuOMSSAav0hqYgu2aLcQYFcca/KT+L7ryseuljlZSNBFePCx9VuVukuW6N3n8EQmncZW+he7R6djcGaPmLdWlZSPhmIqPcTlj4IyX0MY5su79xzQ3lSNgVYj0ssAAxl9QGUKi69yqpfsCrU7IXRGJZblJlwE5nBCc4I1NV5bhgvLV/QK43HTvRSbfGdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eideticom.com; dmarc=pass action=none header.from=eideticom.com; dkim=pass header.d=eideticom.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eideticcom.onmicrosoft.com; s=selector2-eideticcom-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pRUDFAbvP4Wci+R7KuxCrccwPqV5quWpHJXtfd77Uvs=; b=RB8UnFDpYGk4WIvEaZYq7Px6GoybhdhyGJDGWCjwLHew0koqhJzp3s/9NhISYYJPD8NmWmGAkblVgd8XsRG0CgwrZe9lVGAPlRJYUSfxm+ikjXc0dG4NizVkwoCr2zV4WqDRH9Vl8RJ9+zbeF0bHIwvrrGZeawnMwvYt2HylqKk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) by IA1PR19MB6348.namprd19.prod.outlook.com (2603:10b6:208:3e4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 18:33:53 +0000 Received: from PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849]) by PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849%3]) with mapi id 15.20.7828.023; Thu, 8 Aug 2024 18:33:53 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , Artemy Kovalyov , Greg Kroah-Hartman , Jason Gunthorpe , Leon Romanovsky , Logan Gunthorpe , Michael Guralnik , Mike Marciniszyn , Shiraz Saleem , Tejun Heo , John Hubbard , Dan Williams , David Sloan , Martin Oliveira Subject: [PATCH v5 2/4] kernfs: remove page_mkwrite() from vm_operations_struct Date: Thu, 8 Aug 2024 12:33:38 -0600 Message-ID: <20240808183340.483468-3-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808183340.483468-1-martin.oliveira@eideticom.com> References: <20240808183340.483468-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0072.namprd04.prod.outlook.com (2603:10b6:303:6b::17) To PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR19MB6828:EE_|IA1PR19MB6348:EE_ X-MS-Office365-Filtering-Correlation-Id: e8fe6235-4ead-4990-611e-08dcb7d8a767 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: r/inA3VT/8mfOp8ld6nKLqNGAfmT2/ixqrT3JXm9HT54veh6XbiIINy7ywt2BBxrLfOmbQqZra3Wig8Hjp0rCs+8UevX0MONWDEYlPOQSVtDTT5oqQ9z9ZknafUtWxGUdsunA1NWGjd0L+UmykvYU1zQeqSvK6KUtJfMkAA/9Od1ULsbqKh1E+qWAPd47Yly0nZKes6HWrhXhRTBdy+fAf4BS/Mv0rXYdGTu1bjRLheZ2x5+ybzPst1mL0OVdmSQYhx+3px6CpxFntXWs7IfVF4GMYF68pk4bbnsHGkGpd9ZtZEULgBZKESKclQ3j3oejLIWGBeUt7W8xj7sm5ovBQSowf3AEnPg75KZ3PGHQcHokncPhQCKIh4daoW55Pt9ctbAZCcXXWrLHKUWEKKcj/iJ43ylnU13ET23s+EnTUR4EKHWsFpqm7F9zPz7g/S4R4FglL5p4/bweNAiHTVtP/CyCqD+QyDzgFw0weXUOuBstPhNFWtclb/veEVcrPDImWonAk1RSo7c2IHwjtaRU8Y1dn2htfKJ8GnOm9tp4hJTitsHlsDF+Jo6zOMFWJWmR72zGOOFxsuXVpWc5mHAquQYEJh+u9F8OhX8hTkjILQGHfqppqYZUSfd6mhq+1dtdOliBcb9GwWIjg3fTvtXcCdmdrZge0BRlV8EsglApf5S6jJxhfSgXjKMDRw4GAhz/sYfx9TfIh5u4gZ1CfLYt4x9vB/28aCJqV0AuwqtrjWwI2SvFN/Tr3SoriX89YI7FeJ5CSVMmnE7vWqcGMOhsBVboBz1RxHmfJYsGGuWS0qjuqPbutaCpyqt4ILnVErprw0I22Vink+DqSbIqgLa2KddOytj28npBUUN3yC/mhM56xPJ013HLlN7hYBrjxQ4pdfny6wmXszlNmyrhnGwJNCVFPo3B0YEnFhBJMI55vhdBXfdzJ5Uk0LKraIMac5/DxDeVIuGGuQ1GNz3QNfbcHq3P1lWMTWoeuazn62Fze13nAUGwO+V+QyWNrU1KRC0i5mhdYqsdvWE3OQ/KNOXS+2ESlsEBtTQGVfZoDx88TfyvDaCatS4fsrhAqKGO2tCrOU2QlETf30DsHGMlaMaZ0vtlQEeW0WeFMhtP5VZs4y3BK1i9vX8HyOVtPneW2stOpZ4jyRTQ30yI89eVxVsckVepBISgSSiUXBwnjjqcdZZiNS0IxBRgmCQVbnn/cnW/m+eLOETTZfNM6LE10pQt+sMyXpNjM1ZqfWNCwtTG5KHHGbKiFsODcsemcIpmEnL0VvMZajkiTno7mwLxYfgrl6VSj7W2tShXg24rzMRAaQNVzupJ/F4QzMnc+Fvr1VQ9nwMidwaeWJ4Y2MzRXmzVXQgZhBEw/7VzEbIOhmQmOCX1IKgKIuSUl4Q/ELuKBkFIJmF69jE1WRUOShf7zWAyg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR19MB6828.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yyf1WoVvEStKZSmkiXOYLR4Bd5OaDzNbJTkW/CdtySv9bR3pHgXjJgZDWZHzYVEWzUKaTWIKNfJ/WZZcNfDIJ+F9nVmOAYNFW/H/3yzv+wMBsWkzuOC7YYx0z7JYY668brQsWDeIprt5/awrMYC2qHuYJrHrT+enKPjlcg3yVPqrMojNNIa15bzbpgkky8jovGUY+nEjkAwh8xnts3LZxXPcpp1sERAz0tZHH+auaQhm+dImD/ocW86oceQxCc7EIKWLdKjIoWtLTe7jjRDauGb5V0Lmzv6EwR6saWfbCr8pMcKNBBGMfxx1+qLMJiklg6gJnfcu/mpz5s+OQczvU4+HZ/8jMDWnmmble8g7eZslepeLBpqFV81zDb+wfgIwZzMrKO2jCiPgpaKdt93lXUbZiTVcLwYgFP0YP9sssAAR2RmbamzJSL9I6iev4g94KanGjzFfhLMSDjXnoJexABAATI+Hpk1RKC3l7jVitNwWmjmkNN/nOMb37KJrZA7nnNbDX4Ok1FYR9uZ1Ixn7XGNvPqQDhUC4JAdVbvq22EHcG3sPjkTM4uAE33ngyPfCF2uC+2d34RwwC86NSRiA67RCH33U2v+HqP2t9qjAoUO0zr4Uv/o1X/o3My1ukhPrPIM/OyP/y8GsH0PeXpCb5MIMf2uzQRJSvMIGeAx2n/6yjzuRU5P5dcSgIVubdLs+d8bA/gGRqv4UMWUqhFSlPiEVZzGpt9c3aOD2Fsgba1Y68VaQ+M5Z2RepRmso7Wtc020oPYFCydsH8e4tFHENK3xbf2pKq7fDuXtnJJdg/jbcSj8kcAnMe4O0MTIx/O+pyym3J+LoXgCP0pdfoxp6rBSascjKigtPNLwbJKKEL1SSLUqN3JqKPF0TWwVR3nxxXC5eEC70r1XfJRBxIFSE+neuNAZG8eWMkIYh7+m51ny20q2Uxon2u8/k+5PctWKIP7DgeoDBnoF8VzMdVPk3a2EFtiRwf7EwEORfAqpwR1N4cuRhkAR7uFSCGBoJSh+/vAM+m5HndgWw6DGvJL6RzGFYgIiQ62WlV360PPEL2dca2rgiQRgJoyoCmpJ5w02xti44ITil4DXVTgEBLU8apgW8g9XWpugsbl9MbC4DR1kWhTtTZndgNJUuyDC9XHFyGxJOGXpJp5WpQNtJ9b3x/MLFs/YDMujzNEuDpGUqBKMb/7xIE6QVdF12GMxQwQ3qQoB15zn7jEb4Z7HPdZdoBAAASHVj0KCE6BK1H1QzSyzp91P8ooay4K5gmJP+0y21eDgU88zLuMdTplzKsUGsDDgyCC3AYTOZfRkTRNk+aSU/+o/EBblbqfikuTr7ibp8ZUwXOq+C4c+zjhAMr7qtQaFmdzJc4zoW48tjyszfpEsQPUoTC7yUhnPUWaXXloGAnCkeqZWYh2/xR5vde0knh8QiSucVaYqbvO6W7fpSXXATqoJrtPO4FR+sRSzJkZlmjzmUH/xuvZtLyuZyfavF4ef4MWhCm1ESWRoEFMnWHV0atzG3gMnAzOiXKWb4O8QKAbgXqDN8WOl/AWujk/HYxnBa1uf16mFXev0AY56o8Sp/jkOYRbFwDcavncWmPSjRFIW4ZFW+TlyYoyDrgYft4Yyp1M/Q4sUp4lBv6RJkNvg= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8fe6235-4ead-4990-611e-08dcb7d8a767 X-MS-Exchange-CrossTenant-AuthSource: PH7PR19MB6828.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2024 18:33:53.0371 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3490cd4b-0360-4377-abb1-15f8c5af8fc2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OckluIzi8BL2FY3s8sO/bhcIGAsU1YoquPX9U5CVsPL3KMM3n721vf8I9WeGgRy+MNXfjGWhL8JBpV2qsOs/o5a6Reqpv/n3qwmc0U4cyH4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6348 The .page_mkwrite operator of kernfs just calls file_update_time(). This is the same behaviour that the fault code does if .page_mkwrite is not set. Furthermore, having the page_mkwrite() operator causes writable_file_mapping_allowed() to fail due to vma_needs_dirty_tracking() on the gup flow, which is a pre-requisite for enabling P2PDMA over RDMA. There are no users of .page_mkwrite and no known valid use cases, so just remove the .page_mkwrite from kernfs_ops and WARN if an mmap() implementation sets .page_mkwrite. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira Reviewed-by: Christoph Hellwig --- fs/kernfs/file.c | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 72cc51dcf870..a747ed95063f 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -386,28 +386,6 @@ static vm_fault_t kernfs_vma_fault(struct vm_fault *vmf) return ret; } -static vm_fault_t kernfs_vma_page_mkwrite(struct vm_fault *vmf) -{ - struct file *file = vmf->vma->vm_file; - struct kernfs_open_file *of = kernfs_of(file); - vm_fault_t ret; - - if (!of->vm_ops) - return VM_FAULT_SIGBUS; - - if (!kernfs_get_active(of->kn)) - return VM_FAULT_SIGBUS; - - ret = 0; - if (of->vm_ops->page_mkwrite) - ret = of->vm_ops->page_mkwrite(vmf); - else - file_update_time(file); - - kernfs_put_active(of->kn); - return ret; -} - static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr, void *buf, int len, int write) { @@ -432,7 +410,6 @@ static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr, static const struct vm_operations_struct kernfs_vm_ops = { .open = kernfs_vma_open, .fault = kernfs_vma_fault, - .page_mkwrite = kernfs_vma_page_mkwrite, .access = kernfs_vma_access, }; @@ -475,12 +452,17 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) if (of->mmapped && of->vm_ops != vma->vm_ops) goto out_put; - /* - * It is not possible to successfully wrap close. - * So error if someone is trying to use close. - */ - if (WARN_ON_ONCE(vma->vm_ops && vma->vm_ops->close)) - goto out_put; + if (vma->vm_ops) { + /* + * It is not possible to successfully wrap close. + * So error if someone is trying to use close. + */ + if (WARN_ON_ONCE(vma->vm_ops->close)) + goto out_put; + + if (WARN_ON_ONCE(vma->vm_ops->page_mkwrite)) + goto out_put; + } rc = 0; if (!of->mmapped) { From patchwork Thu Aug 8 18:33:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13758062 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2130.outbound.protection.outlook.com [40.107.96.130]) (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 B7B46153BF7; Thu, 8 Aug 2024 18:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.130 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723142039; cv=fail; b=qimJ8uT6v640cnQR1NfhE2daY/lqwSPqyDqqe96OK1WHQ0k5r1hg2wU2OoYVuvUf3wfm6IVWOsAyW9EWAu+vy5FDX8Ga1VWoQGarP7ar060IhgptGBoml+aLZgzRdjCOXzEyABP61qRUL16lw8Tn2UgsoWXYnZ5cYb8xdgKod7Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723142039; c=relaxed/simple; bh=IS5k97kV4aZ+mFLbmqY5RYA47xnvX9Etmoc0CQch/Tw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Dsz7+ZCko5hCWdO3fiaIG3cmqm8JTHh9w03kFn4Z7Sl/ft7lf4m3DFK9uPSTbeUjhlgEnNxcXpGeJceKRHNAFq4TCw9Hy8bO16qPkJkm26sxBcLsbcLf8XK83RTqKJTNxAWXBvU2WPdRt0bgbpOV0jDY5ESROrkc/6vz9xShFiE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com; spf=pass smtp.mailfrom=eideticom.com; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b=JozcmOKv; arc=fail smtp.client-ip=40.107.96.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=eideticom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b="JozcmOKv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e7iHeB+gO8ENeHmXvNMmqHVBDMebuXMQGSm6FcXwYVeVh9dkz+YvrDi0cT6aI+U+iRM4cJ+J5ZvnHPZLh5WpLyftTVu+zAqHLYGTLY4BqL2GoUu5EcqCQysMQloRcQ0Yh9RkUyjMBNFks+9bNrTKcQlet0kLpeU6NUjKzKV9jRhqmGtiLL5Xpi/1D2SzN4rb4wyeCFjGVnv0i783W8zf7Mh/SYY49FHUPH7a3+p4wa48JHaXoKUneJDBGQqeoA4nI2hEym3D2lRHNsZfE/AGdfccGrehPQmyycy9AW7HdRBlLEeiwOO1zK3x+IcjGlCaevCraVngXSfd7qehpYOj7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wBSqvI5dXaPzoETqbPOnxc/+b8+MULNZC8MMNCT5Abs=; b=gm9nTQmS8dKR5w3diNeHpML0mfKV3qidbZ6JFtxGiN/iFt7g21ocnDIL3kdmPmnhDTZrsftO0srP2SnfdXsF94C79uXvYLr4D1ecuXMe26WJN8AMrJkNiaxQVJQ5nLgQ3Is7g+W1ZRZrB81JLmwjUpqig3ksqK8pbKihLRKpFT0qIq18IIbjgrNf7o01cjtOhgHimIEZ77r3N5GL0SuRH6NbovGWU80ukNYy157GEGyHt0XVQgZFlFSVuN4rdI/f0Ts0aVhEIOM1W7wUUfHQ1exc/O6J01QQ3bvGK/R6FxFSsB0EpyNf9wG2GRti3Q1daO4TB9nd2OaIQk4+phKBqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eideticom.com; dmarc=pass action=none header.from=eideticom.com; dkim=pass header.d=eideticom.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eideticcom.onmicrosoft.com; s=selector2-eideticcom-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wBSqvI5dXaPzoETqbPOnxc/+b8+MULNZC8MMNCT5Abs=; b=JozcmOKvyz76ll7oNloZENONSDfQsNcyGa37c8IyKEOVqTJOzmllOSvqxkzTKU8SBfShrt0QpbYU5Cse19cJjV7YvmT5+noIZs12d2oT1NFqkUj649glfXOMS3a3eFkeAPQf7L/JfMta+DAc+PuqgV0cw3eY1MUhFHWXr2cvax0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) by IA1PR19MB6348.namprd19.prod.outlook.com (2603:10b6:208:3e4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 18:33:54 +0000 Received: from PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849]) by PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849%3]) with mapi id 15.20.7828.023; Thu, 8 Aug 2024 18:33:54 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , Artemy Kovalyov , Greg Kroah-Hartman , Jason Gunthorpe , Leon Romanovsky , Logan Gunthorpe , Michael Guralnik , Mike Marciniszyn , Shiraz Saleem , Tejun Heo , John Hubbard , Dan Williams , David Sloan , Martin Oliveira Subject: [PATCH v5 3/4] mm/gup: allow FOLL_LONGTERM & FOLL_PCI_P2PDMA Date: Thu, 8 Aug 2024 12:33:39 -0600 Message-ID: <20240808183340.483468-4-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808183340.483468-1-martin.oliveira@eideticom.com> References: <20240808183340.483468-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0072.namprd04.prod.outlook.com (2603:10b6:303:6b::17) To PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR19MB6828:EE_|IA1PR19MB6348:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f15b87d-7b51-4821-929e-08dcb7d8a83f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: ljTw4fek0YiKThM02yRvlu+OTVvwBSWQyPHsXATUsNjn1zHABDYKi/vI6GVe3meNuOjNhiDC7t5mGYBTkJlWKQW5z1aGR01d1FISnXFfTAvoh6Tlpf4ItUHHJkS6r+DM6O20zBDBCjLsY7wFgH8fAzgQn39CTmGBPGt+C2NR2Sg+bpvZMr9OCr2bv5BQ0TWit0FEbTIiS+tHbzXRYtSmaBoaBsU7CLA0V5jNQO2GB/iZ6HfMEyMUGR55PRk0gl2aQMbAjs8vtj100zWPagqZwAPU4ZzeOPYKfTGnJqtttPwmn6gOSmE9FOZ9MdU+VfaBvQiibYFko6/RtWiOGDHtqBgf3xVq9F4/vsqo3zJjR95mzxoWh/HOhVDLGRgCHnPb3jbdw2jTlR+dzkrrPRuB9FdUTDfSw0BhT0TENmWh5D4ifMPRi+wwxIwfk9b1VWr6tZWZd9TEfilgCvlTq3/bcmTzMzzDZLORVj50oP3ZRpyvAQE85NR5Gm9WGTguSMbgy/zJVMS7ywK/nT+q9StIifkaQcdX55+aU0kUNN1N+sbtORgUUrMQKwIaqifNGd0+favZIxjSZH/fFiAQ0MwTxbRLF96YX5JKlw+QDwRURMW6xyXEyrfmurPbJPRvfzVIMrnqNHjEgkeWpQ3OCBPMsnm3mZwNoHl3TDWFikdFCQLIDa5ieN13wVPiVzWwEsDUcGdQ4HAO9hVPtXmzyeLABsQOejFfqml4RlbTdFUUdR8V9OKSqVRCpjFKidSOg84m8XTqtvy4vOxMs3Ap61Qm8CqnQ5bPa8nANrWqL5O9xCryQStISybw48KpPHgRYHf1HM//XD8hNIc6VxcFcWZN6RC+SUdmWuj1oFf8J/sB97Os2YCy0TfeSbg7eJbUwMnue4ECe2D50ArT7I66WtmI04cUTB7Jbq9h8agY9KCgelxxPG5A5rT8a3Z8punJyCrMQ24Qq8Ec3kUMwmzuD/zBnQxs+yAvQ+LQJwszQdcPGM7ZH+25hIwFLYRvNANo6qb3Y/V4bwJAEQrOp2aqIMSQWl+CbyR5SNw0YOYsM0HW9KsLZrcCpWJXbT+yLoSuRDXes2GwrLWln8c8XIsJtK8uXKxSIxYJ5bb5VjXfQeZLZ5iUtsJfxuL0kgU0qgH+luCvOf9gDKDMNqgXqc4hdbtc1HSPoCHkQ6MYEf8gJKwR+MmWI5ZJ4BRai+AXQ83p2QAIw7H2HXIXwdUKwmGe8sldhZ65gcLp2GBcbq8jaG0N7cf18vTeT1bpYpM17YSBNzGywDi5bHglaqKFYQRTc/385MaKkowYfiQzWRYTeTqBpKfrL75lq3ZKPl5+R2RQmWHJt0LfcpTlkJuhfyWR2LWzVoFutOjTqGEszZZToxu08UI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR19MB6828.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IfrUkY+Y/+ZnKAXpgWCkpPSuEnaEUuiOD3MGAbZLeVp3jkFf4xfTSbDLPLoKqFIET+2AU/A4QTjfOE7uJzk3mlhgbielDAnH56v7Afq0Kg3XBnLw0B5zlu/d0PTZw7qGIN56NKqaQvLX3j/fCm+ZfHQWkfgfYNCXyNrEKZwmVU3pMK1WzoUso7ga0xtJrJMDkUXuOzmou1yxocJ6LeSXfV6Rkmukvl2LztpDrQvSx123ZjtplgVeixqUCVbAJa3EAlt3MhbJ6FkYVgR8ZnCEC1sR+RY/2sEJ0fQqNwMP/6opoSPXJolqOwFJC46eAtyQ5HddIot7OO4Gj/J0S+u1j3rVgqcoZwb9Z3C5BCB19GrG+9Z5tNeE2FXAAl12+qNx8NWyE4kTv/YBdcra3ZsGDZap3+NrhLjMz1TotAmBLaXLgn+kxQN9PTYTkv5eFdgDVvTRt1zBu26U5cdN1/2w+xKkbyEg4H7W76qV5Q/fOnOU5HF2BPsa3Wf9LljJNgCZntmhLeJOqjTpsPyeJQSeD0ZMSFwm7dgx0pprjmFs2ZxWYVAYbDwbDO/JTizZT7s8i0ufUziOn2U9+d3i1xkVyMUpXkurkKEWFINBujpCQhq8FAQZ3wpnbRrxPnchEomuyM6HipRvtz5cAeXmt5+NXByp3NXn4rl+aPSe38c7SnGGZ6tcjewDLHzFD+W7X5NU88yhQFz5RASD7M5PG40fIqzfCjGevG3m4rmC0YHGiPwTJdh/TdGwpVZpqbv0TKZ2ZoADwkOY9jb0zzlK0N39Q0yuaHkS/QEAzzv3Ih9r4BoKQrPkpKl/JIJZ6ywtGc6bdKWq2hfrUgOE97G2p0SCmHUq35+Pfg1yBnpagYHq0gqsjThKBYGKWz7aJU16Ek4lvDQ9ynq95DU7GfNGnB8ePhMmPjQclRCXl0mJbbh1jRiqh5x0DWyVY3X/3TkpbLjMrA9GZ43Lxuaqsf7G2RSWLepIa9nJn5yZuKKnDNb+NK9TMetiubPAzNW3UMlNbfYN2aIVzCmC+gLZ6LOddVfW0NGTDiqttWxIAPATAlHDZvu/hGtFuaFV0VXYI+WUYHUWLQyFNChP0cIDIn87PLhRrfBNjCm88sz5KQ6HG/tCbg9KbM61mVh7A01mTXdttybKjZi8XlxBr6/ty2nfdkjeBci2kInARs/4khF3PLvJ78hNAJVQJUxEeolPLea1PBmZ0OBMM6ZyltuECBYOcUN9dP73JL1VRFlzAFjuPEylX9SmySnpfajHYRlOD7BZS/jJFMeKJ8ZDRRjyDFrHcop3WQgElyDXEFJmP0Joe2nBQIAGCc0lfv5vcVjww01PHRDOJHzZjIASHIYgr1cjHWUQq7KHMsJlPYXxzmxmaYUll8KhUizjtO/I4CTV4w62sboOyZtcpQENHg+1EEWCCUBT03o9aU5xGb5BB1AXEtZmt1jw4KZyB1y/u38SKOI2ZfPSkp4fmGbnBXD8lV1drNXKF1WDLa2NRUXJ9ldVnpgh94cltrgBwzKbtU2N9v08N2qBb7ucQ3shvk8hut7DAVzEElYDXS0BZ9aXH4820rs5fLdWSKr3vg0qFVYMCqvB1TU3/J2drgfs5ptSX5suhL2tj1vRwvH9u3e2rb5jWKJ4488= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f15b87d-7b51-4821-929e-08dcb7d8a83f X-MS-Exchange-CrossTenant-AuthSource: PH7PR19MB6828.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2024 18:33:54.4761 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3490cd4b-0360-4377-abb1-15f8c5af8fc2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 75Bc8jM1rxkkdoKhWtPCyhLbSgyZ4DaAz06MBYv8sb/txD4peWOctwkdjxgOJ3509TXhJXCFcnsA0UsZ391Z+7/qPcMMGEWcuxJ6XyIV1Y8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6348 This check existed originally due to concerns that P2PDMA needed to copy fsdax until pgmap refcounts were fixed (see [1]). The P2PDMA infrastructure will only call unmap_mapping_range() when the underlying device is unbound, and immediately after unmapping it waits for the reference of all ZONE_DEVICE pages to be released before continuing. This does not allow for a page to be reused and no user access fault is therefore possible. It does not have the same problem as fsdax. The one minor concern with FOLL_LONGTERM pins is they will block device unbind until userspace releases them all. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira [1]: https://lkml.kernel.org/r/Yy4Ot5MoOhsgYLTQ@ziepe.ca --- mm/gup.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 54d0dc3831fb..df267b7890aa 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2547,11 +2547,6 @@ static bool is_valid_gup_args(struct page **pages, int *locked, if (WARN_ON_ONCE((gup_flags & (FOLL_GET | FOLL_PIN)) && !pages)) return false; - /* We want to allow the pgmap to be hot-unplugged at all times */ - if (WARN_ON_ONCE((gup_flags & FOLL_LONGTERM) && - (gup_flags & FOLL_PCI_P2PDMA))) - return false; - *gup_flags_p = gup_flags; return true; } From patchwork Thu Aug 8 18:33:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13758063 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2130.outbound.protection.outlook.com [40.107.96.130]) (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 6F97A13D63E; Thu, 8 Aug 2024 18:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.130 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723142041; cv=fail; b=pJY+5wA/4wdxuz6ETR160azdp+lX3mw0DIP5OgHNN6rMhfSUo2JUWEBiLNPLdccFCGR9yJt7Ji6tWfjdcWGA3JNBpVPZeVXixl/NOIrktrDtv2sNQSTGaSaLyoult/1vV+jrzAX6AfetswGf1XAvcsT52Wi+IU4ET0+3E58iQTc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723142041; c=relaxed/simple; bh=DAJxoPvAhAmZO+nhmrqzk2QwoaGJG5l4HRJIVEMfJFk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=AZfFRG9hKe/gGbJEkEgoqgPQrytKZmaegWR33JUnnPNcj4wAm9VDcHMMzg9rfrcBchUVc11NqAE8oBiYe14rloFQXmyKqcVGy3MQS6fhlZSuYN+qX6EXfjv5oBCf96ZEQmBJdOZ4E1tnzwj26j/th8Iw0qmjsFiJhtawGOvVB2E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com; spf=pass smtp.mailfrom=eideticom.com; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b=e2SwepBc; arc=fail smtp.client-ip=40.107.96.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=eideticom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b="e2SwepBc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NBth5Ki4owJPn3df35ss6Ii+bPwPaxuWZ0/HzNxtUcyTNKtx2i9jvJTtsxtSOnVg5soj7HmRcUmOoKI58b8g8fCALXKeu8W5M220hf+BbQc346Ey1gFMIXnRA5+4ul6iyMC8TiyEA8bUSu+/nRs/5JhrU3oDo+D/Xu2+6jHd703ePSqEE3qFeT1YldytyWqjHfu9SC4MHaxBo6IGme4FMbaCp+ni2Ec4+EZDxlujv/uNi3Pipr62R/iqqppCNdponJkDajtJ9SSPskkFtzeHyWCcKdXo5jW2IdfugqifTqluExZCmRpuQDWdYaVQNDuaymHlvtGMMOLPi2p+gULyyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kM+81ayAtTLFvHOakRNJe8YX626jXBDowTU0GcX7MMs=; b=KSt+7Lrr4HdS52FAwBYoARjzYMD+ITrvFDRbm+qgJ+GWmT2uKQDqxVXFHqCPMK3rdbXytompydINjhxZ6UZYPqNCvlOlcH/gucQ64NBvwNyOFIPdjY07GixIDOd8cencQ0oeS6jTSvpvwR/2fCBD/LCmyINAplfT02+P5r4t11q1arDqRfpXBek4irN1yI70+4QmsAMGhV/bwFurryZHd4cY7ijn/WZGk/81qhfKyzvIxSLCEHrA47Uo70Mb5LbwTI2yIEqscLMCbZ8l6S5ddmMsDu8RGChKxP5O0Q8gDBQ0FJVEw+eQ/uRI+78l+fSIxsQsulGWztgRYyN+UbqurA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eideticom.com; dmarc=pass action=none header.from=eideticom.com; dkim=pass header.d=eideticom.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eideticcom.onmicrosoft.com; s=selector2-eideticcom-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kM+81ayAtTLFvHOakRNJe8YX626jXBDowTU0GcX7MMs=; b=e2SwepBcGIAeoOtAr5+TT22sQVWqBlEhAtqG2Xlw8Wd/7rP88eF5Zkf4VLHj/niPnqnuVL0eECSrdW5eeAPxuWmza4w6ZXk+boqyzpQIBfqj6fG2lvrOjq/nGGdXNFF6bXZIzi/m4Gq17fAVLUolWycEWTqh2BTfZp77KfYX+/E= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) by IA1PR19MB6348.namprd19.prod.outlook.com (2603:10b6:208:3e4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 18:33:56 +0000 Received: from PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849]) by PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849%3]) with mapi id 15.20.7828.023; Thu, 8 Aug 2024 18:33:56 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , Artemy Kovalyov , Greg Kroah-Hartman , Jason Gunthorpe , Leon Romanovsky , Logan Gunthorpe , Michael Guralnik , Mike Marciniszyn , Shiraz Saleem , Tejun Heo , John Hubbard , Dan Williams , David Sloan , Martin Oliveira , Jason Gunthorpe Subject: [PATCH v5 4/4] RDMA/umem: add support for P2P RDMA Date: Thu, 8 Aug 2024 12:33:40 -0600 Message-ID: <20240808183340.483468-5-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808183340.483468-1-martin.oliveira@eideticom.com> References: <20240808183340.483468-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0072.namprd04.prod.outlook.com (2603:10b6:303:6b::17) To PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR19MB6828:EE_|IA1PR19MB6348:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d2d9e41-c152-4c08-bca9-08dcb7d8a921 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: u2cO1CvDeX53TNI81bLQDi5hhFhenPl1bOdoE+Px+QRPX/ekjgYjS1XXUgMPyPGPnblBBotJsrvotqu2B0CuVvSknWM5aGfG3bXRqkm9ahCSsLwl+jKJNIv4b7EiSuTe6YJa+/9ZkmZ5w7eGoyh/9Ysh+12kWNyfvbW3QWLXP3NRorGhMoRhsofWXfpiBQlyeRQPS0uefRJ73PoRiv0NC4fdG6HIbk31h9YseLQC0DcX+mjS6W+atGXtizyTFVRJhrRkmVUw0UgOUySp5LuymMq0lYtOcQYLC5Qr6I4bH0iLbFyGutkiDIO0yg3o1k1lKnIuTHWOTmVKuRSU9hhaNeZoOjybWNq506XCoPECPOTJV1Fm4xxsssi+pLxk0gxFJPNnnwT4vuGKH1TW7PmPQnJZmoFDrOXCn7FMC2n3CvOBHmBLitlZY84WqiJlPhnuEUFCyfuGbHbPT50w7dteiSgiO3+2ma9Bw3KP7autFN9mltQ/N1DZYkX7B5DemeSLFYrTnV7gFjFveAm+J5KFBK5yZX0JmjBU121dafUItrhZ/Xv4iwhZtdem4GVcrDkawHOiLhgn0/jbUDkDdG4vrLxNFZV7oIMDOzFju2YFiTLNuRw5C7yXzGX3vP/SacSYF+ykczDCZOy4/Tl6UU2320lUh7VHgEqYvOpMFPjuC8JPt2v6y80VbcIfyXT2jdVmxV/kcOzgCUV2FGXOo9BZgP2dTaAy0ZYoREBe12zWNc3sNtU/GW1DTpHDbz/sKR5Hh7jPwr7bJSh/NYDYEhPLKssrJVcbv0hQ3MLY0SqeY9KvclIR5IhGDezW7oVIKa3uWObmIFeFBVn5bzqdrMbFjJjc6b2yRBL4YTTIS4UclkOtt/+HGlqMgfsxIEXeap95m41qr6stUA8IAB3tNfn66UnMOI48ztOtHdcRZ+HJguC7DolInmAC+OBAtRihe2Tna/0K94mDmm/jZJApFN0MwERTkaA1ZH3hmv7aOJMu5Eg74xVipUH328Jp+52XPVCr3iqRMI1K4wYV4oJdU+rh6e+NAbojAxOJDaqqCLjGUe5olX3cL+S9XA6IIzf0Je6mGHqSzMOTSLNqrjY02DVptpFJXST8YlpcsEAsZmEtFDMS36sRHdTRDmxaL2krZ3z5waeM961RSjE6nH45lS2NYilCPpHbt8gfhQ3UOk5ANq/0MdQHh/+Xd0FwW79ak+j6PijiPIMwZoV9AQSoDVggn7oQP9KilYtxZwuAm3yOjqXuUtXdCif/RoK5Of0qPLKE7ahaOKIeHjmXTZ8OHDgcYrg++6KOQ05BnMufMW4bAk0NQ+zDsNVZEbmXpep/WxkRhMmaNlPwLdbOgBlsyO+o42TA+OJC0oFfVlCotn5gD1hHNKzHMQPn/u3Jz4xQR1iNCyDUA+yACdTkT8cJVEhPJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR19MB6828.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G4AoJDchhPfOk7tlSGE+qTcMOCpjdP7Xnb/Ya163wV96hJhOuQ4njF04LzQY0okOFa/8qzb8mIMAASVI0ZZexqkveh3hbkukWtaUN0z2TIU2KrsjLfmo+0NPr3TL/PSykOqnmRf99cJmwgS44EdP39h6SEjY1Ppux+M2vejZYgIrUz1P2sgQblFmsX8vkt6BrYNmuY3UdwUw2QCWhjOcW+fHy3vTE0ClIU/erK9BiArgNoKals/nrypwK9iTs2K2ewJfLlzqDVsT3I/7bHr6ymQkJj5YdtFT/2P8OuaouWHCzLUS0of2Vvh+G3Y2VfiWoAy+CYJvVJQ1ANHiJodH2f8nC2wdCxU5d1xkzQZNzzK2xeJ/QIsuOjShbjRNMVR7mWfenIjqVQ0u9eW2sLCIQQcNF/SsFncvSHplMi2seAqauJBmL0BzAk8tN3xm6RZfa1N7pKA0lx2wZOKlayvOsNtw52hWk2cavsBDqkNninvaTukAlEeLZK9KRq8unE9gelSK+bZq/B30GFyqeCw+kIe2aTWKRO2EUG3kpGEo/o+mHj9BK8mgi+8n4aCZn8zLa2NTeU//EdufHxG1JIubwR5x26HKUJbGlNvqBy5ZjJOVkukvP1XDuv9aHFPoAABBWRmmyZgvnjErXZEK5uG5d59AY38G/mIgGB6Rd0ODOOytpvzHRVWLNe3s6XpkPQRrS2bZ0MYuHuAYwEODqYR/y43IvMPeDpnIw7kMv4Bsm4sBpZ/cLzcJUgQrRr78JwNj9SpkBALbV0USqq1x9eF35qk1wv5dzlipS2g2W8dnLK21tYkVukg+Bu/TjfloSClMSwT3W2XD9Xbhv6+BmD34i94yqOl8iiZ2Slh5YykDjllIG0Oud9OH5MfDNAchiEEub/memNsQAfCOEpyGs8n87+EKeZIw/kp5VjXa8lBR1Ukvogz72DUXRSO81Kpa090xb1VZoddN9TXCeB7ufj0N4GT9OZy1isL39CUZ+9OcTcBgAN+G8apfUwppPIVRe3e1xc1f4lMZMCg1gJVmSQjL9D2vCJqoaKKrNstqxcj52obh7y+TQc61L57pG9l0zxrvHnWvmysShbM8GMWUlA0gsXHDwzRLJe1Mfsl/NvOSaonnUvgsHlTmmXiIWX/YSWVJgIqO7I2jesjUGsKKvxaOOYeKI47cwc36h4CXPCNqGzfYIGbEACSQQxtyqjsyCUJgyCtYT5si12aqO4i5ZmuxKJOuLSnbPPU+03Jc77nM+tOQAPYAcHmy9BPF6Xfn9NeeybEQePp4JFdkDi5vOpd9XjGv8nxtRBxvT9msususAi5244m/1gsjwyUigqaffjkGS7QOFCjWROGzJx7aIRW2Xskc8H3WVJPzqptVlrqRek8O76CjA6+m2xVRTPIzncBu+rcyNV2wlP5BWpc88eSXehX4zgrqhnLEpiha1uYBiNlH1OGNCGqHVg0s2dm4KsKhAYVPguX813EtajbmlUMm8tHfEnvgrS2XEQV0dBarPHwBf1UD/0W4h6aJp2TLzKOzbRiyZSTNte8ronjjfofMS4x9qVA9+n8WAuzmITZsPM0WIwr/24YJWlsxyUmYuxXwA4bOJthPgJTXskQY6Vmf0zPWmSDn4MCK8D5Nv5GXHZo= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d2d9e41-c152-4c08-bca9-08dcb7d8a921 X-MS-Exchange-CrossTenant-AuthSource: PH7PR19MB6828.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2024 18:33:55.9963 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3490cd4b-0360-4377-abb1-15f8c5af8fc2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iJqWVk+jsUd30CvrPYOdskSZeE5/eHtjjUITK6vp0O5ci4VQ+p6gWPPq8kOij49aDmNnHSzLseG7Gn1NYZt9lq9l7Q5fB22DFTlRjAw4fGY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6348 If the device supports P2PDMA, add the FOLL_PCI_P2PDMA flag This allows ibv_reg_mr() and friends to use P2PDMA memory that has been mmaped into userspace for MRs in IB and RDMA transactions. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira Acked-by: Jason Gunthorpe --- drivers/infiniband/core/umem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 07c571c7b699..b59bb6e1475e 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -208,6 +208,9 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, if (umem->writable) gup_flags |= FOLL_WRITE; + if (ib_dma_pci_p2p_dma_supported(device)) + gup_flags |= FOLL_PCI_P2PDMA; + while (npages) { cond_resched(); pinned = pin_user_pages_fast(cur_base,