From patchwork Mon Jul 8 16:57:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13726868 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2111.outbound.protection.outlook.com [40.107.92.111]) (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 2B8191474BE; Mon, 8 Jul 2024 16:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720457867; cv=fail; b=OknAwAKZKMDc5LZB8R1BIL6/wG5LRomnjEPtv3/JBAdJBrqNgjtYfhLvc7RB9Ye4mSXBrehvG5T7hCLNTo2632HoszUT4AjXzu94HKt4mwx5bKZTOgBZkx43Dc82xqf3DvR1gEL8qcESq6FmHg0yMsc89YCpG4fvO3d/KDYJ4Ic= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720457867; c=relaxed/simple; bh=3uQI0rqYALZkwyAE6tVThIY7sHPMtEUB0iamPboTASA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=DNYiIwVJtilgVTbZQNQZ73XQ+kV2+Q+WvDOASY0UcsPQiPaznWanCzxvfc5fEbQx8JABkJiAWq6wngcVh0q4DUVvTPlh+W71mPRsEmQ31ewByf2dJexOTZ8NrdXNyJUp/EDt2bDErNWC3AUA5OxcUhMO7XYD2E3ypkm2N+Nu7ks= 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=ba9ew+05; arc=fail smtp.client-ip=40.107.92.111 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="ba9ew+05" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MjtVhcClUyfJw/wQMbOMh68lYH0+822o4eSifTUdYOaWOeT5725kRTDhejlww0cPEvEpWxkRIbQkVSVXUe3gR9GFpUhvkc6ghLuHIrnoSIs0sq8W25TeJ6ArUpaOd8zGi4W7a8TaiKhOX1Wbo/ZJhGsoCt4fLeSM41w7nYLHxOd9uvj98/B72mNj+Dspsz0xxVy+mwH0SO8hQgx4VTqtyO9y0gzeDCtdnfLFqzbkBfcxOEGHetW1bvFwJsUTs2aLGGe+tv/X6nS5AJzjeXlmifTwYXuV78EfCelQ7QbUF+RaJqnF6NMmckXNIcjERan+8e/CXVmrcExF/lQdECEDHg== 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=lYp/stGLWTk2gTG0FcZxnAS3NZ14yVcWXZJlVtyXPTQ=; b=NaM71RJeF40dwkG2ezAS8fkWYMmqci1F2fZ/N/MWftzMaM3y878+a8FqEOwg5b3ldzzPGyr5cgvyan4FZlSq80ojc+nmZ2tt2nX+Top/VsVsbFaep+iJwpn8CBsno2fz/a7ZdLuFg4SdWvDxImvSl3KN8goPvkz2n+kZ21Jjg1/a4XhMssQxw3t1F2ZSMzV6C4PhBL3ANF7gLu1e+wx06XR1Sk+xbQwww98aUjZ8UgPNbax7gx3bmgIJvtZn0M5yP/eXYwzaOa/4rEadQaVtVtmOlvO4836k2KPAI60GyNcdaRCnVjaQXwB5SZyAxdhWYX6T+3pQDvkPNSyOjw28pw== 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=lYp/stGLWTk2gTG0FcZxnAS3NZ14yVcWXZJlVtyXPTQ=; b=ba9ew+050HVndYP3/8eDoY7TdBdglurTOcQ/uebhOyJsk9vkdH/G9Qir88aXjkW6kg2va4ZHyI+bdTMcUeyDB6xbAjNVBs86vEjNfhwU2gWWyea6KMrluMm1tMelDkUPttHBhacPFO3i2RCOZHtv2f8GmQoyL0Zw1d2LMFbwKxk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from DM6PR19MB4248.namprd19.prod.outlook.com (2603:10b6:5:2b0::11) by BY3PR19MB5028.namprd19.prod.outlook.com (2603:10b6:a03:361::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 16:57:41 +0000 Received: from DM6PR19MB4248.namprd19.prod.outlook.com ([fe80::d508:c71a:eb4f:7cf4]) by DM6PR19MB4248.namprd19.prod.outlook.com ([fe80::d508:c71a:eb4f:7cf4%6]) with mapi id 15.20.7741.033; Mon, 8 Jul 2024 16:57:41 +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 v4 1/3] kernfs: remove page_mkwrite() from vm_operations_struct Date: Mon, 8 Jul 2024 10:57:12 -0600 Message-Id: <20240708165714.3401377-2-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240708165714.3401377-1-martin.oliveira@eideticom.com> References: <20240708165714.3401377-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR03CA0252.namprd03.prod.outlook.com (2603:10b6:303:b4::17) To DM6PR19MB4248.namprd19.prod.outlook.com (2603:10b6:5:2b0::11) 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: DM6PR19MB4248:EE_|BY3PR19MB5028:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e92b340-5a31-4b03-27de-08dc9f6f144c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: IcWMnKsPssgtg7sMcNbp3lUM31I62TRWhcLkxEV2wkZ7WLqIOgkMV8aLSxuZprlYA4hsmT+D2v1Rn125YdTVDUgZBRoZjEjbt1CmP3DSfZSpMPhZyZtxPv17w68Tfdota9iy0YOaYvJtcYQ5KFyt6NFya+Mnzsd82xklTiZ/y0Mwp/Rqh7TrzfQks792HHzOGb3IdMa6ZWulBHJJcVugCVunH2rB7MNFu+cZ4sz2ZpZpnQmSemG7yHbjTMFPDRAhxw8qeSUX/imuLqkNyN9p3BQ5l6rqnOuC1q3N5WmSTshY0qs42HWqwgjhXGaETiuDV6tiwiyE+sbYyQTEGIyL/ozEJ2401PZ+FfRUt29+eotFYbcPaADmDnWRWG4f0wYuZj3X7FnjoISJvAFPRaSFPpngS8q+fh7Gmar9h4OAxvV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19MB4248.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aYEd0Lp4zSKqOMA76BPNObq+2MjX/D1q1wDF1CQm+pY8Q7eTBC8yUa6ELcBRgJ82h2/RNQu2Huyg3iVjP/cW7srdmKJQ6GhOUyqiwz3KY8ySE+LlE79MMriZRZQGAP48t5LbVC2Pvzt8Ynll+1ewaHW4gfHZLNqFH7cDbcU2iQV2K0gd5SB8uvs05VD5K4ZWcKpA2iSqTZYQJURiMUx9bC6d4/PrOsmbjXxn7QoUP8MoMJF1jRvPX3tLX80RmqS0PksaSILlYLeX9Hw56Gq9fv5C6BZv8lPkZLRwvb3w7msE+oAHatk7S/0yrbH1D1he3ShMOwwmwlXx74BOTrATAfZa8tPZeXr6zCK8Eo9YsMdFA2FcPvJ1r3wNbV8mV39x1DuQQHt7aVR9c8dxOFBVcVC2z5N6/LGZRtHbDQhopFYiw0sUZgJT8AppHK8mUe4aQqJSNUWLb4y6oSHj4PZQ3fbzNZSUiv4AIqkUkSvQ0cBZ/flCaVVh9E/2cKmKhQKw/hqppmHJfGexKB8VWLpIIKCksSGBQqofhdsIpt6rNQoX2CQ74pBwcs3cUtMF0sg+xaIIabPVxI9PvW7HjWuSke+4YcAvmulGNioo2MU/uEU/1Fo7rstz/ZqpdDDHdjQgUBZ1mcsCs+AWal75Dy38OIbWMG7THUm5MDVyX+RbZGEaAPGXvdkG3ztee0Yh0lO51Jbhw6HMtyef3C/c9MTKsh7r/VFVI+Y4HPtdoaDzokFpv8ga68V3n3bDelOg19KPQvwNRNmA8KjcbR/RidToHj7sW6u41pfodx3ENEW4+GzTljt/Oej+FTUr5nc3Ppy0I49/auuwpBi5/fqLHzYmqCAYbj2iqpsO/yrxsulbZ4AyI32nkbjlPSLmMaGAKF0lGHHof6uOONCWSeQnE++BRZGfNu8M5WrYLkBti21yTZvdCoM8q7vHP7cTx/Zk27OcUT27QLcO6Bqu9dk0RfiYFJu+7/m9g6pDiOOX8+rtf6CilJSGNyzRcRumO9HFgFfuUWZUgDgI8wnDtmc1Xed/kA7Pv9qFMqQJO73xq0qJbF+dRDoik6xZw+g6eJDP6WmYgo0lzjNHG1jXuX2xXPyCEdhr67W7Vmj9xZYcN/zGf6Jwk0ng1IXmS4kbn6o+i5nsEISbyBAptvDOjJzzfu7EqLtDtK/2mTHedp2FtiPBbnHKE6t7IyEKlRR+2X5chyzlv0prA/dj4WCT8WXZwY5viv/adrj9svCekgTRvVSQbTBvcLnQRFrWcqwzZaF7nIfuMPxW9cdXR1crzsIBikAzV+bPACtJ92VNl2QdE+Ey4InsPHQsCoN6+wjn2BKpcaFD8TbkDr6PskCxWBoaCzRgniCxfKS6h7P+p49TUNQ3SOGTeEvVnd1aDoHtNTWy5jmx64KW+XN8O0H2BJL47nzFlbC/aqqSuXUwfdMKLEEtBN5NXMgRgkuohz6DoY5nz/qRtNu27i5B+FNziuCi6412tnd6ju0i2Ss7jZ/TguTgLfVod4knp4tjAUgDtBOQ60cu+0z0pFQFZyHYzifDGxM3onCkdMrbLTJjfAmiP0OcWhiaunnx6+qQCe+DO3vBlRGkG2FmEIQAQz8yvjyximoGnA== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e92b340-5a31-4b03-27de-08dc9f6f144c X-MS-Exchange-CrossTenant-AuthSource: DM6PR19MB4248.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 16:57:41.2017 (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: PGdH6cDoMyEtcKqfpoB1Ble3yPwJVLhSEpDROfa6n7Nd00BXZYTlOIjmvJpEW+Y3ABNxobxSPg7W4A+ap0NAFOeil2sPrroH057X9cI8q7I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR19MB5028 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 Acked-by: Greg Kroah-Hartman --- 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 8502ef68459b..fb2b77bf0c04 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 (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 (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 Mon Jul 8 16:57:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13726869 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2111.outbound.protection.outlook.com [40.107.92.111]) (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 04CF714831C; Mon, 8 Jul 2024 16:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720457869; cv=fail; b=G1lK5UAyrkKvH5QnzpynueVZB+zwieCmXvyXMQ9E9cKM7tpd56V5XdF1nP9st+e9Y/wqDtsArPzDlAsXeMFFukBlCW8Py9h556ximGKml4clC493x3CMsjd9YTiV7nt2RU8BvdKtzpPKB5QCyfZGvJbz8clwSPkC7XKpfv9nwV0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720457869; c=relaxed/simple; bh=kDA9NQkwJqypp5SvEFRbIhfkySmnnatjHvbHY9f7zfs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=oUUjb23WEjYmwOfRHZtTzlf6/bRxB5ewTGrGAQtkT3jG9b5RPJrDJeYGollakTbGKC+hQ7QogB8vNCZzf/WUZXYThphqSl5zs5ESqCYES9twcmt7aaSO+Io8lA21x9Rl+phi09sthb8386E/pOdqcaGhCIU6fNGc4mBkr2xZbgc= 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=AisU/B4m; arc=fail smtp.client-ip=40.107.92.111 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="AisU/B4m" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HcV9p0yKaipeMnYXL0COcO9YejgXMxzXeQ9v1XxuXRgbN/DVZbGVwOR0lyb4Hr/QkJV4dbZAmgmUcbqRGseRvXRm5bcoa6qoke9l9+oMF2UzHfeerZDi0wO/ZEp4WdXpXXOIWCvp70tzXTmvrvqnmp9CB4h0e28rm+8EWVbOBDJ/i6/ygIiy74VGu0ylyzwbpDiS1QGqHeLDfLHc/32nzWplG1NSeJaCXq9qpUq06R1RnsQwfs8hUTuzZDctVb6B7KFIwdGZrT9vk9FJlPzlmgDz/Rz3MaZKdEmnTt+Ip2NY1Uenl2NBUFgkWwSQKBH/JL8dt0UDsuuC1UP0jMZUfQ== 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=Mff2QxXv0KtYsFlPLlbLf78RHGnmg8mypeXSoOpRTj+fJXut08X+HwSy+ELJ2Lo+tBzv+8IjH+ACFjxC46W4tYyFvR9WWNrgcjO0uRxxcahJjoQbPVLfhrwtK3r73VxKhxV0JvmtP1empVPprbONsTldwThjT9apP0r66UGVbNv7CFG5wM3xTiDVwGOQK83QCp7Frb0v7Xa8ajyb33CYAUu3eEwg4EBQ6pHqFSg19iQZgTI8wHpyO0m/rGrCTM48EgP/nQA8lFTN46uGP8f3rXFnu3UBDMfMAVDrjWILmJ6PIpbQ3JQUL+qvDdKZUGlt0xTKgBkTm7miUmtzr9mjAA== 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=AisU/B4mBvAE4ToJqcGvsQSfGuRX9tFJ312tXXdIG5j59iNqDHPDD2Tqbfp2TrGaypoQA08ekiPOlEHvrNeIy6uR7sa6pEoj/0thiN3eERaMr/WAKla4BmR7xZB3PvqAPpDTF5esvD6D5DYgqy6VP4TDt1UN+L4qiY07hx1Id3I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from DM6PR19MB4248.namprd19.prod.outlook.com (2603:10b6:5:2b0::11) by BY3PR19MB5028.namprd19.prod.outlook.com (2603:10b6:a03:361::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 16:57:42 +0000 Received: from DM6PR19MB4248.namprd19.prod.outlook.com ([fe80::d508:c71a:eb4f:7cf4]) by DM6PR19MB4248.namprd19.prod.outlook.com ([fe80::d508:c71a:eb4f:7cf4%6]) with mapi id 15.20.7741.033; Mon, 8 Jul 2024 16:57:42 +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 v4 2/3] mm/gup: allow FOLL_LONGTERM & FOLL_PCI_P2PDMA Date: Mon, 8 Jul 2024 10:57:13 -0600 Message-Id: <20240708165714.3401377-3-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240708165714.3401377-1-martin.oliveira@eideticom.com> References: <20240708165714.3401377-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR03CA0252.namprd03.prod.outlook.com (2603:10b6:303:b4::17) To DM6PR19MB4248.namprd19.prod.outlook.com (2603:10b6:5:2b0::11) 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: DM6PR19MB4248:EE_|BY3PR19MB5028:EE_ X-MS-Office365-Filtering-Correlation-Id: a565de53-4a60-41e5-1795-08dc9f6f1535 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: GcuMzkadVzg1uRgFFK79GIqPLg+m9kcO3Kdxx5j/OeMQ0ScGiT42fScXLm6mvaZPg1qc4jkO9G0m0kS4NSBuNUDRipBr21BEZsaFYxNaK80X7vjHaSGQx0VzH2Mj2CHM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574wQ+6TYVUaT4grawKlcbeFh4bfuti7ATv7+7fTwbd3vUUAaIlWxMHPNwaHSGXkUJHC5fmHOjz9bEzGunXOmpygj7IwRtI56X9oH5X5iiMWxQ3qx768F2apkQ9zcj651KzTH3wGT+CvY1urdlRgwD9pTnLBd6d/GF4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR19MB4248.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cFFfOj8uKA/93kkqnQRtaAUVwOG/smG10ZfVsuknHW4T2wksASUkUJr5ZmxPKr0ePK00ndD+k0Fl2MappZ5WLFVE7kTq8QSE1DHVRcz5g57czfvYQLI2daOVCJ9ZwBee1IkUxWSc9d1hV82kOF/hgSimo/3Ck80YFsxAE0qSx8S7IHp3ZVaXfgcQzqIsjStCoZ/8gkk7Sk46eVpUoaAfJTg9DkPmf13lifbkUa5nf+BcI4vSx6PzusQpU3CNUuMJRO7vDpv5PKY+lzPMjtMTX1hkonwK4FRaHP70RRqB7rjoQlIYmKcR5twl7RXWmo0Z9wMi78u2LYjXk0E6cQGYTooupiP++HtSpMINHFwheN79E+i7P8DJzbwJ8wsDEg8xGOIzpNsM+9dUiWt6BTLYB46ocjjSBu2Yp9i/1UTuURbc9/ln4jW6WfEkl8rgj5qbhNYkJMpI9Mxb+euz4Xv4Odk+6WBjpukgAhYeY8fYq1abkmoVSyjifSjTfYs54eh/cKGOc08wO11ftsgDH1COABEDPcewnete0F+0EIOGYAOe1IkHOl/Clof7JBylhtCS4gbTq7C92dkJ/e1d1kEDh7/G+6s4qRy3cdLnAPDjKerbBhJN3qXpQb9A5Bbd6tXR8Sw3gGcmpqE6tYhnjBgWW7/V5weGPtY6+vDsIZvfiopNHj0F3GkldKBH0AHeNsoUCek333KKIAH++K7bbxlqHSC/qTZ5qPdCzEUcP8pCprCE8JGquDPGeR2e/ZSNBNfcyI3MRqKJD8HnHV6nXO74plx5JEmlcTpBpxb3lgMflRuAmaIaJ2pMqRGzRtLKmgzaHQI1L/ll2mvwJWQDoSDiibZmD2rLExQmNrWueDm3oxB868T4iwn2vTiWe4IAUtuoA1vNQnyUdKwjsYS88UP1Z0Wk7q0n1MutwazxeEMPtwESNjQ0E/UAoyk0/bhApZ9tekUDlEs7WfOyCrsSxNESr44qbUGazquPCbMdHYmxGrtcBWrowHVQAv1plxEAm0RS8Z/UeyxzO84Pb+watDM+IH0ufOWWPwb32VopdAwqMVq+Be/d6wQ0Y/gd86nd2HvHYktpF6+8IHkWgzflJoiYuZ20fx6ZHcugffFRINyYO5wumGTFUGmkekACsELjaWGWm0hi+GNSOTwsYYq4INXMWokvZvF7FgJJLDJguh6bmldfbB3gd1amIFfnU1uJS7K2Wz4Lk9R6aifKnz29UkY/tsW2XtELWDaJ2q93F2B1G+TRGSGSk3D9rtQszoWZnCLkFKy+2mijEgfHZ2aD0z1C7XMosb1BVFGLQpMMorUMp8H1UDr4AwneB4oUVFCweslVddLBthscVvQjeHqagf4cu9tS1s8j/ZcpdT89/SExgY59ww94R6XOuQgoL3nps7NtC3hdO1ZijQXfw98uPde2jsTXXu5GgnqPoDoKjs9ICrC0kskha/d/pO00ux6hWFSgvbcDsHVV2dD2uOdaxzKmAw7VJxoAWVWM3mHIsaRgbheYsBmDFG469eOR2NyV29XMiBcinMeunrJivFoOKM/RrqRaJedglM7/qgf3sUGMmCEtWnG/eBoB0TuQILVjgY1wORQZart1YKnJx9qutXOUag== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: a565de53-4a60-41e5-1795-08dc9f6f1535 X-MS-Exchange-CrossTenant-AuthSource: DM6PR19MB4248.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 16:57:42.6777 (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: VlP3bq3F83T3k9tXtjmOfcc7f9e2XX4jl57TxugKdT0o40PQnHxuzBuL2LG/zUxSZIzvaO4PnZinMvcWo3mBwSNmEmnfRsmOK5IaxAj9NoE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR19MB5028 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 Mon Jul 8 16:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13726870 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2111.outbound.protection.outlook.com [40.107.92.111]) (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 B281C148FED; Mon, 8 Jul 2024 16:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720457871; cv=fail; b=tw/sBjwp9EjW3IgRcmSidOh270QVOex5lSGoHf+SnFU4loyHubljKnuPrtHzWECDOyCo5/NLbN2F1R5VmHzRUbxWo+dgVs90lxBt7g0rzN4c2JHGgW5c50chA0dcUDM8SZ5qf7+jCjK01DINskTmkT+RMXJcoBpjbiiQbFSPirI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720457871; c=relaxed/simple; bh=szLQRnqhp3lsW0d8v40eokUGOw6zDrK50Xox6WfGvgY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=bfnJdvhntLr5woLZOiFojsZjssrmILmO5AERNJwMQfRMIYIgQNgueCE+i+pCwLcdJRO9ovMsiw1J22drgsLuA+Lxbnnb/1RONPItl3wNCdGHb+SfxK57zt+Q+Y0xVr68e2pzoVqOAo8qNPV0srnMx/HoG6PfhlSIs0pvPTUmyjU= 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=KnRGtE5f; arc=fail smtp.client-ip=40.107.92.111 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="KnRGtE5f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C8E0F60lBTk2yARSsHbC34QHx0AHYb3dCtVgIktM/4mtKN4e/mw0NCZVpzzasoLpKC13qb3QUskybxTapqbat8PYWsyg/RF3H0akW/P0o+MIJrNd3tgJdA/N1lilPWGxsTOoaO+TDYNqG8QFdi+OPprskp1Wyeyl7+mcr375b3QBYJa7xvjB5C+ETPVuxvq+QPML3bLgwseF+9iyKGYbtEZBrNf5sABSQatEotC3jPrwLHbvvMRiUrc1ofBq+wkkOUD0ba83JxTQxIv76gsMdtY6XJ3PjOlOqGNTGGBcwjLKLJJDQsgI28QJHXVgQ7g0k4jq9ltoL/xS+cjo25frjA== 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=at7DIGjQwysJf9VB8hv584gL5BcgR/4UQoI4j4drsw08rj4Cu4tzhXNsv4nEOXIQbDTU7KothsrpqnQP9OXJOS7xE8sNpay5O36a5gpVDKNyG4w6eyUV/0is7YDz0Eh4iSOQft6z/SDilwVP6tv0MNut4WgfKYdus8IKSbfMELzxovfsWRqawML6aVncogyiSBEc2tcHS+3NFLCOddJ+Sya8SPkPlBqkQbFkhfRC8aNEQW0gOkGiSDYjjRGyrIAc/HMR1PGi50wK5h9FFvZNSaa5nmbsCzHeWjToKxiD/ylXRjJUY4gZu15R/rIqYVf/oGdSt6RHXZyk3BPIqjcJyw== 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=KnRGtE5ffnqfvuaoRRYC9bPMkS37lthLEyYLc/ZCo+lK1o/JiSQtq78r5xhc4ENVRHOyZmGc8VCUUD6PT4YqmwkzS3eg3jbRoLp7CwW1A71U3Pvubg3eBvgZOfnlMbTfRJxZLq0rtZcyWP8niXndyNHffCWrW9d8tsXbba6Fx3o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from DM6PR19MB4248.namprd19.prod.outlook.com (2603:10b6:5:2b0::11) by BY3PR19MB5028.namprd19.prod.outlook.com (2603:10b6:a03:361::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 16:57:44 +0000 Received: from DM6PR19MB4248.namprd19.prod.outlook.com ([fe80::d508:c71a:eb4f:7cf4]) by DM6PR19MB4248.namprd19.prod.outlook.com ([fe80::d508:c71a:eb4f:7cf4%6]) with mapi id 15.20.7741.033; Mon, 8 Jul 2024 16:57:44 +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 v4 3/3] RDMA/umem: add support for P2P RDMA Date: Mon, 8 Jul 2024 10:57:14 -0600 Message-Id: <20240708165714.3401377-4-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240708165714.3401377-1-martin.oliveira@eideticom.com> References: <20240708165714.3401377-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR03CA0252.namprd03.prod.outlook.com (2603:10b6:303:b4::17) To DM6PR19MB4248.namprd19.prod.outlook.com (2603:10b6:5:2b0::11) 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: DM6PR19MB4248:EE_|BY3PR19MB5028:EE_ X-MS-Office365-Filtering-Correlation-Id: ff788045-f79f-4488-3ea0-08dc9f6f1618 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: tNsAzoWvN0zCxDPi5mKkCivR5HnFx2660fwqJoXqk2H7xF6xTyIDXUaRj7k3FXHQtMTXeXkKSf1FvZc4enIdLsVZkVoGdTclROijyxnM+K6uKIBjQoWkpnEzwx87ZG/+Mr9vuP/yesuw3hMxSnJsvmSdWvSAGh5ngkGwECmEes4PJQu++B1qEhLqGP/VOQfefnGSsRffQzX3Zd/JmmWalURX7AmiV9FxJJ5uKk7CtOnMoH7pXVzGaOeqk2mVfL852yinuic50r5gtHoiu6JOI24VUD3hfvJujs3Pezvrhnozf+TAasUPsFIpvgJ8YUNKA/enLf+JLMnsZAoJpy7TdazAHXnAPqo8KhNoIfrCh+QVVTp9Dn+07n5AvCIK9kjcrGo1DXbyOdBZoJf02OJLtT0AyD1DdvCvCMe8RUBZatXxFjXiFFQ7gZbH7tm2v1GFei3LvY8sWdyTllLrOA9k8RoC2b20IzIH/v4SPWmUdrXq9R+Z+HaOVjZWqlTedH+z9vwgdnGQ3HYGCw25uw4EhQJJdlI9zUrpQdgZglhU+X7soVrngbm76eqpCrFoonmGPTIblsgLw9+qd9zZgAZRof+uDoBJ+4c4HqIdBgGBU8is9YR/KnJoeY5bQTlgFOY6St5lEpyLsDIERj6+0A0aFF67VRn1at366wB5DNrQbu1i09twc8vzBNglYv2bhg7iKtrin1fxYpKdqe8algaT74+1DPvbekvPPHW5SKTbQWpGVa21kKutFrLFEhNOB5Kp1rMr8jUZqzSFzCme8weNbMpnw/Dd+aehMMjDGdkwen9tCcpFKAxv9pnuq8bb0TpgDF9ecrehYlfbNw1dMJzgClSMeM7ENwN+BX4iUU+8MwIbXwj0Y89PUDKJnGtJnpftuqoZ74hfrjw2UamhxhoxCuYPf3cebINSxih4A8fmXuNh0bDtbR5rqE/pJ/N3qNbDCtLw2WX2/2IhWt/NQXElgT5/Zkao139QSRaLMJ/+Z8avYIw2Pjt6Vc6UxU2Zks9tew+dmzIj4YzjuLckez2i2/bG69jCC1vglmcGIAQJkkRZCSe9f4h718xL8/4BqIlOeZQ0E/1zoaZDtvd2eErKOXVg7xpSoFkpfzODsS4PjnPd3GRWNFUNrcCewx1BBVXoq7hn9RLqFLoHzyKp2JbYt1zn0YBP3YWbLWAyowzDJBVOzPbLIKgDAzoLSPEdxYzeH/ZuL7wfejFhvU/tdySN6vKJucT/ZyMSTCkjYFWOMOEJmaKGJgtayOQcA1WpCFrjSZbsKiokJwHMNWAZm5Tq3YlPPBTcLmgy338YgdjB8rNDY3ZKxYzTrWJ8msKUP5657qX5C3qRgqdjCzrI03JnYS5tBWeBH++BXFcXg3yLcOHccKOvvXCIkq/5GE0E92IqQb9hTYkFWRk5OigR9EwAsg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR19MB4248.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0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ottf+zgjNfZnyUcyzV0eK33okvLY5NWgp6BQ58uOqU1FK3VSvTgXM5ubHpIJlX8rc6kQ3ji93W86EbRGmLNSpjKV2lsVAx9tUXDxfqPinU1pI4/edf6SWB+ncfT9uxR/v0LxkX7PZLE3AF2rKzFE+fX3s18cnfcGajSX8/SIHVBvpIZ4bdWYG2UnxmvN52aeH8O9aV1oniErPFhNW4OFWOovoafLXyLYfgNHuJBhncPzM2UOfZD1KLP60G9anFOt6BA/wNvlJIyOlsDsn4301CES5pDwptWA2wfKGdQdIu2mt+yyFgjjkdXYqiSYb6ALU/HTxT0mZ7RPtQ66Qt845sQgak10lrJqAUyLl4AfdjeNceVnfeHS3MtxKlMYo3YYDI6KVqp+wU6siitSlEBO73sV/CU7R9X88ReRw8SooELakBu7VYYAo+11dkTZU3ekXs44OQWj9q0QBte5XkBxknjgIaMormn/wknGyvYK39X+KX+xA+OalvCpK8g594Vec/G6zX0nS1nAdmA1dYjHzERF6C8AlXk0DKPuJHNg== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff788045-f79f-4488-3ea0-08dc9f6f1618 X-MS-Exchange-CrossTenant-AuthSource: DM6PR19MB4248.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 16:57:44.2254 (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: WqKcl5Hbl2Jd5CKOBgnss6ZhRNBbS8+vCf8BL3Wd44pH09ogyc33Gt7DVYEpEGfpN64kt9pKF3FqAR96LnLgggPshelZNlpmrwgoDtns3Y8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR19MB5028 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,