From patchwork Tue Jun 11 18:27:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13694128 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2103.outbound.protection.outlook.com [40.107.94.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 5D90814F132; Tue, 11 Jun 2024 18:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.103 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130488; cv=fail; b=YkopSyTHqkkcdA2wMjBKxL5XIUYe3VWgoQ8snj72CCsTfRYRWNaa6bwi0rnAVcuYCaD1Sta5Nb4XvG65Zgp0aCwkEjMmSDIPbZelFqnSrSIvVadCQ/Fatb0hkWOxemWdN58Lo8jwxOkJhHsC7Bl5JL1iGdiA+cmJsDiLrLDHWoQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130488; c=relaxed/simple; bh=WoNHH5duUhzgG0Stfsj480woqqSsl+cFqhXTFMZm/5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=nkwNwOwsmIfiFPrOKkL54hrj0d309YlOhz4aPcMCyjSqENKOlbpQrrx6Wm+Xt3Ukq3/jTe/lwlBFYHm6mcy3Wninz/Ttyh+SMEu4wJYFaU+fzRzrN7jkxHhbHvOrotpkwtQ6bjdU1T+9/t6LnTZ8z7+v+VpvxBkfd2MsqISv5oA= 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=sKhC/y/y; arc=fail smtp.client-ip=40.107.94.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="sKhC/y/y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FEM2l2idObSV7aTl8dFjanVABjMsQRPxvuM0XM3oLFRp80eZSood5FAABcZ+BuTNcIugdVlj5tTl0hPEr+bUIOp6s2+fF8sxFKsKcFnLYKHscOlPcHFVM8LUfHuP6pSVaumfu7mbiAGzHe4laqQBA22ZGOqgzcw7QEM/+HivMy5yVZ3K9m15Xer6eeZtqhRg9E6BoQwDSRSJ52HSRCojr49G8sWahCFaku7VgH17QVvu+eRRdeg7E2IK+L7rxh/f5jvV3iu7s/AvPjEwUKiET0pmlCINRVjPXbzaHHZPYIIHyMrQv9HjSV2g4AH4LQfyHzIbHgegsxfDDs57dF8mGw== 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=egpQP0BDXYyrYjOSywdL1sJt7M8DqRDf4NFqGyAHqgw=; b=fOrHqNHaP6h1juK8bd8cG3ceOGDwScuDnp0x2MhCdssxN69+fBViqrQ7EbT/fJM1Z6RVna6P2KkAv68omX2iy4qtDiJ7frsbtZO8dvgGtBsCYHOPyX356ygfyi+zZY4UZxK/MzDVHCZFla7HCBaoCpB74vn5wQHZ79Qz8SObZT1WOUuwFJF5rx4x4pWgtrnjipR7AF0fJCv/+tVwCAGuvw+WEzWGq5CREelEU1npIcR03aMSuxPfX74b5QLijDHzboCe+Y3ztCd4d+OvkFWOxVlzQtbXLHzdESU7BM1ioL39crrKXcrpUoPb83D4iwDm81I1qiA7p1Z2Zobt3nto3Q== 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=egpQP0BDXYyrYjOSywdL1sJt7M8DqRDf4NFqGyAHqgw=; b=sKhC/y/yl1oMmZVZbF0L6LFSZstZS3C3NsRYboja29e7YYprCvucDqv7SeyJk2GZAJ4XLeZTB45P9pWU/i1e34kF3AyeapLusl3gq8G8mRUCGuPUiKi1lhnpG7E5Q9L5J19IM3Xf0fAKTnVj9cWP+Ns85qApwKXLc3qL77YawdA= 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 BL1PR19MB6105.namprd19.prod.outlook.com (2603:10b6:208:39c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Tue, 11 Jun 2024 18:27:59 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%6]) with mapi id 15.20.7633.037; Tue, 11 Jun 2024 18:27:59 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Greg Kroah-Hartman , Tejun Heo , Andrew Morton , Logan Gunthorpe , Martin Oliveira , Mike Marciniszyn , Shiraz Saleem , Michael Guralnik , Artemy Kovalyov Subject: [PATCH v2 1/4] kernfs: remove page_mkwrite() from vm_operations_struct Date: Tue, 11 Jun 2024 12:27:29 -0600 Message-ID: <20240611182732.360317-2-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611182732.360317-1-martin.oliveira@eideticom.com> References: <20240611182732.360317-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0113.namprd04.prod.outlook.com (2603:10b6:303:83::28) 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_|BL1PR19MB6105:EE_ X-MS-Office365-Filtering-Correlation-Id: 81a4b7ca-b8aa-44c5-03a7-08dc8a4438d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230032|52116006|376006|7416006|366008|1800799016|38350700006; X-Microsoft-Antispam-Message-Info: YCJajgWDQyWZTP3DQAv+qUaoNx9aV5drFpQgU4ZY3CfIVtlB24s2JlsIyUBsEbnnj6EzeKJVXHSKqSU8CdbnGIPZvI/hdV+Nh8akksywCbjYxYrlXyxzEnJ2JQgRSJBmx6lMbRYYTGHZbwuU9/1HcSdgSvnk5R82wF8kKpxZlgwz8iB8MYfdnJfSWI2b52WFH6sm5JH99/zi42IKfZ7qhJjSrSHSe13dnNGmVJ48fdMb3sytyTvRmqKN6o1RCoa8KvLcx8TUkJeaBlrxXFSwMqIEfb8JwwaSsDStdTLTd4RF8G3WcTTLvZtIWPkRYB+1CSDiEnqijxvRDXfpl44SpxwzAEkRt61kVVQUJ5JF/WHjJeVWOiGD3lNKzyStlb5DZJgQ0uEpanROcGWqaBvCcBHYkQEc53G+n2SRTlh2bmvH9dIMp7amTsx4a0oYazHcmW0r2NJ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/J3+JXwiIuCKfWrD64ceBSbrIrM6fhstQatIDZJD9jL32HqV7lFGaQolxTN8QPEnAOk6eiC3x5kpkVFuX0grY9rEGtjmePSRlvVueSOV4rs4h6YJkcHi2eq6o59yEdPp3BqOyoNCxD7JT0XqUgv+esO/xs+xkL4jZRX+uVrHS6B9w70/pyOeP2CsXJHrW1J0qy28/tHmsZEDegE8gFGVgzKHpne0uWchi7dl3Ssjkj5A556/enKcGIhZuOEQen/qZR+dppwpYDpJh5gDZ/TvnemYS6FXHnh9QJL6QUIByka59POHkJOS1/vkUiYiouH8rn/pUDzt1KpdD2pWOVQXMGErYLKGNfrOevFgCMCSx98Dfi8JaaNpxDv9euNIvJj37+8K7N6IIhQOhTXERdMcTo+MA6v9ut2AWRZSmZP8Iewjn9oP734mBwaa5DCZbG59G4FdOpoC/dRODA14vrEI4o2VV/QsDvSTVlPIES+0sIV9U6KdMstpVBLWJGsxT+L8b0n92+CU6pxgDE1gSaS71t7P56q5//JTIEVDUM/IRCmkM4DZVzkWpzgLrhlkDvxJe1VldeNSR65DZPebILySktodKBI5WTDezb5b1VleFwfAogwNyTBHczQTt08WrqYumOi776YSqWX6+rctC42gpRw95gs= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81a4b7ca-b8aa-44c5-03a7-08dc8a4438d5 X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 18:27:59.6764 (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: EnirLeYvlppbgpUVSXko/D+lRAutQq/Zf8NzJpbZTnDh4YryJzpTnYiR2icHv0LL3PvEftfMb4bt43wJUrXcu/fIvfDHXohJtP40drGiHXc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR19MB6105 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 return -EINVAL 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 Acked-by: Tejun Heo --- fs/kernfs/file.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 8502ef68459b9..a198cb0718772 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,9 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) if (vma->vm_ops && vma->vm_ops->close) goto out_put; + if (vma->vm_ops->page_mkwrite) + goto out_put; + rc = 0; if (!of->mmapped) { of->mmapped = true; From patchwork Tue Jun 11 18:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13694126 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2103.outbound.protection.outlook.com [40.107.94.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 CD06774BE8; Tue, 11 Jun 2024 18:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.103 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130484; cv=fail; b=eeZIWkohAwQDkjihF2oJle41DTZqcLCt5JTtz4e4EnNAzn5CDsR2ysQC7O8ro3nHfUTzH9xfKbRfN+muzEow3C+S/hk0ma84XBrCjMcoKQa5yKjx4GJWtZh12uyc2Stq8wYe8ku7X/NmukC/Bp6P+4nJtusWiT/A/2R4XI2xDg4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130484; c=relaxed/simple; bh=1qyHICxpg0eWsR78ZtFM5nNtkrN2NQeSGHqo8ejVsY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=qOcisc30SX7V5C96xd4IZ1S815dF5tAZ8CVBeVWacvrQYMJc9d6JTB7go7kDI7z3IYdlXlgSI860I2yut5bJwex9lOFMhg4xPWew1//TbKhtkaJgnmZFutQmTKDoeTzNXTJMu13y3mbDi/S66x84shlM5QDP08Qt09ZVWvEqp/M= 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=HEJve3rE; arc=fail smtp.client-ip=40.107.94.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="HEJve3rE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aTy3VFsaMVs9IA4dnVMq1VHuRujiPjQGjQHgVIKcyPw6b+uabjIKMIh/5UenG0q8ja2R1cxV+fB2mDpdJmZgdK6ydF8n+Z/3R1tbORElAJZ5V82bek+V+szUPC3Ws7Cf9ywcQZnfmEiiKW+geTB36408WQTisJNBVI/Fx0CQlUaBQp49HIr5rBvUshzd9l8QsVfDDKslTU7igN6dO0gPwGGHiaRQnWJJWmn49lmBVotLSmbpPqa54pbCl/mRjIxOmcHuyGOwAADX73tdVCEn1fhApHIyXSyz2UEE8zkVTJ8yCbdwl7iozna+zqHfeHH5a/eOCD7jryVITvf5wA0skQ== 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=ltSVTnfSQLBLzvKgi3YJev86956nJV0gsu1ICDHeH08=; b=meZlq2UEv68OI0eWIgMUPr0STfLcz96Ewe2fcCcBYlLJSpBJno6nn1EBqNULjsGduoRrLcQ+Ot/ufMMaeMrIzpWhhOcpw+tMHCkayZVvP7PJnUr9B+xzaFhhMBEll7y45qHUsdhP8jrUI7VaYyCmjxgVnuwljSMj4oqVREG3M24gEusP2WtPqHI/8FRiGfeLI6sxywMr5d6GgfR3yGNZnPL25dttmfJl9uea8b0gCxo/dohLfVgGLENEXVW4wwiMW3QpJH2Wz9FGYZ+xFHML/D7n64pVsIA7xTLoKR8khp5W7ZfnG3i6b67n3CIr699alL8j8/75GtKX0KpouLzJTg== 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=ltSVTnfSQLBLzvKgi3YJev86956nJV0gsu1ICDHeH08=; b=HEJve3rENKbMbnHsMLEdUMGIApejn1xirNlUhkBn+o6RVl75vidmlG+8T7qwcXSq6H8VIRpetsF9ZJrNsdITs/prFiKGzOKX3pmHIFSeYqQjKDhH+Gx9YXsJaf+5JNO3Hx49MX4oRMCG4zPGsb5VZmEsQbIolzXKTd1N3HstWMg= 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 BL1PR19MB6105.namprd19.prod.outlook.com (2603:10b6:208:39c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Tue, 11 Jun 2024 18:28:00 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%6]) with mapi id 15.20.7633.037; Tue, 11 Jun 2024 18:28:00 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Greg Kroah-Hartman , Tejun Heo , Andrew Morton , Logan Gunthorpe , Martin Oliveira , Mike Marciniszyn , Shiraz Saleem , Michael Guralnik , Artemy Kovalyov Subject: [PATCH v2 2/4] mm/gup: handle ZONE_DEVICE pages in folio_fast_pin_allowed() Date: Tue, 11 Jun 2024 12:27:30 -0600 Message-ID: <20240611182732.360317-3-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611182732.360317-1-martin.oliveira@eideticom.com> References: <20240611182732.360317-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0113.namprd04.prod.outlook.com (2603:10b6:303:83::28) 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_|BL1PR19MB6105:EE_ X-MS-Office365-Filtering-Correlation-Id: 78715319-eaaf-458b-c874-08dc8a44392e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230032|52116006|376006|7416006|366008|1800799016|38350700006; X-Microsoft-Antispam-Message-Info: RRYhFr32mRS4mCB0QCqgCeM9RORNURaFDYxjvYtxb7oTFhmfUWd7kHUnMNd11IeOqOaVnxd1dxxD7HHDv1tc/1LwAtt/8gNN2HDJC8PPNvVUdz3osKdREzSuEaYUsGvrfCDtjWJmspT/NCJBd98KrCsxOK7NKSWmlFTKwoYbtc7JMpIv3Kr3ozzPZ7AWtDwY7QiQcRGEf/SfnCYu9Snjo9Sl8lOrDgPV/Hx1jdCXBLMvojKRNyazXBCdz5s5eWbHXFCRy3hiwwkBbTvUFkhSMtjIk1o7kHKCFadNzBeRjQ6qwZP3CWi7FkFanlexYot1WgYmB2vBFk27sYvGJtvd3lJGAk0GGX4+Bq2E52Sicjsb8iwG7WY7zMMsU7Sj0aQpC9QKMmS/d0l14MzFZW4bkB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ook.com;PTR:;CAT:NONE;SFS:(13230032)(52116006)(376006)(7416006)(366008)(1800799016)(38350700006);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: snBOHwcygg3ghtGStEnwZeut5s/ucWDTffUeYOj0/XiePGJcChY+GeAguWriPHjMft0sYKlz0fngc2dvxIlKny8GXIS7shkH37g5jynub55pM3o9byVgYui/kEqn1egQi4x0TJRJh8hV73MZa9Qs/kt/jlq2PBuIQrgVJ+gTGg9jdQffXGU4qoN54mmFAwNIuIXtNFUhqd1wxmjgTui2lNbesL+h0TzT4/lmRd6Np0Z5hzhJ14aqyx4VWR8QUqfe98dNA3MUrmerr/+5mBve/0Q3i3P658tiDlDA3/29+fGrobSlxMdygWbinmj6kX85AB3JnM2xh40vnji3Rco8vNVCjpyrv+EMGuZBB81nnlLgf+HeUpunT9xcCha0pmKcz1ZjSPvgNCjkNGlT1qzhrvgfSr3n4+ieR7RMW7IaiRh0QBbnusVWXjR9MIdGSF5NMTLVYt39hNvoqoBdwhPhiWzo9a61YXzQ5eWZmbLVLnPQnYWrJQ9lpk2EWEnCaPPcF5Oepo2NeKzffdYkkL7dMQmPo5CeJsc0+gOl6zI8uVXAB472ILvbTrgAH0XRQrewhPK8MT+MLXOjIQ5voKjM0s4Z9rGd9EUwLiq5bDzZ/jNSuyZgyV88OBTDVXHYWSGVy9Q3mh8dB/cklzcLdGIL5zcju4lqOGeRcVPzNEOGHM11eORFqk+UZTXDYE5pvJ8Jc8BvERb8mC4rPc3xDKNX2Qor995DT5Z49tTsVSAZC59o9NLvUhNVmc4iB6rsdO2a1Fw3oHaNEJtHuo9zg6j8QWq1rdvzEOYBxMoVZZ3+kGkUxjkOKWx59b6diWbYai4ZTGMi8EEgzEaRTmsaQB25xuZY3iYY3fz5NfLYLnWpIGt7UBHnSoY+SF3AHj6M0qxiWa0Ms0FPSoW0Im4XrTSIsd4DEKKpEYiBz0xqhgPhjaD7Xj/4zXCAOKNKnwXYSxr5p7AnTHcWxoGveMM/UxBYAPpNggzltZ9fPy3ZqR0C3cxBAJ1HPCB7UyHGbtTs2vw6u74UdnlUlews/zBn0sgUGmyzfWsNN/gp8tw94K+k30HRh4oBpF//PvqTn3G+cGvqqPWpLss10kPX0o5n5B3gJsJroflb/wY5D5Qt5AtRy1uC/68ky0RhLIXLNTgyZslG16S8+NMWFGSYfocQXROg55aeW7COoIAsXUbqE4j2IUxvloB61fPJeLHw/p56f8dqEL60VJtkXWTsI3hGa3OjKm6aJ/6T9UeGJWG/US2NbqrCmMjq1H+F8DMRnMnLJltL6dLwfaBzKTSxdCr/b+u9jWCUFUY3Zuy8N1TNz0VmNVA5CQf0y0czx7tn1LpakoCDymTDD5OQVly98pWv5qJE5XqUq4a625WTCEhxpIjzDJk/rCkwBbFl+btVpEv3XYfior1mqa0RZROMKHyNUAqh+oVhfyRQp9dWL85b5gDkK/Jwenc8cqQ+Gfm/kSs7wmD9EXtDNqgIWBN/kYliRsvJAK24+4hbpF6k3GQcHSzBGBsGVcnuLwEO5Oq4YnY5sGjAStYMqTNsyWCB+yBlkSSgEGQyGM1FaJv/A/Dh7SFIi3T8lZ9SYauFQT3LFv/ITGrsqqG6H8kj2K6I1j+1lpOGzripXR9+tIRr03db0QQHSIM= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78715319-eaaf-458b-c874-08dc8a44392e X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 18:28:00.2550 (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: 28F4sPdzuvBC2Gu7EfwX1vd1OefLwuatUANqLPCkgcNSXLk/1YNGYZcFKH3LbMYIFwF0Skd7GwqtwXn8w/S5WdIvm6Hl160g+3/tnL8/PuQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR19MB6105 folio_fast_pin_allowed() does not support ZONE_DEVICE pages because currently it is impossible for that type of page to be used with FOLL_LONGTERM. When this changes in a subsequent patch, this path will attempt to read the mapping of a ZONE_DEVICE page which is not valid. Instead, allow ZONE_DEVICE pages explicitly seeing they shouldn't pose any problem with the fast path. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira --- mm/gup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index ca0f5cedce9b2..00d0a77112f4f 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2847,6 +2847,10 @@ static bool gup_fast_folio_allowed(struct folio *folio, unsigned int flags) if (folio_test_hugetlb(folio)) return true; + /* It makes no sense to access the mapping of ZONE_DEVICE pages */ + if (folio_is_zone_device(folio)) + return true; + /* * GUP-fast disables IRQs. When IRQS are disabled, RCU grace periods * cannot proceed, which means no actions performed under RCU can From patchwork Tue Jun 11 18:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13694129 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2103.outbound.protection.outlook.com [40.107.94.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 37910152189; Tue, 11 Jun 2024 18:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.103 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130489; cv=fail; b=j12z+ty1FwDEn0iiuhAT5KcgV9NBBfo78T5svmVuCsSHC3UW1RgHR+hN/QHf3kqQjR6ggPslyPMtGd1fWwfi5jcv9nz/Reoyk6ftnCC4+pqDGL3tLzIWIMM4y22CShrjGytV7e8D+OQBFhnesc81lMSYUg1hYOysvCcLPOSqAgI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130489; c=relaxed/simple; bh=ZFVugkXFJ6vMuDHbM6Ljoc5XOaMzE1P5XxN3vTBByrY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=H9ygkWMjboVc2EAR8NMFs4qfx5jJ1yo67FapitpvDHzvAHb+CTVFRXAm3TD8spbaFrgvlaHjACzfOzVWmbB1ZLb8tMbA9PYTQhm7widQMfSuvK1nyVUpqbHwTgPStm3aSbrHgak8TTZvNCslCE5eO22yog8Ghdzj51/mNLWhbUE= 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=UvvugJeH; arc=fail smtp.client-ip=40.107.94.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="UvvugJeH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aDPsNzeJ2WK8Hgzp6FUdQpyEFnEkm36h+P5mRktLWOukdOjnI+RBOBsPS24O8/rXvxQdv1botIquVf66dBCVJDQC7GfrjbZsEeuhtXxwe911jPh01Qf+gKRMVIe0b9E5Q6j7JVhgrlaHlGiCGQ0r7mJQ1Jp76c0ZZl6ogtx9hPEdYWqpE/acpPCCRdnM+S5T3bW01SGjHJe7yEltrKTaDM9hdwAnoqWydYnsDVocbZ8vjZNuG60DlYdeeKjPe+LZo88h1Ve/0KohIB5owEQmVqrKFXuUuApZ+b5p1Yhq/WQ7i0GU0wcUHEECpLyxezTREVatnny3OgHm9CxhSe22VA== 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=zF/PKkFIEpEBi0OtXGW3K1kbUiVKvbhfvU9Blf9kNxE=; b=CG7O+Wa2N/dE61NiefZtTjXxJWmghTgutsbPIkT+OGLVsN2PuNagfBi529MYfv/uZ5TPzHovqBVYlPqrOwqkNImylG9vPyfLvFF9/DQ8XNXFX0guaXVkQ0r9DUHL2EBfIEAnWR0mpypxNZS0KVmygMIkRkp3pz6B+zGuFaKq5rvQIKv+qk1fUAR6aZdS+UeZDBrB1bGGtBfKiaBT5Mf7wPfURnsL/wFnKM/6lBHDdmd1cY2J/vQ2X0LCIU9SqkaNJmq6yWFvXq6jK2NxkS/uELYyxkX2SczCbobfVH0wj4nmHjvZ0A5/HlZgpZgWa9+jKdMQGwpRXBXN52YGcRJ9Nw== 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=zF/PKkFIEpEBi0OtXGW3K1kbUiVKvbhfvU9Blf9kNxE=; b=UvvugJeHYLU2LstTZQezAwC/fTVyLQ67WvHpZ4rhQpqZxDMsAqlUDVkgnXOplncOHYCW/zFTHWRtovvJ9IOANevGD6tHQ1F2gUlzG/V7qAD255sD5BgGAUwk9pPAIgDdQlRcraHAVasK9noWzG45SEH8ALRGh7MEpsXB+CwmgyI= 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 BL1PR19MB6105.namprd19.prod.outlook.com (2603:10b6:208:39c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Tue, 11 Jun 2024 18:28:00 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%6]) with mapi id 15.20.7633.037; Tue, 11 Jun 2024 18:28:00 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Greg Kroah-Hartman , Tejun Heo , Andrew Morton , Logan Gunthorpe , Martin Oliveira , Mike Marciniszyn , Shiraz Saleem , Michael Guralnik , Artemy Kovalyov Subject: [PATCH v2 3/4] mm/gup: allow FOLL_LONGTERM & FOLL_PCI_P2PDMA Date: Tue, 11 Jun 2024 12:27:31 -0600 Message-ID: <20240611182732.360317-4-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611182732.360317-1-martin.oliveira@eideticom.com> References: <20240611182732.360317-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0113.namprd04.prod.outlook.com (2603:10b6:303:83::28) 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_|BL1PR19MB6105:EE_ X-MS-Office365-Filtering-Correlation-Id: b11f0199-e03d-49db-795c-08dc8a443989 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230032|52116006|376006|7416006|366008|1800799016|38350700006; X-Microsoft-Antispam-Message-Info: Jm07reK7DZau3aajiTfA1ptGEq1+spLddj5HxUbys/JyDmNotM0uwQqqOgAtyADVwi6p/BkFrmJcM5PHVp+qZBL1Qrivq3nFFF2Foegz7uX0+4u2OBJGHqd3rWS1Jpkc8aJ6c9kX5B0UIYpOS7rXszASXHnWbKp1kAOgBLk9F6uKRRXFoNaiANLsyIy/RikR8HH7HB7sp/nmxTtrnff5R5sdHXzvjRn9trnNdSRK8lxZFsqnYY5i41cty9zNXgMqPmDvqhjxrs3HwHmYf1hNhwOCEadqXjYmlAzebRRkL/ajOvwifjau1SNaUj/Tywk9iazgBsC2/LJhzqilOpYfFXYfZ/xRVxkHatD0m5cbwGC16QTaiuPKeLWF3syTNvliFkErObAkD/rjnAOTK0ZVZE1BXKGbQEEPGp8K3vFjfDroeLJP3dfbd21PEQPUUB7uTjHRB2QE7pknoZfLHqPN9AztQ/zlUhJcY2p2LL52bhxrpDV468eihQdUhPNAhZOXfuGIMm1/1cgo861CvnGHAtUfYURQNgEZzIWJ6782+PgwKS0gaA9JIID2uvAJ9oD7MSt7jbBPE+Qnrp764XmgrfKNgAmzSeO+Qlx9m/0fafW0Y3gC9RXr9tOmIRqzzdYaI0ETvnFyTVSrlhs/+5HZ/VDZG2Pl3PQ9y0tbo+wye0KPEUfXnx+WK/v6usZn6v3hv9Ml0CT3UVn6VRsl4q/db6VCO8YqctQFofN5Avh7ych2S2SPIrFUJSDM3NihZprxhRDCQh/e6SJ5wnaA5vrc26bhwQDqaLgow14a8FKIkdEgsAeVrSy6F1sMKaID6ZVv812ly7AQgpw8kT+wrBJZ1iXGkVIT074IPLgylItmOtQ1NHOHZvr1mnDwV7ZChGx73pWwhrom6+vbpz4snS5HFGOka9xzPQP0RsUsORm3HYGNlrOgGKHDRQJCC61kE6jwFS9lbyl3HGdaFLsmDG1fzNIjCzzy5ZZWgYfmKuDmZP7BV9gJwJ9zckgvvvRJLOGlLY6uDp7vLaujw21yd6+qwDVAkKXMrOqgXLig1Zw4rGTtcCqbOuDOZshrfJfPYIM1Gnwo6zY7PQjgPwr1iP+0/uvEpWIy5lcIDrQfSXQqjZNflaDi2yETVWovcZcfMf+/yHj9zhSADKZe9e+pe5sE883NDICQ8AsOHxrjGZJXKolKGnBIcVXjuy4pqtMxwQUzvL7fqXFHc+jSRp74b+Ca3fz4FHrQPkgKFsFzIUbqQM3rqr7iilQluM3EpsB3WrQYZ/nYQWCwbthHQQnJUahXil2ertJbfaWLLSw+yVlvYiJWKSUGtqBXzCZ3WzjbPNGx+XpgLj75BaHBvHywAdQPPoYCs6cL9nyTYLPInA9zghU= 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:(13230032)(52116006)(376006)(7416006)(366008)(1800799016)(38350700006);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e7pxCw0br0O09d/cMsORV34IFbPwK6UAPoCGnmdDD2mtZ2c8X0pAhRytykLYXYDZModGkc5U+9gL/H6+E3eb9VVLJfFUd1lxCLi4PVu45vJAUb2mksRNu61TatyW/77ImJWNiqEgCEbAElF14Vihyvc/Z7h0g5MEjx1zxzJvI9fb5n6ilTimV6R+jLceaG/74SP5ShKE5p5VVc6KqMIdt75rKFdTn1zF9sWWgt5eyAFF19QOvKPYKfwLvJuCkj5S0T7tXvbl7f+o2cmNThoDy3+LzZolMQpnfN40H7RKWqGxW62+u6Qj8MG5HV8wM7+wd8VKtpknvilZKr3qGh6QZX/1kagIYudm74Tw8qctL1DD+kql0cY3eIEYNi45pq4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5Q5VF0ASs3hJkhpJiyA+DVYD74QBALXiwT6SXrXufJQ4EUL7TnEgq39d8poqYztVZw+ecKthodOr6ygUUqg/t74w9sb0J5IINCS+1BYb56E2/w18NCtB8zh3OBu960t2kZHCdTcOgPljAiC33kJlDAfaIbe87MRnPRO6Vcucf6CgnZQath6KxJY/7M= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: b11f0199-e03d-49db-795c-08dc8a443989 X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 18:28:00.8665 (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: v7F/UZ/nD4KIBmuJSzxA0TBQ4H8LNiL1N9KMB+uORylsg68kMyuG2DlTJPvBZwHJNtE5QOWaAWxuUa7eLvi4rUQBjqEWyvAp/93gKRYZZ7M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR19MB6105 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 00d0a77112f4f..28060e41788d0 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 Tue Jun 11 18:27:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13694130 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2103.outbound.protection.outlook.com [40.107.94.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 07F071527B6; Tue, 11 Jun 2024 18:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.103 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130492; cv=fail; b=QA1aLjyvOeWMZl0ff8w8QfnSfXgF8TSSKN1xXvVxoG7V01iOIJM3va4IOL47JFZpCiJ7beDVHFgNIsJfeGp/3AKKvA4VD5UN6B7mtCEkOsh0NC2XxUTsV9eBGEMGFMCO3bAp3n2aCg2YCWb+46TputYGK3qsu0y1hoiENd845n4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130492; c=relaxed/simple; bh=IXBEWYopPoD6OpN+sUxXksUBBaWrlmVhCGXuL2Tnjr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=EbY4h2pSMcM/xLSf3c24ytM1Ix4QuiPH2QAlE+8wOTT+hbAK97mgtyAHE9WJw8hqTEVSL9ozBlalTUn9laZ+9dq9r6Cg9XWt3uhVYdoWIlvtpOuP1L6+PLiuCbn/jotW4ynifRxl0rXhWlFtMBTdfUfFW3GE2Br3CnwDbds8MSI= 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=QTeiy5Vg; arc=fail smtp.client-ip=40.107.94.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="QTeiy5Vg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HHPv94/4NYgc+yrQA43KgpiQ3tU4Ofy7LopO3JPab5fgIZz7sfZ4v++KFSKkTN4+7d54IIt4fPwQ44hcGyHJKfZ3AAfaT1kNCibDDXs8qhiRrRHz83JBdgezz+kKuqSEAbeb8Yy1A3ke4UThnIOAakS9LN4k/iO9Uw0HwbHTsBlUSYqH1ziEjwMXEYBZVGrodK2RJl5revROrP4xovSVdgG7FYIw+Tgnm70nD222/tQzHBtd05I08uudRw6Y5QDiui1ZuBikoyNnOdGbdR0UuMf2f8rWsO4agdTpQK7NqEKFNhbER/MkhBxHevRZKyYifez0Tc0nEoI0xhfSFggerg== 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=gvCcvfD9XrahsrBCD4LSwm0IoahU4H0qyoBCobOTXhU=; b=FEvOcS295EU3BM0NDOmpLsmqWRFKpR843ESEhiFn+jR6xQCogR3k6l1qoQyS5/znLVG4ngdY80IAtwXOMzo5XBEcyJeru8H083qmUJ04VMyyzjA+IlIttD5qqyFqyD4iV0RO0+0WnhfEM+DFQV4uOI7SFEVg9kT6wYgAWkpktPjOEalFFWbmEEy4eTB9zfgtOsWyezu4guO2ihdzpEEYpaGVMhDGWiLOXotl5HSy1eHAA6x08uXlMAuuWaolvMSWxQ9+8hPl4YQbgcRQx9/LtfcEb2bho7Y1Z5uqpboTALO+crNbgjejMnP3JiyMtIbM7eUL8a/pJS4h58U4Kg1k3g== 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=gvCcvfD9XrahsrBCD4LSwm0IoahU4H0qyoBCobOTXhU=; b=QTeiy5VgaRI/FsOLUlwLFDe1qgC8D/k6PT8t/cN48VAA+3yCw+1Ygy+G8P24csDVhIRHqd21aSl240+u895x+LyzBKLHvHWN7hwnUxBb9u5eFXtw5ZD58rMNFYsyG7sfJEfsBW/213ZPJU5BlYgfTXKUnew7wuZieS7nmusw/Rw= 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 BL1PR19MB6105.namprd19.prod.outlook.com (2603:10b6:208:39c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Tue, 11 Jun 2024 18:28:01 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%6]) with mapi id 15.20.7633.037; Tue, 11 Jun 2024 18:28:01 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Greg Kroah-Hartman , Tejun Heo , Andrew Morton , Logan Gunthorpe , Martin Oliveira , Mike Marciniszyn , Shiraz Saleem , Michael Guralnik , Artemy Kovalyov , Jason Gunthorpe Subject: [PATCH v2 4/4] RDMA/umem: add support for P2P RDMA Date: Tue, 11 Jun 2024 12:27:32 -0600 Message-ID: <20240611182732.360317-5-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611182732.360317-1-martin.oliveira@eideticom.com> References: <20240611182732.360317-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0113.namprd04.prod.outlook.com (2603:10b6:303:83::28) 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_|BL1PR19MB6105:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a8f2ddd-db78-4eb9-4ae7-08dc8a4439e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230032|52116006|376006|7416006|366008|1800799016|38350700006; X-Microsoft-Antispam-Message-Info: /9WyAYOuOMhT9KUFnod/oddFU56uiOZt5NRKABGc9HTPlYE1IZmJwmBKttmadUaw6N5jOYulqr/exv1Ao886YxVt6g7p+7Eob2v0puSX6DU5xE37YM8DzPjojAcPUU0vNStqqxI0FvPzg9Gi3cGPx7VRMH/sgFZ9ciX1fNJJZ5wrFVUsr6MFeYvGUJYw31vG/8ijN+7o05jLIzm9jKMXACH/P8NB45mR55ayLfep1pwVf/YYrXHb6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YaW1x/g51fcXipaaJj/BAzMBX3e7/1hq4hw66kc1JtAvInE/ZXyetdX4RU= 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:(13230032)(52116006)(376006)(7416006)(366008)(1800799016)(38350700006);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TEy0VCfL5PhTY8q8PXYLsIvYXOD0eOmxZG5GGLayO2B8iWO4JkRI3MyYwaCK/RWruZwY/3vZuP2STXLghIOlscAkNTn5eHtb5Ig261fVTW/k71eOQULZzloE8cZaGY1CfUWsLL875LciboCzAPnpQ21376hBeEla7wCnCEoLbqfPnKG89fXx9sHG7okwSyedlXuIkEYRxaD4ktnF2XQBIov2J0TwdGA+vmQV29l+GCHeyVxv5g8haxq1bes/HFY9e2d21m8qWYQnFnxXIqAvxQFioKmxo/fhzp/H125bew2A6HHuvwg/ChQA42nfAmjOPjrFnmJDgIjYWmw+fUYOl087XONxha6bVl3oFoNXoRsmuBdxcbzHOV+XHJTF0YTdqj+UEMABflg0YtqBR+sbiqBxRSfMl0UMfRD5hDKTQNom1/bmpCE33gar01QwKb8vWSepv4w+SDfSn141rN/7FGGiv+RYpnW25xseRFJBD2S6lwt7zNS98CzCMLvZrbK+z8LUXLYa+DwetOJREVZvH6X/pEuldDEbUarUk0MtnqQXEOL/39arrBnEQmjD9OgsLRgZ13gERbmE9R1LI89cLqfwe7WN8P+B2N2ogZonrn1p6A1aOlRqNrHA9bfxqtcGZDmyxqpyCnZpyVmhmnKYGdfLiJrYY2FwcNPpW5hPhckuNAmoStBwcw3qc9lu7fk1DEeTiVZefjrPE/EvYneXGa+DVmBuh8NBNUmmN5nlwvvr409uYH4H0HKAvkPzyfd1MYz0UK88yHsup7tlPfkcxynP18QvUz81tyGWaxmf+7I/KG6wHTELqBllUXgxEECpp1EyDhi2VHIbqh7LEbpx2zU6/HBHNr+RDV8aJy0Y5e6xXA+cMrTPFF/9rBWQxgFaHk8AeBR/fi9ydmVVBxIMg+LBWUBGS5NV/JRK0GfERgJxViJGOx5t90mM3EmAA3LvhBCFEbY1HSEw59SMxi/8UNn+arvRmDujzSr63B5bB7Z+tZ7kxTD65/5BFzwPh6my4DU2a6gqXyE8SrQ+6tz8qgWV2DyCSGhidlGMX73QCstiyXQe67wxfRvCS/srf+huOt5tlq4YEHMtNMLK/GBmd9ztn8aA+Z+jASt8OAlZ2Te8jdOZWfBqKmVyy4ProVv6emA9NAJNrt6TuhXnyzDaOwzpmENUKKqMCnh9RA6G1KS7jOAdP3hubEDxR99HEzIqqhhngDyDmsL5030uRoYsqmzprgHjP+VtYoy0HVFIjvngdvyUZQEwPrr9Ybdjv+1v/N9ERfSWZ59k3TIwplMnOTgznuC2+DKa3c6Nd3nbdeM57erIH4/TIl27051HkgKnFjHfNIsu1mYAYE5ts8jX5M9ewXLCOBvFwric67qm5G4rfgyRljXDYSExJ6BdJy/wclyvPV2LWrkgP8QGv6m31gwJGiBCnZQPc67zSdkWcR7aOJmY2r+EufxBPyAfxwhhmKZdXe3NR10gPqkKL7zxLOQ4gornp/Inc9K5UWos9Q2BLhfvX5TQ/VtPw16MG3X8Zogt0puTPOF8MAiDdXcPGcPTw38rwbC39lifo5HhF/4m+qOOoK7NlE0lGfoCXsgWuCvEyIxEhyRy9VsXpgDko2TQQl7CJ+IELPtPuB7DnZI= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a8f2ddd-db78-4eb9-4ae7-08dc8a4439e8 X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 18:28:01.4494 (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: d9PwHMXPkw6nRjOAwcpP0DzfD8sY3KkEObxz6kA2K46DzQySUUXB/TGghyLVTsiTMoIKKtZtxnvIejn7k5By8ThWnjjIA+gDZpgP4fX6evo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR19MB6105 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 07c571c7b6999..b59bb6e1475e2 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,