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: 13758052 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76A81C52D7B for ; Thu, 8 Aug 2024 18:33:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01E546B0096; Thu, 8 Aug 2024 14:33:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F0F106B0098; Thu, 8 Aug 2024 14:33:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3BFA6B0099; Thu, 8 Aug 2024 14:33:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B44D06B0096 for ; Thu, 8 Aug 2024 14:33:58 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 134A4A1601 for ; Thu, 8 Aug 2024 18:33:58 +0000 (UTC) X-FDA: 82429927356.18.866FF83 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2102.outbound.protection.outlook.com [40.107.96.102]) by imf08.hostedemail.com (Postfix) with ESMTP id 3F616160019 for ; Thu, 8 Aug 2024 18:33:54 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b="pCt6/GQM"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf08.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.96.102 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; dmarc=none ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723141968; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EQhK3ka/BH1jfrlP7Pg1JtnFuCDr3tWdul7G2/wv3bQ=; b=POnSUMC9z1wmNXwcHbm6xDizxtYXx6u8XZX/7MMyBN8z1u2S32xGQTsDFyinxA207l9K+S UwhZ8ysA/HBapJvACi4jlV7jR/eNCmEENEa2Mx73trEUfAWtJfEpUEiF4YstJwIaInsfn/ h1WEWTzCeuQS0nd5yRvbyMPFdKVu5j4= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1723141968; a=rsa-sha256; cv=pass; b=m8xB3A2+8pH/5iCo9RLjK4iuXBvYWxvc12OSA2nZyT3U9FxNSFsKKoataJGC1fu/3GNpAO DdLHlucUxpXQjbXpyX887BXc8HaFWmNJBG9EYHd3iFnUlfxdRk6fCjkJhdCZusDSMjue0C mrxYVVyIRV3KNx4D+JLSVMgZu/JjsG8= ARC-Authentication-Results: i=2; imf08.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b="pCt6/GQM"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf08.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.96.102 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; dmarc=none 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= 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) 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+oSG1BZygGGVjTYnA6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gWkGwzMmMBHGUFLlOovQGjqJz+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 X-Stat-Signature: amhm669qq4yya4myqnpicsdrnypp8jgb X-Rspamd-Queue-Id: 3F616160019 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723142034-783911 X-HE-Meta: U2FsdGVkX1/vrrulZdmiZS5oqLGGdGUxQ2Cb97470XjyPZuvFLDFCrmrpteVQD4NnjWq5SYVKL8SkdwChfIb/oiSszBiq2W20vo3ufzm/xl13xiNuKyBOH5STuQFt0LNBYirpXM04jU0dVSwxFC2/vookFaTqCFyUzIsadk/ZSNwSlZymXCb7+Ahs9Lxv8bbYmtHYzU3OIZSWvwJJK2MEAl8+EbH9FYj1nYZcdMxA3VfCg1vrslwS9fQcONu0tnAUv/ZYBW0pppIu6mgmxSEXnjk7QZYTpVoTux+BR4G7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hGo85RHk0LQfYC12PSTCI8fn2eUFdw9xwYlI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13758055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8C70C3DA4A for ; Thu, 8 Aug 2024 18:35:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C50C6B009D; Thu, 8 Aug 2024 14:35:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5743B6B009E; Thu, 8 Aug 2024 14:35:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3793A6B009F; Thu, 8 Aug 2024 14:35:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 180016B009D for ; Thu, 8 Aug 2024 14:35:40 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 92172C15E9 for ; Thu, 8 Aug 2024 18:35:39 +0000 (UTC) X-FDA: 82429931598.06.035195A Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2115.outbound.protection.outlook.com [40.107.212.115]) by imf16.hostedemail.com (Postfix) with ESMTP id CD3C6180018 for ; Thu, 8 Aug 2024 18:35:36 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=RB8UnFDp; spf=pass (imf16.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.212.115 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=none ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723142127; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pRUDFAbvP4Wci+R7KuxCrccwPqV5quWpHJXtfd77Uvs=; b=IAxS3ucOE3OLZ363TzX1emmZuapS/B4506zszi8qJS8lGdhmPmvsx7tCun/9wjh+0MV0Xi PSf7aANrsSql22Bm+diU0ZRSae2YOp1RRuodz3Am6SQUze6BVAymLh7zJDGHCoKIzegj5P PDpFgN1fmOMsB3Bi3iRW6YD8ilYl/6c= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=RB8UnFDp; spf=pass (imf16.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.212.115 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=none ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1723142127; a=rsa-sha256; cv=pass; b=Z2h/L+Un7IZmff+WtRktsNM/MdLtgEyD7i1S52EOXdEPCrahqSNA56jpUl2vVKExhN1qox 3rLDw6248bylU1KU4VY+zmwexyrF9Wxhyz3aZt06BVmCep4Xe1Z80ejypda7Lx8dNZJfhL 7tFciVMonlQ39eIgsNmYCiJ3sTS/yvc= 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= 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) 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+3px6CpxFntXWs7IfVF4GMYF68pk4bbnsHGkGpd9ZtZEULgBZKESKclQ3j3oejLIWGBeUt7W8xj7sm5ovBQSowf3AEnPg75KZ3PGHQc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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 X-Rspam-User: X-Stat-Signature: fwfjf96wd8tdd3faetyruchacjn1azp8 X-Rspamd-Queue-Id: CD3C6180018 X-Rspamd-Server: rspam11 X-HE-Tag: 1723142136-169659 X-HE-Meta: U2FsdGVkX19MDWW3FY2oYWFqvejvNhBERl3gQJ5q3IgJV4DirSm27dr9Hjdrq4qn2qIlY8tC2dwmsJrWNhpayByF2sUOtKawi8rOKthAZLVnirjm3WF8YwHfY1zW1IX8P2BLgSpFvVJ5SIye67EOa3ecX653gSskqdF0ohUq+rqu9M9f9Cdlr9tJmRGo2EK1UoXkE9JzPuO6bdwVNQ+Y5RX8T/BSPDYDUep4HqB1B9M/Z2/Dv2PCOY+hZhPqAQZRd80X7aTHeP+mSC3EMK7YPklxekf9xp5FC/X1N8c8ZxL8clWfn90B0PfzC8DvvCHtfQliMArhKV5bR3X1guwR+1SwWPfJh4bZNAXPOuq6TceDadPabPGshpvDCER8zckf2mez6jKDxOdVZkUDbgzaJAxT6OnKHLqhN3tI51WMUu8soJTxqvQwxpWNZE2RbknrdennJmsAkfV74EiWuiGeN33bpW8DzyTYtmb+C6UhZPVZJZn/JhggjIBub4VAjS7/dUNpLpErT5R9i9x2cDtWz8eGEYpTqBurShUmHaPAg0P4eTUBh1FEW1eIdRBIvMmy/4SDh2JmF9nQf1tWxOabIBahsE26Wc8xKKZOzCvxRfFbS8n+ZlOL8FnUvB/CEBKG3flWmQTrrTzJK3xMKd7SLAqklYfVOOGL8d2YUbJtThVCUWVYypq4BM4atzqu/no/KT8DfwtlVFP+MCLIIqpCsGYUpcjd+QYCyIDhCOydhkZ9NYYg+X1R2xO+8vfutesJYBMSxhKdsRExjDOf7+G/rpNIRSblMn/wpk9SU+ymF4rX+s4huOrHZLtDyr5/pcAKAJx3glR4uGnBhyx0HfZ/YAzBQjj3rYZoox7HEb/8R/RPJiXFQm58ZFcfE8s2edCYAGZ9lhc3vcx31uyDRMqBWj2RO1gUZAk1UTvI1NtLItVHCZ4F0+v0WHJDxWK2PHKrTO80w1vFhzK+TtzsBe0 +kSsAYT/ KFj2xYge3P/+LT1922Sz2KOlIletHJtKzJZmhCG2W36bvSu+xwpEPbAenfc0DPXNYppkYBm0le6LQiie5KF4MnE4WHzRehWrrRXtdfF6xePjXLDOHW/WLEwYiAfZS5u4xZ/HNbwEQZb2WBQaUlTtF3FZ95iHmfZSPcSxNED+ikqjpLcsVqoAe4ByGXndgrfuA4jqIesAdFXgJ4vR9Eb2QM3bLnFc5Okm22KtgLq0tV7fj6/dchSojNEpQhKPZ4METtIopOVtRtFwAiDjtHDxdHchJbeIZ04xMvqeFP5Pyya6s5z4f4AS5nSk8lTSRbwHbuR6kTJCTnAOV9THMROlCOBqnurl7UaKu+7umY+B61a0u8ntmQTYP2Z6aUDoAi2YLL4rHp49t9Z9oWhI9RqY4ZY/M6MniWU0mEb/r+ppzdJ1cGqCgK1dMyQKS6KwoeHARwmleE1nfZWygCpvQRqVB7mMs2A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13758053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A87CC3DA4A for ; Thu, 8 Aug 2024 18:34:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9CC46B0099; Thu, 8 Aug 2024 14:34:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4BAD6B009A; Thu, 8 Aug 2024 14:34:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C78416B009B; Thu, 8 Aug 2024 14:34:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A1DBA6B0099 for ; Thu, 8 Aug 2024 14:34:11 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5D6C91C4DAF for ; Thu, 8 Aug 2024 18:34:11 +0000 (UTC) X-FDA: 82429927902.19.808C9A1 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2128.outbound.protection.outlook.com [40.107.212.128]) by imf25.hostedemail.com (Postfix) with ESMTP id 99FFBA002A for ; Thu, 8 Aug 2024 18:34:08 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=JozcmOKv; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf25.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.212.128 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; dmarc=none ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723141983; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wBSqvI5dXaPzoETqbPOnxc/+b8+MULNZC8MMNCT5Abs=; b=SNS0vGUB2/R8cQTrPdbeAqEe/pcHO7WsrEBreeMakWLMrjXfDen21/SeOOUHX9QKC/zIdr pbggMdEmCCC2S+B+2yDMGymxhb+Y3AIJSxzT6MspJGsjLJvLrKZn8VOeyAamp1ENY8gjep HEWlXYqt82QM0K4hM3byc3FSKhaQPZw= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1723141983; a=rsa-sha256; cv=pass; b=8V0DwofA96hNlZsPQqTPp2Ng5EaUneGveUNwbzvh2en7q5V8yKIACoe3hHSIeGbFaEMxr/ s0nA1Kh7UWov92FwGmiS5gxRtgYluOw2piLlHhf1IV9q+JEKy4KqL8nTH16TlTWBSrysFQ ran+TlhTI3euggAiyI8XklLG/yQ/Yso= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=JozcmOKv; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf25.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.212.128 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; dmarc=none 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= 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) 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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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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NRUXJ9ldVnpgh94cltrgBwzKbtU2N9v08N2qBb7ucQ3shvk8hut7DAVzEElYDXS0BZ9aXH4820rs5fLdWSKr3vg0qFVYMCqvB1TU3/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 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 99FFBA002A X-Stat-Signature: w5tyjk88s11d8kpba34j37wjyyhktdxb X-HE-Tag: 1723142048-409582 X-HE-Meta: U2FsdGVkX1/fBwozxNDOCRTjmAOvJRkPXejB+VSvGr172AYa+AJD/BGV6ViQUXvRARaukcSoycpTZPaz5A9CB60dyMeb9h/MCUb0d8Zxti29BrWy55JBXyPD72O9LGRN+QdxF6OdM4HXeGEIns/1LZ7405oQxVQ595ID3Ei87tBN8xc0jqCXamXVHYJK6tQv2YCY//YQbI8zG5IdtMjIG+sKlQCCNrePNq+FyTMMj0BphSTzTs6oNgKEaM56Z/6zSyEw0SxWTHGucfZ4AIoAql7EsGd6uEHrMRfTM31FHPhdHzRLPZUpd7A3sIObJgyIyj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CRizYglyILG2RFBmxacN0c+PtNi1wO5wE3lq88kugGNb65B7DzLbsTMie+GbTP9n5hMqsg/4tw3HM96kUb9JJGm5cinYiR1wsn2bOqlgF8u3/mSeeDKSJWHwbqXSfyzO1NNsh3/1oCIL X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13758054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DAF4C3DA4A for ; Thu, 8 Aug 2024 18:35:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B692B6B009B; Thu, 8 Aug 2024 14:35:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B40A96B009C; Thu, 8 Aug 2024 14:35:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B9E36B009D; Thu, 8 Aug 2024 14:35:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7E3546B009B for ; Thu, 8 Aug 2024 14:35:26 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 319B7C15E9 for ; Thu, 8 Aug 2024 18:35:26 +0000 (UTC) X-FDA: 82429931052.14.9F65190 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2134.outbound.protection.outlook.com [40.107.212.134]) by imf14.hostedemail.com (Postfix) with ESMTP id 64BC9100023 for ; Thu, 8 Aug 2024 18:35:22 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=e2SwepBc; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf14.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.212.134 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; dmarc=none ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723142057; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kM+81ayAtTLFvHOakRNJe8YX626jXBDowTU0GcX7MMs=; b=5s8TQQTKit+REa4emwr0yqlfEZLkTHiqE06ipOGnuTM0f73aYZL7MjonAf1rqCSofSbsrN 5fj+Ux4SYYFaJ75PQgHgvw885y09nnsdZ0SlvnxCNODKzMfzE86fzhCydbPvs+gnyYOl7U 9I9g02UnEiKj7tF1huLIVhHgfOZok6k= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1723142057; a=rsa-sha256; cv=pass; b=bmtxEkhjWMpKZfY0zwfyxRIsnFMuh+m9d0A28wGh7+u11Ct033spSDz3T8+oT7o8stgSow Ow8V/6z7VkCLPCkONpyWQIzGUlq9PEjbPGcYv4UJ4bMRaNob/3prFrEOdVVRJWkcis0/ec rbUFJU5IbMY5f/EdtDglLkXdPx1S9Sk= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=e2SwepBc; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf14.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.212.134 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; dmarc=none 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= 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) 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/ekjgYjS1XXUgMPyPGPnblBBotJsrvotqu2B0C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E6nH45lS2NYilCPpHbt8gfhQ3UOk5ANq/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+8n4aCZn8zL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ange-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 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 64BC9100023 X-Stat-Signature: ah5emro5kp9gmdpkjbswmestx8en7u4x X-HE-Tag: 1723142122-42279 X-HE-Meta: U2FsdGVkX1/9+GpXKa0xRMAHM+CQEUoSZmfc7Y/ArSDTDb21IZVmMT0dQfWpqEZLKtB3i2WU4jHrWaiNrl6VTkontFc9gLmZe5etsZePfIDTVDknA+KBF9tuqd8aKtXhPGDA4Qe4cTaiPsAJAy7c2fgx4kenZykxdvI/cmfqhGLXy/QOt15XvRlMj7Rkx3ulkxl5L6ir6yWkN4BSFvhBXmAaipP4CabYN9IRx8SjcnrJUW4R3arvSHZaPUMs+U79nEzPm1VSzqAsLqH3u6J0X82Xh9xqYOj1sG6gCKbcRLc/1UIQOhzIhQMgusypl11SZT85CSMAuioiR9EkneuSkpylPPEh9Xv1AWSuIVfPKgcMgusxJEgGqfzxwyVQ/LR4LwxTDDdQJlGGwirSCBu8jrTgNxVMr1CXeZQtDHkaeISFvp4wKsG0j53gk73ZYIOWzn8xcTy+6Z0D1YtGF95+dUDlabukDHqrGwHszBqhiL342AV15Bh73MC7VH3A4T/OuuiHDsqwSv3ghfgExZ+lP40/8uiUSIu8omvJYiPfvOhhnF/Elj5gYMGUQOgBpUPtrV4GP9mE5SMZyrUis4Z42AfGmJ8JCx2VrhgKKO9kgHZUQ28/VV4zxhF2zXuJr8HZlJkN5BPGgscEbNRUlNOytYRgGO+5sRdtRpH7hUdxI7ZelacG3xJlVyR8D+XodB9OGH936U4HaFhlsxxpepU4BqirLkITzi/MjZa2FRE1ILKOrEGrKTtMYgHJw70KUj3MhEnZ2fMuYTEJ1FjYlDjnd0NdNHiL+gZ+KX3xSED4Fyl6+DjuFodpU0lI8K9SGn6NeHfE/9FIiVvqcdQkpFX/4PHUCcoM7uNUy9yT3rPFjXyJkUTBFGmaWMCSOMY5k5Cjd7i94Exasc6JYCaOMRuCIZLCMv4oDeCR7jH3QNfWRZC8Wpo4DjyD+laAcxNZKpWsgRDlSBhp4+FAIaVaSXz CYaTbkSa iBUO5TZppRjIKPTBMgLX4s1J2RMELa5PlzvQjJkt4LVZBPSZNVQ49UaDclfb40YIqasNWGvMo5gMNK9J/c5U4/rLA2LzhYBucTgB86x6MZd2OftnOXKcKWrifJKHAh75xv5NXUDJKqIZUG9Ao45vTPsQSpEWOffYHS7wrMVHVjV3ONcx5LedXl36DNLSqhfyG97Ux5afHiW5InrFM39ZVTe9dBs+Fi80kvHfdmhYncH4oEIAaVUvLhAqSQ2VXNLeoQ4rQXqvocPjG7kvsqNYE93cEKG4Rv1yt92Uuj7weZPL3mbBBC+Wbjt6T8zuB7Ek9x90uL3H9lLNOIyUYr4t1rWkP3n17PBCmJVBVH/tIIwry4+QtD2cVbrUOablfd/tVR7R7OvUxzRWmC370id6fmsksMvIRwDiFP/z2PqPAIvmgjK5f2TWm1guIzL0b9fmIsbgr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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,