From patchwork Thu Jul 4 16:37:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13724011 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2103.outbound.protection.outlook.com [40.107.223.103]) (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 336A51B29C2; Thu, 4 Jul 2024 16:37:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.103 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720111075; cv=fail; b=HsvTVM+D+Hw7lHBXxBGH7+97G8VXqS3cNBp8CKKzTiPOOfUYqsBN9zdIhNPuf56q8kccEntHjSeqzOdLbRaUWMu/bO6lrxewCVc+VguDaI7Vp+CQEul4M1UQ30nwghfH1HIr3XBHSKcYwDn5dslWCVDKGu7d31f+1sqNeLv4Qoo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720111075; c=relaxed/simple; bh=GE06KucFSBUQ6DohU7LR5l3v/5cc7brxM/fx2G01KVM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nQUTozeG27Wr9OuhbREdzNd1WLi975OxB4k00bf/Nm2lZwYkzGV95MG1GcZobM6HkAO8ATu0Sd+MVARpU5Z8YlKKOf+NfNhPomJxWD7xFHBXi9eVVZ6EeSlxBUZyCTjF4QqAryGKMEo42HWZWZR1pVkOuwzyxUm+1r/Mc8NPVj4= 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=IMtTti/Y; arc=fail smtp.client-ip=40.107.223.103 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="IMtTti/Y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aeH3sL8HcCzwy3oG7rxLA323cVqweH1WXvU26nrl0QhF8VPEZI/kEDqbgwYEsoPKXDX9m/VECYUSXXHRq3E7tByyYvUuOrdh/BvfaQikq5nmzKiLxxYfdJc1utOjMG3fxkGvwWvnq4PzslIi2dq5lg8aOQhss7yBAJdkv0fI9jWmDOVgWNI8Q+5pUkDBUSosQg26hNl7yOt7fZtEnXVuH+dju2r01Al1ioNwuBaR3Hhz0e/yNdBGA2l2jcN74iIJxAWynZzreIQK+mOeZrwnOfCuJDe15EbuaqgEyfqw+nPLSk+VC0KT6jzPjL//HH8ASkoVeVZ9rOrihtUGcbOj4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=E9xpThQSwDqFuSjjUacCMlYFqVz7Hv5d66nL0tsLOEM=; b=UMSfxblBFOQNczrUnTON/iLCbVawFCTYInaqNR311rTD07nICPqFBEPUnwgI9q11vt1Urqq//wf6L1QOSW4qQ5z7icpVi8uEfgexCal1y9OJxpXgL6uzUpIzyv9U6H36I2SwocIeWqRZP+ykTD+Y+ZxZPLL6zgdjNbOs4+7sQWRg78vDyvSgQbo2EEFTH17lvSBm4jMXGLYvrtUc164xjP7n73ruL4jHTRtWyMwzlU+hznaYt0jkHSgxdhT8+gJf5dR88pTyPlSdPwpUuG8SJCP4jY8iKudrLFkAX+cylN8JzNGDGR+NC8B5J2nio5pRXeT8aSN8mXzYNUxa0tZPyQ== 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=E9xpThQSwDqFuSjjUacCMlYFqVz7Hv5d66nL0tsLOEM=; b=IMtTti/Y+8cKQwOWumy3CbRSLFo1b1VI3gUFVdazkZDkm3+8ALaFrLDTepkRvrPA21XYiOYmq8ejcdpmophHyRuSGW3HNJVcoM9maaN19FMbykLErto+dqauWwsw+sVS+XTztD3Waf5f74UMFh3AIJkT9ts+BopNC66riiX43ZM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) by CH0PR19MB7850.namprd19.prod.outlook.com (2603:10b6:610:189::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Thu, 4 Jul 2024 16:37:50 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%5]) with mapi id 15.20.7741.029; Thu, 4 Jul 2024 16:37:50 +0000 From: Martin Oliveira To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org Cc: Andrew Morton , Artemy Kovalyov , Greg Kroah-Hartman , Jason Gunthorpe , Leon Romanovsky , Logan Gunthorpe , Martin Oliveira , Michael Guralnik , Mike Marciniszyn , Shiraz Saleem , Tejun Heo , John Hubbard , Dan Williams , David Sloan Subject: [PATCH v3 1/3] kernfs: remove page_mkwrite() from vm_operations_struct Date: Thu, 4 Jul 2024 10:37:22 -0600 Message-Id: <20240704163724.2462161-2-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704163724.2462161-1-martin.oliveira@eideticom.com> References: <20240704163724.2462161-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR03CA0078.namprd03.prod.outlook.com (2603:10b6:303:b6::23) To MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) 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: MW3PR19MB4250:EE_|CH0PR19MB7850:EE_ X-MS-Office365-Filtering-Correlation-Id: aa1941cb-f20c-4244-6de9-08dc9c47a4e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 9rAnHPmSAkso4hCx28EN/Hx1gNvOBuM0trrl5Y+AK7ldriGdsa2ZZ0gh5efhYhYRX663DSrSinDajt0dtykDd+l6wgbx0gLduq0I01Ye3kRYmCnVtMyA7qFazUVcmSbUk3bauF4/KwT7VROpANM3/HXLjoAYKep/4Q09TkIG6oawpCcKEtAGU5GJtRLgBa5LCLdfDCq51tsLDmL0CfNRsWLAGlDRHMQPLT5u3uH3PEt8QJTF6HUHQymqssd47dkMAv+iQxzXrUKtpfT2fAo4XJXhT59BCTXt3YUpW6zuLRQ0YpxKnQdjKwcURXyCA0wL9OlnjlukfuOimmd4kUNraLYNAJwqkm8vIwm5MGvkn9diX29QPdI5aJ3/W04oliHTkyLJow/cAtWnBFVl68158ZJS4o/Vokr3MQkJVEPnWE6Okkr3ntmAO4GEwBWhpjY+M4HAFip14vBq+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ook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(366016)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WbIwduU3K4nMudLaU7AXM37nBdEo1iSfo74SW9DvXzr6djZS6tXi5b8ddwxchfhnvqZ1KZIcjzKbmhYQ9UwPf8aGeSWm/f7ap1BaXrc49NUjPl7DbbFwIO81NmQe+++XX74IpRyI8mBE+jLgjgM99oJ+7cFj6p/aeVUIifWfPxbsOQnFyP4/+jihjOiI4ziLVYv1eLk18Ee8grgGnET1zlzvrUcMTPnOp48TLNANFE3DlLpjpdPcA1zEgv8aNsHZILNIw758dLX33yd3NAcIzk4mgUvy77w9NJnKLpV/MLqbbCO1cCPhG/Urbte/yVOL7iQn17GiICBseukY/+zeygk8dOVEohSYVUAit3LraBeyfeLFhnnS3hyNeKwpMA6VhARkFznL/8icUXJ0qjTUExdoCLyPTWTyCTdI0o8EgvypeuIZ9JzN9BFKDtyFO1v17pbFEzYrQ7y0M0VyPC7mUOmALKE5FQazfEpeD+tHOUT0lHGL2W7UcEp30r46wQaG+9W100be90MjA35uIUzj9sCqRZbH9RONsJ6TtCGHq031ZmTIiTrnYZnHCjXLcy/kbZcE6LFVyMXc7cePS70uxowQapPwF66s23FTG9NqM5Pfy6xBWuMCxauFN0f9zzTFnzkoUHdJsWhGP9UwW992SarFh6ydXjnuD1t0PxDcjGIqyLewjfKETYKhCEOANm6eMaH4Kj7chOu11Pj1RBqoqExs4qQSkZm12fRMGD8Ypek6KtzHO5ye7rANSkT9I8hWDTGix19B1f1L92f0BxkIYfuzS7RxMN+o/LIY5wHaFtyNGYlhcbtI/0rBDQZz55GnVr0nvtcIXdNbrBl2W14dg/uUulZ9xo7zrKQiNBoqvZHdrMlZVetolNcflefwQOkapsYeXKAi0ojvekyQbic86YoYEGIv5Q8haGkm5OLVMbBwihtEcSnJth2x4XiWo2aMNQJT2CyAg19aK7Cjka86hApVCGVdftt+8+55EoszozTd9LE4hJ02sVXviyyX6rB1MuF8iqvlzbaCp5cTGVV3xOIIx4Mbka16ObXLUlK6ESmAJRdqD1h+0UGI1qvcMkzDQ8rT4oUD+z3riKycsG2srE//qhzi90NpOU3hhK+h5WtgYk1qElLLklO40qvo5jivy9D1wtlGHlUulCJMQoYPxcGbvvvJh5m9Fc+3jLdeaRltj/lEC/M4u2P+qetDLHqicgFTSj59nn1AkPRCBuLgIHIjeAKoIoxmQQe7hfvh6iD6FJLucBZ5+knOy/kQ/6mIrNQ6zWTsnUOOlqR9ASHEsOJu1Fp4kuc0fBAt08JOkIYARaDYcAQus9KdhZRBiF87442MYTf1RCOKRJVwh2a2kSxUwDFj3cbxzqc1LGrnYlsLvmHmaAzEt06t7xk066K5g/xjY1cmUnnAlHSYxq0ASRb7nY9jHQSUp6SA9efhB4t03O0pGFTrXZPJGksxzwFatVOB6ipMyzySMsaEqTrtVxoT628NZjpvdRaO1WzsUOUXB/mxr8IXWwCjvmwgbm/7Wstm/ay5sG7sZU4faxEgwXM8zr7GnZz4kvOU/ozjAtRHxe5EgnVlQJLBUO344MsLYBgXScNy/xBHoAwS3fzmfA== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa1941cb-f20c-4244-6de9-08dc9c47a4e8 X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2024 16:37:50.4367 (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: XBHSmtUXiIhMZbKA7esjKytTNhJro+xd4W9ZeP8ibduQCAZ0x/iXadR+5O+YBGgqHKQt6iMmYjbeoMqhJuBAzhw95y3+iv/hMmRFgyCSJ8c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR19MB7850 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_ON() if an mmap() implementation sets .page_mkwrite. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira Acked-by: Greg Kroah-Hartman --- fs/kernfs/file.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 8502ef68459b..90603664de7f 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, }; @@ -482,6 +459,8 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) if (vma->vm_ops && vma->vm_ops->close) goto out_put; + WARN_ON(vma->vm_ops && vma->vm_ops->page_mkwrite); + rc = 0; if (!of->mmapped) { of->mmapped = true; From patchwork Thu Jul 4 16:37:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13724012 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2103.outbound.protection.outlook.com [40.107.223.103]) (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 E42481B3743; Thu, 4 Jul 2024 16:37:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.103 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720111077; cv=fail; b=Dp+xfCO3CMfBrKsxcPytiEn1NSZSx50iIJvjLjjyQIeJOsmp3PCkZJPjtAmR423t+jGVyLlCBNbkZsj+9871d7aeLSidzZLlJAcwhkJ6TK0c5Dr4+MjzWUgxEaBTG2/Q8G2HTWrZi3kF5+mmnm0aBTbr8MJ9rqTWkAEcoUr827c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720111077; c=relaxed/simple; bh=kDA9NQkwJqypp5SvEFRbIhfkySmnnatjHvbHY9f7zfs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=oRjMjA7D3A3s1MynJRgzCFOOmN4xUhv5WnsbqMT8ZlkmPRQSW5eoYWSf/5qimB1wQoTAKo0YC4NOMd9gHIXyYyVAx1sKZktlKUbwAGLaCaS7jkcv/HL7qTvTSr/12Bj3KcEw86rf6xxFuohIgSXJ+w0phlWKXKK4Vyu5oBt27IY= 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=Vx4Dct8V; arc=fail smtp.client-ip=40.107.223.103 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="Vx4Dct8V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d7sehZwTuEVzuxEF1FDl1BlUS4k8w9hK5kC1bhYZOsG+jZAfGF3p2cGTjCOfknnOqwxlphVi792yP941MkxFX9aC6kSAy1xqVW1gCwMdT4P7w31OFNz0J1EZCqke7bquJfdk/SQWWuI9j1Yo2ZvfX0t3oqDMNFrKbiDzZ+LhBrV7b6XohBjsOks6UMuMWSJ5d+zT45El+ooGIgqoBTol5tSUBCnBepmRRvK6iiURkl2tcPFtCy+91NfNHQrAFHihlKCaVt9EghdeAd7KOVBA/lZflQ4Kd2UUY0xvdp+eHzNlBqdpSPiz8nEJICYb5SeC/xyPMpP8qA/IImuNdLQQVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=QGCtZ5R+9+ggT5pXZCULkbLLO7rsRu7vy0kuObEqwzc=; b=KZKeCHPGyj8jJDTi4STErX8GhEgYb6t+w5hmKI2WsunpgVW7G4gTX3l7wxwwhToS8Au9+jMPRyT2OzdX2KiHrjtX+CxQ/uJ246JNMvomNwIItLWAd9XWKDba8xZDtOIaSvogedtyFGvUk7vCkxy4R9XE4dg9zENIN1lXrmi4l+VDSJtuVJf8tZBgfM+4HswEYd0Y8lDUZ959gPfQf9KBnHgr52/C/1TWDcAOUnXv6zYZLdTRsXpO5DoIWTE1uDqVYbyrKC9qwEf2+GlnFDgt6EoIY5bZ8A4sbc/yQMVb67dP34PZbiY7ifjDJwf0m/HJHzDdck+cw6rHjU46TqdRNQ== 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=QGCtZ5R+9+ggT5pXZCULkbLLO7rsRu7vy0kuObEqwzc=; b=Vx4Dct8VhisCvg30GSDzRB6egUd+/0ohMKwsVu0mj/OI6LmRQBj5JxeCZ0oK4WeRZho4zzZ1o72bwm5rM4nf6aS7GWFzFEWATGM8J3WjX1GCiYtkMzTcDwCMjgR3lWGt7uYp4fd6EcoR/H8vewQ+lwMDZKkKu92eFDFBcMq6aus= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) by CH0PR19MB7850.namprd19.prod.outlook.com (2603:10b6:610:189::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Thu, 4 Jul 2024 16:37:51 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%5]) with mapi id 15.20.7741.029; Thu, 4 Jul 2024 16:37:51 +0000 From: Martin Oliveira To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org Cc: Andrew Morton , Artemy Kovalyov , Greg Kroah-Hartman , Jason Gunthorpe , Leon Romanovsky , Logan Gunthorpe , Martin Oliveira , Michael Guralnik , Mike Marciniszyn , Shiraz Saleem , Tejun Heo , John Hubbard , Dan Williams , David Sloan Subject: [PATCH v3 2/3] mm/gup: allow FOLL_LONGTERM & FOLL_PCI_P2PDMA Date: Thu, 4 Jul 2024 10:37:23 -0600 Message-Id: <20240704163724.2462161-3-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704163724.2462161-1-martin.oliveira@eideticom.com> References: <20240704163724.2462161-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR03CA0078.namprd03.prod.outlook.com (2603:10b6:303:b6::23) To MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) 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: MW3PR19MB4250:EE_|CH0PR19MB7850:EE_ X-MS-Office365-Filtering-Correlation-Id: ef476c93-f2b4-4e91-ae84-08dc9c47a55d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: N09VhjWJpxlEuLqzrjKFshGZlVd5iqV7U9j0qpeXCEoClv1dbtaICSsZ/VOkzp2quvD34QHrpFPlm2cZ9+/hnsNjMsF/ix9dRRI9CRXkfiUh1Ro8Y/nXMKL5I7+1GxRdjF+7tKEtIsa+dPrjbIEGkLjELbLqnyF1epjAjmjvDFV0fghROlmrvjb/lHUcz5gVBpvwuE3k8oo8c7VoBAxOIz/vAD2NYlTl5VdDRxKaJ33XToF6I+yxxRVTXGYqE16ArI0cxhIpvD3E6VE40fRztdX8gR7YnQulhQdVJmGRIWsSJcbkxikgsV5NoVTtIu8k0Jz1wl2UswjpFZ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:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR19MB4250.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(366016)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UdPtpFYAHspmw8PCldOIHVslqjtH2ofQFzZKB4uCuH4P65d8/Ht5//Wjbqa9VlUI8OZWo5Vwf6brHu7f7YR13Pv5c6gmPbFLIDStLmk7WM7sROo0Oqe5SzSYcln5BPD5gO5Q3vfQI46bzSykCATWVqPccuFjybsFhDhZcXJ+CTQSX8kanoPIjzxSecx5Hn+gPGLM6rsxjHBM+bIrtscI0X1/cVJ6tx2CDk/GwDzLNmcX/ddBcX3F7MITzpCPBw00UbYIGfBlXjkdP5O2XJdm6MIzqNZhJbg0MoWmVZmSM47c4XR/rGMBtDOCYyAJKhaXI+1+KfJbgAaUSShaPI5w+CLHIq62WQoRTOhgYY10KF5/TG2Ixgc+7PzjK+yQYzvA+H61GdOgK2INypIpFFVySOr+T3lKlB24+opJXN/t/7g93BugLIobzTZ2MgbAQdY4WW76GuXPUbZsrO7VXqNRCbUeCWP/kCXpUv3YKWZLuFFUdBBLehUtt6VPSukp3vaFUwvf3PlCcqVltQGooaEUikK+ralmpEbzHRmOlHPL2QezryZy1eL0RZ8hd+0Q2YJFK8n68gFxCSlYHWJearyBKWkqDgn+i4ZvzO+Tc7DhTAm00Nv8enAy4xVA+vLkPYh71bU9T7IXl5x4c7q+fW3RurJ2CWVHTyQ09DLnFG8iD2V6uD0sEIcdQIJwCnNDYls5tVJUyC3QwIuzcWiWNsV4ByMvOtC7lKoZqPpcRrEszSkP26tCb5eqJAqv6yg3zb8O4IRv7gB06ev2ORCiHfhS+4VoyJz79Uqnqux6ubw84SP8dHB/uPaQhajbsCIX1jk9DoffpAlUQNk9RT2+wC5v10pJ5i+gNOsiu2pVa3qMUygWmJxaqylIBNv6twlodJnHCtFx6WHSRnLWHz/xEmsVdmgjkp7cpDIkkgYwI7qGgEl62PpeqrPE1Db1/Ztri5O6AL73fdiJKBLCcE+Cf9VK7Rei2cE4KhVMFxE+pr0d6NtUXCelyGeLx+upuqwNTTI9a//ZJUXhSo8+PVximOEQYzXgcWdX1GATV8+3Xz1pUzbJS5dSrVqe8sFcoAjrRm0jFfG9xlzTjfjGtLbjVm8AQzvRLkkJigoGM7kBLPgHf8vvDP2uzbrBXZSOFJrEe454mJRu4oTPB/31R1SZ0i3oM7qp+UtA43fjrqlkWeqKZglk6jayiNC0lycRObMHMkowBIO/55PgAfdvDUQ/sJ4u+qzkPWCSO5At81CV4uY+ouCmk4P9mHIx1Z/tnXPnCo13wGAuXRudLGm3UBbn/OEQdpO5xBg7qKVR2c4tJf8bd7M3ViOrNoM//WMXg/w8wuvhF4cM38IRzVAdRvkmonkWZHv7iJTicGaE1k1LL6mm9oiFgrfJkidaZd3b2KIV3htB3n4QNlwtOGpYCuUbr9A9RvquXTvFVz1sXjuN3xQL/ZCqhlZImWpRcKL/CPj+qiBnMqwMDUljFYeU8InPToxQ0jss8mlibA4rvgfxPMa+GDU2cGCzPLGh/Anw84/46t9EuacGdauVBkoJpXJXOOC5ocrjPfFOaIFJY6e65eGU2JgFMBEC8UN5Gh40RuxAIasFoEHUWICD5kbMnSE+whhXtQ== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef476c93-f2b4-4e91-ae84-08dc9c47a55d X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2024 16:37:51.1851 (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: oEqVqtbDblHl2Gk8ZWGKWlWKjXH/u8A/C4OKC/Y15ZtT8rEEQJw/OTfLdzqdMHxnDS8bfaBoS6+SemUIkMDD+z7Ho2Ua9b77QX6+v6DVNGM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR19MB7850 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 ca0f5cedce9b..6922e1c38d75 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2614,11 +2614,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 Jul 4 16:37:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13724013 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2103.outbound.protection.outlook.com [40.107.223.103]) (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 9252D1B3F09; Thu, 4 Jul 2024 16:37:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.103 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720111079; cv=fail; b=OtrngivLc8StZCgm2HCKxWnFiGXZ4xth6MsdRRwYZ/YO2tfVilyN950RNPVA3ZTZdhf/I8vAORyd0iNvKq5I0JTTf8kLANHxpZEroTcsJ6cqQdmllyzsDoqPyAOqFExddgRDRwvVbxNNn+Gqy6k0z+sqc+m2mnIfXtWs7fdvcaQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720111079; c=relaxed/simple; bh=szLQRnqhp3lsW0d8v40eokUGOw6zDrK50Xox6WfGvgY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TCL9TIDHG1PutU2kt5lbgHBTosBaKHZSj08YUWMiNBdbgKNdsSXxkbBBtgtfApeESyigIu+nq45MoJoWiZQavddndvTT9p1Bb7psDf1PN6nyQczSeI1nyx7Qb9ok9d5SvKmMGcMkfm6uqF3bnmUmxQnH8dgKakzIXHrBE6sDsGo= 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=ao5uGO4B; arc=fail smtp.client-ip=40.107.223.103 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="ao5uGO4B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NssNFLK76PWVM8nRhYfj98qgVcJwUN0Z0kLLF3Nib9UBGU5kS/x6t3KxY/DJzr9iZbOUMF2aC+O2PwOhOz89swGOjvO6oIRVytbdErjp1kiTzJ7nmWhe/n0+tD2MhQyVcT39Khur+1HRpISTChIkOBmobkrffhloEAiQla0NXyV5ln+aiYof82SRaI1qfMmmPHhFAOg2drA2OEfoXGZ7z6hvAGHL2vjB6CIuy5TLs0EnlFa9ke2klQfiqJSj4187vS1/7PQoZjcveA6lJV9hx2gDRijTIbO1tW+ankSj+Y5jq3VNGexEY6KbqtoepwGWTRrw7QjT+k7hWN1564q1jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=YueMmbvCvTSA1MKV+udXlu2nutuaCG4yOb4CpEEFNc0=; b=WKmeA+GMx7yTMbGvUrDt15a2Cfws5E8ACHuWZ869DUYvRIFOJthxWVOgSbmeJAyBFXouE/+3c8c3diMW2CVu78bQXp31J3AIUIaPwiXrMiaHu6rSMlh8989Ex+RZT39Sm4ckfTs9GNW83/ZiDYwR5sF4Mk4KJhEWT+7iigUiBgPi4e0uz7uWBDAFMvShvdknuJ4fKdZpB2lYu1GwYYYNbAn3lzja0TpFu1+ptvO0X9oeLJwVPnq5Pz8yL1OAUy63j9vvbaBv/HvWLo4yWIOEifruuetyzrRm61lGaNPUB+jyqJbeE0SZq5TSCJNfM8cI1RZs2zQ96hQuhlYJItrnDA== 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=YueMmbvCvTSA1MKV+udXlu2nutuaCG4yOb4CpEEFNc0=; b=ao5uGO4B1MVpMILxKMNbYBN6GzyAmPjGCSnplrCTjFWIHvDxBJmup+tkA7nnLxDo/LCIk2ekA7GGT1n6e9l7odt3GXMLVoTGZMN4sj4IQKn+mo/25xXgyJkEqhQANpjK/eB3TAQAwnlBpPqXiFUZ4UZAeYhpEP+xu67nh8hrWkw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) by CH0PR19MB7850.namprd19.prod.outlook.com (2603:10b6:610:189::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.29; Thu, 4 Jul 2024 16:37:52 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%5]) with mapi id 15.20.7741.029; Thu, 4 Jul 2024 16:37:52 +0000 From: Martin Oliveira To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org Cc: Andrew Morton , Artemy Kovalyov , Greg Kroah-Hartman , Jason Gunthorpe , Leon Romanovsky , Logan Gunthorpe , Martin Oliveira , Michael Guralnik , Mike Marciniszyn , Shiraz Saleem , Tejun Heo , John Hubbard , Dan Williams , David Sloan , Jason Gunthorpe Subject: [PATCH v3 3/3] RDMA/umem: add support for P2P RDMA Date: Thu, 4 Jul 2024 10:37:24 -0600 Message-Id: <20240704163724.2462161-4-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704163724.2462161-1-martin.oliveira@eideticom.com> References: <20240704163724.2462161-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR03CA0078.namprd03.prod.outlook.com (2603:10b6:303:b6::23) To MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) 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: MW3PR19MB4250:EE_|CH0PR19MB7850:EE_ X-MS-Office365-Filtering-Correlation-Id: e5de9dfb-cf45-4925-6519-08dc9c47a5cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: T46nsiwx1A7Y1lTFHcrR+KB5C95vi+7pEF/KvWB+habevjHSET3dlp43hu6joXokqmbZAFgqqso34+hbMpl/QQqt/4LCxJiR1XK/h5yH/3KvA5PogVImG9GwO0Qy5bgExmxxwBCCUx6JW4h8SEPy8hK6IdDKAOHymjoJhnbvlK640Ga3AwbSxwRC8Ljhm5wJoTNc36NnqcexmkpqN3G7LECO6RG+9XhTOZ5YOdsY1wZXYh8kMR4jFws6cKOKQ5Q/4MiKVLb+SDjAB5EdfhPT+ZbpiRNUuu8DYBM4gbMXlfaRYAU39fVb3CjbUDk5GwIlLGOo5xVwDWnfLLZCCJJ3YAb2gn7auei+r0+3j3zcZg6mA19vb/l080sg8p3o2/sSr9imVugg3qfFeMWOAMMIAoQVmKdPiDmDYopCk4xcSFt6ELSfGrqNhGirAZyRaHeFTlo/nE/gxpwpR0bIOd6UNmSTZb5QR8jwOyvMRuDvaAHxgGxi9KDgOLRKGpF1ziCLO9mbBnIJwZowi/GkB5jaiTSBF6gqbLc1CF4TpDz6QhFZvDldbIIfw/pmh0ZVUMSNkeU0YZPtnvCGO0sVISBipizq26W3JDVhWZ8Cj2nDp6awxF065ujbvk57A0NSeUnGfZlPO74vOpOLozw4qQC/hoEXx/8u2Sx8J6eTb8+dBKNLJ70OvUgj8gm9npAME28tCdCZEwWKjSqgsSOWDAkoq2dPAYlNZvipMUc5jSbrhNrCtLPO9aYo79T8HUtxsqq1tRsRvrdNqoOBiElCLQW6NIOPYvOhg0r356zBuNKq2VOgY8b47V9AyfWYXcO/NZ8otD+U14D7VqjsSSBsvI0e2jI8Phd/n3SQIej1aqe1XT7OPUUD4+GD+uVCkhBeH0GAFXy/6MH2Uu5abprUkV7LMDuHIQ2Ga4cywWJ4Wlcll4Xk+4wvzEazoWPVJfzPt0m4oz/ct/068VQZ7POLyf7NmO69I28+0Cbr0uVbdznbix7+E0YvXDqgtOq6jufmaVNWf4KxBsItMGtxjChAfrKm9kOrvG0manLvsS+E8PlU+k6p+3HkDvk8M42wlE4hThpjdFYBeJfeOGmicDrkAP5H+S4ZypSPtYJP8ME9lJ1/6tyv02mFdoRckqEyH2EMSkXYAo9LVlqytngKFyJ8yJ4pDi66ptvOoYprn23g0TvINLtushMx2j+1siXUonroewggFS4D4Cn05r4KmMJheMLf10iZ/6FTpb2i0QrBGuf+iklw2dp4PsUx0VKKeraZ6x5lIj2dd4Ff3j86XN5H6EQUL5Qt5j2sEzr3y3P/XfpSD2BSdEXjG0UahJvEEyBkZFSmW1uTthLUY4L/X2YW35hG6LIJ9jyryzkL/Neua6Ji6yfPDNprDxnUYVZK8VrGFBJstD8EErxUnkdN24TjJEJeDQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR19MB4250.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(366016)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iYV9ErrjxIeQIOsHo/0csBdP7EmNTFTsUWPXryGmIRAXUkrjpTXY/RXWNGS0lZ1v4YGgu14NqjFvDIrqNpfZ9N6GkUwA2pb1nS3eYDZ19n318evOVZUDBWQTlvJcjETUaA/+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QSXaI5h1MmVk68SCw3wE2flSLS33b5YFveGxiPRRScQsre8DmRHAfFXtuYNdGVW6wrmxbgtB9Tp9aOMhx8f92FS6C+0/+zLDbBTYzgAy0BODH2gqETfvZ31drBFqxTNVSGiFgGwGrE9ApPWkcuo0Wj9EBqLHwlhmlwBx15U3LiMb8xAsDKrAdGUIcp6nEv4poylYQHbma2CZyWXgwahkLV3GpPLjJf1G6mD/XwcSdPWmufacj1ajv1HRTBt0HFlHtdPvE9TTwnfqNFmzxMJfxiRp1GpWC7khVZtM8lIbg9Fk9FX7yIaVwSOfqi/+b4cwYq8hLKyXK7ull66q6GiCVXSYTgRh+budvZHkmd2NPKGC7zSdUAhOrI0vO8/q1FE7D0iIoP0cN9EqLgCDh/c6O7ByYvQ== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5de9dfb-cf45-4925-6519-08dc9c47a5cf X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2024 16:37:51.9383 (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: t+csYIwx7YAmDc0SyasvTCBKH5jlY56NwjLs78GcE8GogcFcGy10XcmUwRRa9efwo17qA1jb+inwu8TKWqw4AeO4JVyYpg8oKWzAioeQk4Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR19MB7850 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,