From patchwork Wed Jun 5 19:29: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: 13687386 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2108.outbound.protection.outlook.com [40.107.93.108]) (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 085D714F9E2; Wed, 5 Jun 2024 19:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.108 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615819; cv=fail; b=sSGuKnbmqlRZco5iNh5csgFMRJxNvPrgAeQwfUCU6NI0nCU94Qr8TQ4UjfPnxCxmOkBxI4nlaBAzyJBiu2P2V7yfaLx/MqiK9onM5rCTgpO/3PzJd4dfVq16lh88gf4pGH47fuIzA6wXPJ4KjFhv42YlckDJeB5HUGxwCwmUhAw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615819; c=relaxed/simple; bh=8W5nGv/3FT6rSUcTLsAUsYjbMKa6DPmS30/tjUC9gGc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=KEiBZkIBY9/bxuvQgl7/qhoBZCkGvQlV898SEBa9wSAki7nVqR5ag3PJ5oXQG4cMzOg3XTSKcg7uXJkH+afiilN8tvrdpVaq4A2SXKs8PywjZHCBctUt8JTbrkYTDpQXqbJj5pJT0rlW2ZLUhTjexpvBeH3Dtsj3d+xmOq6aENE= 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=Myi75pSZ; arc=fail smtp.client-ip=40.107.93.108 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="Myi75pSZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MLGYPz+RBH6dfp8xqYoeUeBBj0Fwb2xXTdEJsVPC7HGOCMje5Y9YsdY9XaxBPG4Nlo8qmXEfsNRf0Bz7OZ9mr28pUjAeQvAY0h2xRao+RXtuLk1pKjnYArflrxVjpH/0krlkCbsmeqgTk5IneW2e40X+i/kopMYmilQ+8zenwjr5lItCif0g205fivAyMMpb6KVSf6hMAW9wLoCJQR1jExw5eXPOV560HDDyVZYAPCpvBeFR3yj+nkb3DjevbIIgq9WcVCTP5TgFnlOY8YzxWc7hgXgSLfXUslAZWkZYFo2bTWHmioHET2bEyUMkcmC/e2SOo2T6WUgRST4h4m+l5g== 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=KK7cpODuC2vrnu2LI2gP1Gpl8QQ3tT8dvcO1Znjx7OA=; b=LZwTGCas1onbv5Bgk3wmvlvl2x5bILYPJmdjdB2u33e/KBu7PtX+grWjSugNKMofuD1mXu4i/45CkBwCagbGSc54y571au6bccvt+uhOX/n4pUhNlGagvpqjlnkN233cMftBuNiqcrXK7b047YbguDmf2g5Q7lz5uRYmVaOO4Jrxtx2UvHUDmjzMpPQ7Y/KQ8/1xPGDiPH27pwS9l6o10qoVPPHI2D/j2b6PzLjQKz6Dip2rd3MA1U04xbXCGRvZHWFK8uvmgBekKJhMvRKxZSrBPBxEfQNtvBHzWrGK4jWnfg6ZTwyxE0O9At6B4qwSu4Mxw0Csqkjn4c9jyInQ0Q== 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=KK7cpODuC2vrnu2LI2gP1Gpl8QQ3tT8dvcO1Znjx7OA=; b=Myi75pSZdEI6GCloybekft5B30zaRF4q9/k6UxQFd0FE1f1CddzIOoZw9zumAtp/nESCGH0uh58cjCIBb2bMoZbAJRdsIJ7+1P/bFE9a/T70jUvJu1SuaLwzacpM+KRXIAFlY+/z2HX6VGXw2DJoMlJPA3ZxaALFeis6MnNquRQ= 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 PH8PR19MB7093.namprd19.prod.outlook.com (2603:10b6:510:223::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 5 Jun 2024 19:30:09 +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.033; Wed, 5 Jun 2024 19:30:09 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Bjorn Helgaas , Logan Gunthorpe , Greg Kroah-Hartman , Tejun Heo , "Rafael J. Wysocki" , Andrew Morton , Mike Marciniszyn , Michael Guralnik , Martin Oliveira , Dan Williams , Ard Biesheuvel , Valentine Sinitsyn , Lukas Wunner Subject: [PATCH 1/6] kernfs: create vm_operations_struct without page_mkwrite() Date: Wed, 5 Jun 2024 13:29:29 -0600 Message-Id: <20240605192934.742369-2-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605192934.742369-1-martin.oliveira@eideticom.com> References: <20240605192934.742369-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::12) 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_|PH8PR19MB7093:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ca59512-5b62-4a57-26c7-08dc8595e763 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|7416005|376005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: ha0zM0tyf8U9v7jHomCRL26QnfIJ7g5gUYuMR6UM4jakXEt79zvc85jMR7o4lIcrwK9TYLHfye1abncNdpIGayYz/U9ovJB8KZuyAtoaP7RD8gtITddgr2avLwh63zq2CFfU6CZ7FzkDDyPKLdGJJ0T36G2kEtYmm0NniSJjtyyBmY1pgzCSy1hnSHPWNHrB4reTdkUIpM7QCrRmYAfZIk9QTs5SOHeoiNOa15cXtt8Um4GUL4rdxLbDiZACV+EGlUAqTB2wkoA/nDm52WkNRmaGIBt5u3nU/vNot7Iunuejm/35T+nAvNLpBwNO9eX5p9Wp7DxOaoCPpolTF7QUKJCxnzgCkIrHX6mHiHzZO5Cuad0iXbvqTaGKcIqayl2hljLYBxdkfCiiUjf/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;PTR:;CAT:NONE;SFS:(13230031)(52116005)(7416005)(376005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Juq/p+vTeOs3yHRCDho5hh0Lca9J4NuKg2jMzC8esDg6cXcJg6CALNlrrHIJ2aXxX7IUv6NLdSz1h9uAVmcZm/xYHqZaiPpRrGNi60JHUMDnyuJKobduKIQYMSM6JNpXF9A78+kWMsfzgaYjBcaJuTEEPQ8FTinK7QAm05K7B1jcZip4Wa0E9UBKbpSuoipUm4iVTqCTNDsu5ub3JEPFoZN/1EO1xY1h1AobHRczAUDBu3ekNMh9IfXX610vNrcAA450xgNmxjLyc0MWiFldjC2mzsPTtDhqvJXB9lDYivEyrKLDBieTHbfqJBTo+P8QEJBzdq9vkRfHJHRPPiPu+l+eoZVWOc+t42a76xgjHJavN7/CctbOZsK+mYWjPDFZi/LkeUSf64I1cUyEzqzBJHnV8svntYdlI4ZeD5z57u/nOQ0MAjiibE2/GTI8XegQjzBF51iviQSblgQkCFbnPr3mpEI44qfrlRmSyMKSjigr47XgwY1+7ToddxzSUxKfYHzbtwKWMQ4OjkmOP5wVcGunYaouisgh5xpv+mZtHVlnNCiPALgBqBqUuEgljQNzyXEtKZtv+G2jfKqzqlI7c9wG4t8o8BdDWbPg84sxqJcjdaneyJCTFbtYEmbwJIL6iaaiDDYzCG1qibsgO/PquTHhxrfxzY8wIJvqdyEJURsH9aP5VBm4xtCoGRP1B5a5mlUvMdm5vepxKaVU1DpPqFj/BD7rPO3BSIbSOSVA+qONm0PnPoIAneYLN5/BOCmmodbQDBW1TqlLf1WVVNzwBC/RAzwLJr0dSTMjCuRPJWqMszV4GEbJkjSdMOVhzkxdRgaDjffTPbRm6u0tIn4HHxoSH0mrbEFIrFnCtw8PbmBPLs7RN2SMWkrYMINAnP/ZqUXkW6AM5fPbfQePSBWYuB66j7T0R4Nt1zfFwdIf8aJB3pfjBBFL/I/yqTWwBIwGG71dLrDlaMD/O8T3OZHWdU1r8f5xGNc8kAMzWIDzlEjjRo3TAi89mV59AHIJzCnXnpeMPGp9cK71VZwMSKkN4CD4TWsg9plsaxPmg03kYNlmQINcyEZsCJeqw2KzP5CkmvIzgeK2VDLbgXhod0kPvlQFTex2kR/1G8DkID+azSDY78yehIY295hFRlZNOx+madKXVDzw/mn+6ZRu87x0ZdDHRB72OtbPp7C1R8O/8szZh7XQDCPnF4SjUXWy9MqU9NTWDkonJ8nDn6DzNFTLHmYo4UFm6VqsgsFVzAGSABg6IFGlm1WxDA2sNENpJVBlnPsvLkoAM9Q9Jv2bAI3GTydwBlsfo7xBD7ewZ5rcvg7ShCjSnOcQV1dLJnIcDYrg+/DJ4WrgUMQVnUtKhA2R65rT7Bo6IqY3IZ3BSho7792r+m39QWvFN5aME2qv+crboUaw1rYMO3PIDdnLChBiEuXP2hozVFosO5lZPKdJg1HSzPG6qhojhZFWQOgpXQcJwY5qOXMX8/9iLxBfszpvEKMCvWwkUohRWt0wOURn3+CKo3h7TGdrB4hjkSdO/hIfjL8B2mKYTaqdNifqzqHeEkJPS4Xv85FWtr/LuUq17jfG7fzmzZDWh58ohpqM6L0Af3tBO90nZxllawYt8D3Lsg== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ca59512-5b62-4a57-26c7-08dc8595e763 X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 19:30:05.9398 (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: 6cpLdDav5zuCi0e5bleUHItKuVCW/1JJlEsyR2t1ScNPRZKi7T5A2eihQwdt4PHi8mH8Cvzlt8WiJT1aZ5EQe8NgD4AtY0/JuYB3WlWcPEU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB7093 The standard kernfs vm_ops installs a page_mkwrite() operator which modifies the file update time on write. This not always required (or makes sense), such as in the P2PDMA, which uses the sysfs file as an allocator from userspace. 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. Fix this by adding a new boolean on kernfs_ops to differentiate between the different behaviours. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira --- fs/kernfs/file.c | 15 ++++++++++++++- include/linux/kernfs.h | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 8502ef68459b..d5e9fbded3dd 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -436,6 +436,12 @@ static const struct vm_operations_struct kernfs_vm_ops = { .access = kernfs_vma_access, }; +static const struct vm_operations_struct kernfs_vm_ops_mmap_allocates = { + .open = kernfs_vma_open, + .fault = kernfs_vma_fault, + .access = kernfs_vma_access, +}; + static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) { struct kernfs_open_file *of = kernfs_of(file); @@ -482,13 +488,20 @@ 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 (ops->mmap_allocates) + vma->vm_ops = &kernfs_vm_ops_mmap_allocates; + else + vma->vm_ops = &kernfs_vm_ops; + + if (ops->mmap_allocates && vma->vm_ops->page_mkwrite) + goto out_put; + rc = 0; if (!of->mmapped) { of->mmapped = true; of_on(of)->nr_mmapped++; of->vm_ops = vma->vm_ops; } - vma->vm_ops = &kernfs_vm_ops; out_put: kernfs_put_active(of->kn); out_unlock: diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 87c79d076d6d..d6ae7d4b0011 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h @@ -311,6 +311,13 @@ struct kernfs_ops { * ->prealloc. Provide ->read and ->write with ->prealloc. */ bool prealloc; + /* + * Use the file as an allocator from userspace. This disables + * page_mkwrite() to prevent the file time from being updated on write + * which enables using GUP with FOLL_LONGTERM with memory that's been + * mmaped. + */ + bool mmap_allocates; ssize_t (*write)(struct kernfs_open_file *of, char *buf, size_t bytes, loff_t off); From patchwork Wed Jun 5 19:29: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: 13687388 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2119.outbound.protection.outlook.com [40.107.93.119]) (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 AEB7F1527BA; Wed, 5 Jun 2024 19:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.119 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615821; cv=fail; b=YQUqR8yjge6Oi3HZxBLP4ALZyULyb0KncFBy7RtuDdhyy5Fh8yIzsZ62T+yTGpFX0YKDA9+ms9sC9X018/1idYeLgx2rCXGFUr1P+stPqWGmGWjXu13Y/VUpHOYWt3M4gVc3X1mKrWmCbliRoJQLlQ+wFCiPuyyLbPPIT0BJ7bs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615821; c=relaxed/simple; bh=ZUR69+qGI4LyqW9hJu3wMXvLwblhnzFCaZu6vfjKSfM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=b3ODlIbkEMxinx2VR/IYBs2BkC9hwjJXkrXn3D/f33WmRHKpRVYUJevSGH1BoMTyoG7ZKAt9+oM+izwF31swDCQ9h2IUsz+74ow78zUJrpPmPW/FGSdtVRofnd4N1M4qNV98b2XRlGXLS3qkT5gvY8fWkhnNO8vP/SeA30DlJpg= 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=wf7ytKak; arc=fail smtp.client-ip=40.107.93.119 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="wf7ytKak" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GXzgCpABVuwAna9Jge2elVxLGwFtSqFLfc8XBst3lSbNnbTGR8LAvohBSf17vLG2/Ioy6V+W8Ela0PFnq8+IhEmckkerE69QOtaMdkS3jM32xCzu8GtGMjuHFhB3i5OtxyZIunWjSjVoPAK9gVy9I5izvgj4224NThjbdnlBocJEnSOwEYJqZM7rd/ybd+RHBu2nc4oe5qw4c4n520E1F86HrQkpzu7tL3BkoT6Ci4AzwIiXoMYPzeg7v0Jb3R9LWCZx8Z1cGXrnYnp717s2PYhfO8d7LNXYpNbhIbaeQlItDZTzfvhbUATcBtJYYb3cprhF0/6w2JTJmCXGpQ48bg== 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=iZhzkCh0YEXOsUBThTVc0p81/UyH9suxkN/Dh0CRO+k=; b=lXEoul320sVfnbDXWzUmZgepWBzL7iJ1HVpwzYFHi0Ms6rGHCfKnpqRIIoQob8IHY35joWYerii+MEY8dV3DnzjeuDAuLghytQjV4FN+W+fGj4C8yWwDh+nVp9rEWVvKol4KfzA0Elc5Q9Uy7Us9uiXmTSwOxi0TMzQvOWYcd6fDa6QJmRtcdYTYf2ToFEhE40hhu3feJwT9O4q1puZrvtOlvzPexwHfWBteatyVIMyZ4Y/TovJrHKMovrqr04kEuVjWIz59Zl5VmDRkhdUisnYmoaCU53XXEuU2z+EjOxY5UhccIHPck6rW+Bu//xWxxyF5wY7HX+lgap4HBuVQeQ== 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=iZhzkCh0YEXOsUBThTVc0p81/UyH9suxkN/Dh0CRO+k=; b=wf7ytKak5P41Cyst9fDP1j86RjdXX/ZpLpulOEZrqQUU0dj6G5yLMPP5PzM/O32blEAGztSJcfgLaz86APaQsfb6ozcGs/G6FDdtcp52ffSOKe7q8EVsIRBYvk9laO1eC6yPAnCb7WM9v9QTGa7mmaaegUkUkhVDkEbA6xKvypY= 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 PH8PR19MB7093.namprd19.prod.outlook.com (2603:10b6:510:223::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 5 Jun 2024 19:30:09 +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.033; Wed, 5 Jun 2024 19:30:09 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Bjorn Helgaas , Logan Gunthorpe , Greg Kroah-Hartman , Tejun Heo , "Rafael J. Wysocki" , Andrew Morton , Mike Marciniszyn , Michael Guralnik , Martin Oliveira , Dan Williams , Ard Biesheuvel , Valentine Sinitsyn , Lukas Wunner Subject: [PATCH 2/6] sysfs: add mmap_allocates parameter to struct bin_attribute Date: Wed, 5 Jun 2024 13:29:30 -0600 Message-Id: <20240605192934.742369-3-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605192934.742369-1-martin.oliveira@eideticom.com> References: <20240605192934.742369-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::12) 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_|PH8PR19MB7093:EE_ X-MS-Office365-Filtering-Correlation-Id: 542ddc6a-ee66-4ec9-47a3-08dc8595e7ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|7416005|376005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: uEGrR7D7rmRg9eQDAEdPvwX5w4x0zNjNkcfIgrUtrxzJi8cefLPcgoSXuAqMTII0CIMx5SZkKWgtcWmtAiRSHVKej1OWJ//QOlu+dT7e5fyJV+/vWGjFFFudh+Gn0FBKbRk4VJLYqL+D1GpaiHoXOxukZqBR8a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rVx1gT3DCYjNIPKZsumQFQz8RHbveJnI9DbSP0VjZ4fmrENsZ/LoVGNKjhFauU5I03zOVBCRqKPOmzhnUrd1oR429vIUHQ0RYKLM7k8H+CuIVHbx2vMswql7HBCVX1WPxw13XibuGE= 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:(13230031)(52116005)(7416005)(376005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 25lmoksPC/AnTLxDIUIe1owA5WKhvq3G+5/n91gYhOwQWWr1pTu76O4zVE6sZiVYERu1jVFHgy7gqmadwomIooh6TYpU0UYUCANQ5+u44my4ndb1VXsPk6m1SQShBFlFUS9hPuUbWo7KlUJ0OY2GNWbH5NuZB9zP61wawXWDOPWgPhiYPzeZJN0neL2iR7L8t6cuPFHMjUNuhIiYruOptRDAOJw8QdV1pDMEjrkM4kmdaIDCt8yYBmkJNrGSo0/DJO9g49IM5kE54jvkHGcbTb86rcjGZsVThvTAi6Ache7jIjSvciQHeiT6erVrNe1r0oIN/TcjKAS6tb3APhktuP1bzssMOQkv242xcU444xTmTrL/4HAoAA3ViRatyUsRpkmuCh5rdbJoRKs5G927Ek9pnKJvCPZ73UViVvq45LKZewcff/O2inToDBesg9311+ZEAA0ZynhveIt9hotV3IH82+rr21SRw+CYEg8Y73FFNrDN3fmG3EdJjdGhPDFzOq0Qrbk67pWj0wUnR71S4mXr0jOdu4XzAkIROJ+iNkwarOKrBjl+NFH1hOV+Gcjuw/czkO570WhRtAEkCihNqAQjEeQC+qpf/WCRvNYZiTaHoG3ze+OcDMEvlzQs59A5fK31YyuL/Tp3bixeBwZ+XIulmuGrBwvigI3z27bmUCnw5Pxsp6yQnv3cc47G/JGOgzjZ6Tdd7dVGE4hdCSIYjtSptYFpgy2kK2yqBzTMIH+bSWbnvg1h+twM72waLhrE6m/QKdSNfPjuHtyx/vp2u3fmHCvbHugo6M0OZoneuxy6vQaNx2wKJSToX+c0doW+QO3sV/og3hG0QLeRQW8MYFZhXiTZNS0Y1eImDvXbRwZZQJIT5+xL/eqbj7tAYXvIVQ1/ad0V6vWxouWM0jqUsFhkzvIfBzAIVAGf+xOw/oCiTRNx9zPxDv1dGYclmLSAQWI+pyez/MnNo2/vMPIblH3XQHolohozs2SmgdbSV4qmnC353aXWFQ8wiz2q8QXCzf2Lff8NuH7NXgPILk22LyCw/QIM1jFmmL7QY0nS2V8JBLkupfwAE/c1fBOpmIl1ihPD/xNymOQBA6YqFcBOybV8jRilWMVBIieJFWFEXpp2Cm8R/m8hoKgviCoqKVnNuM1mvVv5GrIlnXj0CNQJ7ZvCWaEYyuRT5nOlomhOTWZczSzh/bh8KG16YkgnnJ5SvhSDLLlI1b9h+0yKkIx2S5iMZCUz7QO7hSSL6gP0pwylhrWJDoPVaSCGzvnsiO8c49zgolaIIt4aCRm+f2aRQ5bq2DtDidjenD+zIbRoKi8GDxFZ1ySMd26K3RQVGItbNqv3lLatcDo2Gtr0X+yXiU6d/ErItb6ZPL0kB+F/Wm+Lt57Oe4IhGhn2eTMTzhPNtt0VpRENRA9Fso6LROUdCL89rEgWRRptKx/DBi5HIVvUTAeltMOFOC2oz+9PNe+sSdze0M3S7Hz8VnjUzCpMmqQFo24wVeVScBkrYAuz3NYuIVjNXRDiDO4/D8psNihVr+7fFGS1LhdivVbRixNt5CqqTduhtmZWxLegVUfuxpzNBc7EVgjy4G71MACP6JZuDXyRwe+KEEAOHNAbp881RQ== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 542ddc6a-ee66-4ec9-47a3-08dc8595e7ce X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 19:30:06.6899 (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: H3f+77+UO1EGX1JN+1QoG7pMYrqZSayMlV0Ae3NDDaY8Skp9PRiq5y7AlwCi5QxGa2uf/9pIbse3/1grg/zRBT/DhtCQGDgje48v7F0rfkg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB7093 Now that a struct kernfs_ops can have an "mmap_allocates" parameter to avoid the page_mkwrite() operator, the struct bin_attribute needs a way to choose the appropriate kernfs_ops. Introduce a "mmap_allocates" boolean on struct bin_attribute to achieve that. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira --- fs/sysfs/file.c | 25 +++++++++++++++++++------ include/linux/sysfs.h | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index d1995e2d6c94..77c21009ceee 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -264,6 +264,15 @@ static const struct kernfs_ops sysfs_bin_kfops_mmap = { .llseek = sysfs_kf_bin_llseek, }; +static const struct kernfs_ops sysfs_bin_kfops_mmap_allocates = { + .read = sysfs_kf_bin_read, + .write = sysfs_kf_bin_write, + .mmap = sysfs_kf_bin_mmap, + .open = sysfs_kf_bin_open, + .llseek = sysfs_kf_bin_llseek, + .mmap_allocates = true, +}; + int sysfs_add_file_mode_ns(struct kernfs_node *parent, const struct attribute *attr, umode_t mode, kuid_t uid, kgid_t gid, const void *ns) @@ -323,16 +332,20 @@ int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent, const struct kernfs_ops *ops; struct kernfs_node *kn; - if (battr->mmap) - ops = &sysfs_bin_kfops_mmap; - else if (battr->read && battr->write) + if (battr->mmap) { + if (battr->mmap_allocates) + ops = &sysfs_bin_kfops_mmap_allocates; + else + ops = &sysfs_bin_kfops_mmap; + } else if (battr->read && battr->write) { ops = &sysfs_bin_kfops_rw; - else if (battr->read) + } else if (battr->read) { ops = &sysfs_bin_kfops_ro; - else if (battr->write) + } else if (battr->write) { ops = &sysfs_bin_kfops_wo; - else + } else { ops = &sysfs_file_kfops_empty; + } #ifdef CONFIG_DEBUG_LOCK_ALLOC if (!attr->ignore_lockdep) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index a7d725fbf739..190b4b9355df 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -294,6 +294,7 @@ struct bin_attribute { struct attribute attr; size_t size; void *private; + bool mmap_allocates; struct address_space *(*f_mapping)(void); ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t, size_t); From patchwork Wed Jun 5 19:29: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: 13687384 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2108.outbound.protection.outlook.com [40.107.93.108]) (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 5E0BD1514E6; Wed, 5 Jun 2024 19:30:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.108 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615817; cv=fail; b=KLVTx5KH2tdNF2oCVvg02CpBdnLwnfxYU9zcQ9Yoqn7VfADHjuFjjIA6UebQiRZVNWfd7NiOetQyZcKTtv/enRM6Ygb1Qc5pOs3Kf/fjvifmG6N7g/iQ3d0eOWaE01+zNOc8ozVlSrW+EwcqpzVpub4xXBn22SO0+xQOf4ofJmc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615817; c=relaxed/simple; bh=lHcUZ3NvxnbtMqRhknZ0Iw5RAbVyYCkcnwGIeE2WsAw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cBbr/c4c4lL15yVit1N/nmbbWCFgw/tmEqd+YwZNaUh36Mo670Yl17m9hslkSNFkOgujOQ1eKAORAU44QjOi0s6BS9c169ehuKTEYa2+HIK7EPlUJMVn6NwSaB7aspgsygTqKTglJPktO/JAOum9yMLUwi5CO4wgV8RWNXSHs5E= 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=eKIxsyEJ; arc=fail smtp.client-ip=40.107.93.108 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="eKIxsyEJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RCJUpJ2IutU8ePDFInzmoOLx7wg9qGOZ+jua48lJapdtFrMhlwllyFOAgNI5rc1WFfHTOyl1FfY9f3k3pHfm6ovBPVBIdVaD9+mfBLujrBG4qSCPo8asU9I7BqoQe8ialQauaIT5O52NkM2bqNB6b/JWM9OnKPoRqA37Q+NIUJ8geptKVSrZb3T3r+DY4XyH+lf25gJ7tLi7JnSOziSHT0mBVG4Q7C7UcLfkXH0z4Gf+A7snmFonqd6oIVKZVfeoL5DVPe0IMLDtOBtv6Q9bge1X5QTpyNyNTZlxp9hSWdjgcuvPKcplgxEt1OHlkCWmKe/zYjwI3MoQHn7/NjpCiQ== 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=ScBkgt1wt5k1bldXcuOR8HMDzAQDH+qNdKr1J9JI+eE=; b=dkA9AVynqQ6aSKbcQ4QORLvDmr/GjCRjj5+5a6HvIj5waLjRq3f5UBnWWyJsHNmReSD4fmuSNpBJuPNOSK2bue2sq2u5Mxui8D6bZQgwyOHD16lbRB7w3gfwYHPqSa9YFoFSWWB2oT79pBygqGJe58v+vcSmjVzzvONCZPwGfyBF7OeBmRNCfP4L2GJJ7B2Rl1Mr/Za2xh5WH0X7HlY8U0+TrDv/nAxrUIL1TjV2uD/e6kNy8p+tRdT68hKThCHbzdt8rODhGATRkjCax4uwQ56T29IZ7ULMddPBPh10lxlXkjlmzMxam6AImcskj9/xj4wgu1J83Q77O27D8XuMZw== 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=ScBkgt1wt5k1bldXcuOR8HMDzAQDH+qNdKr1J9JI+eE=; b=eKIxsyEJ4QgMM8cH7CiQwTH4tSOydLvKorYAUWnrurP0BjqbNbv8VPekix52P6BEYsIm3otcE4YZ9AA2rEkv086ISvb67Go+OdiEB7ZqOuHCaGYEnXhIdsWAM7IsAcEiLrMPvJQP5y1+G/5qzoztZFnvNCBKAWoqzwJCV39zT8A= 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 PH8PR19MB7093.namprd19.prod.outlook.com (2603:10b6:510:223::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 5 Jun 2024 19:30:10 +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.033; Wed, 5 Jun 2024 19:30:10 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Bjorn Helgaas , Logan Gunthorpe , Greg Kroah-Hartman , Tejun Heo , "Rafael J. Wysocki" , Andrew Morton , Mike Marciniszyn , Michael Guralnik , Martin Oliveira , Dan Williams , Ard Biesheuvel , Valentine Sinitsyn , Lukas Wunner Subject: [PATCH 3/6] PCI/P2PDMA: create VMA without page_mkwrite() operator Date: Wed, 5 Jun 2024 13:29:31 -0600 Message-Id: <20240605192934.742369-4-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605192934.742369-1-martin.oliveira@eideticom.com> References: <20240605192934.742369-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::12) 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_|PH8PR19MB7093:EE_ X-MS-Office365-Filtering-Correlation-Id: 7aca9095-b192-4d61-0f68-08dc8595e840 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|7416005|376005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: KywcyXlpsHxAW3EOdHyjlbTeco2wZfPYHzE3hjky8MKLqxU+x3+fI5qZDt/6ysClTYOSD1Mzjm1cZnTjI1kPUvcPa90Pamk1cZbUtFKUhAxxynPWh7e3n/oaVOR1JDGulGRRExnmxdfhHIiEg1MgYD2HrjUwcbg5g/04j2tLmPXzwlh1iAIWGgkoa8QrtWs4LrETMy8thl7kZ8glOXpphHR1ygqrhxbqtl6bf3bhBxo5VscOZrtmns1kGcZGPpjKWU5RQKfmoUrMNPfMx3nZrEHupWAv04feHSZYxQnxqVcW8kyghTq+mX+7Fg0OeHyKbC3HJYJ7DqAoD7yOPRLnCbJg9c0hL3wY/49FdgpBoVTtY82IXsqPd/dAZsbjbseCsxXYGUNPvlo1fNjNzjxNzj0kzZZ3XRqADynkhIN8vxIn/RVco37S+gmXsILlgPu20gSUZYumKZZ+PIvjSPd/BIei6+mzmtgi1X7ca3AsKfJ/OXAMZDoqTYlL+dpB0GX4KZpep6BsUbHRei/naEU/uZ/CW0gg3XOvp/G/HwVIENd471sqHxBqwT9K6d01h6TNVQlYKJ85fKe6+Vytgqu8CXRz5V1fqkVhQnT8z+atPJsOSQXaxp869nA/uWUQNbiYPdhzaOltxKKqLJHcXdL5cq+QO83mnJ/VRhkrW5IbWTa6Bt4X4qbqxUMNkq5XcHwGFyS6LL7S5Ji0ddDcpY9e2076G7hiJZoASI+9Mq689jpD6DTHgKH6n4j89Q3b3qQoKfwhYjfjXzior1tVmf1xRU1Kn0f4Sg2aIOhiLlky4aiAZ15ZK+lUStgb+c1lmo6qUsOsddspcXiFFwbLGKQCbOv8ONVPIBam5QNwmOyhQwBxZfLd0hoiFK19cXlxsw8oCVrf8imhca8DCJ5YcObUOwb0n66Yg8UyGPqVjPRUIdrdDJir8medKHV/rB2PobngxXMpjvddn6N1bOPmN671HeqEMno1/W4crCpJcEmvuRcrlyrGEaFqRUfYqlv6tizUlC9TpYwYbGu04fExkvOBMOYWjVc0c8fRPCg/jE8WFw+FstFXyzQGlkal2oOjNHUuGNVafGkRF1x8D02iay0DYhvjXi0ULnxTV0F+giFSbwRHOH4dh3TPX+sv/VjIlkwjAoXIaptx5VjSmqRpuWGMD6cxllIPvlic5bl+hsVfl+6LVpoMuUXGjFUY73CS0E/axL6KV0oR7d1jp7olLV4jHBmTvF6oJtxCz6BsIEwvSxdxcNMWnpzR+rZo6Elfhti3KqBSBFW/CBxKF+nOOZFZM6sv/avrdd1E0VwP7gTcZKVKQLa6Bolw91A7PLFUh/OUlCSaJ5/qtgtwOZZc+YP58SjMMm0Uo+x2KYt3v4I/XJc= 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:(13230031)(52116005)(7416005)(376005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2WHdetvNHqzPOiRgdKlU0TnI3fHLhedUykoJBmuhCRWT4lnVOc7+zphNmYk0a7Pf+J/PfeIp6GzMvkedFAEQ9I2YWXccfkxmEWStJk1d0ghwS9wUE2PHVGG4sCEK7MLWVr2SJH8sSndXlZMBdDo3SLbNeegmCRLdiPHRwLnoiImApp1K4MXqWkLNt5WB59sUHE7SCUlEoethGFFOCyG37hcHghTd6v30v5q7n69LFLE8tTt9wdfbS2tf3/v8hRgJ5Wh682hNlFoQzxONE81ygGpxpSKUKSK6NqaM5GR0M3PmfOIzE0DccthI/qShhXKg4VD1pPCVhIYlzNeUS5Q1kB122tJQa2toYwvSjAxIv/K4H1EmkT53C9yiTOPxEaKNRD97VHJ/RQ6zQTfJJI4pU8ZsrDmfDALSba1/HfyNfxD/dJej8lNEJDCdH8BBs3INAcPZwsoHqsmWvsBXKtfgiF21XM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Wsq9GWsP2gLEt2GCuejNe7TP0fBvDalvoG+m7zQdNf8SxCRp9TTAmEug== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7aca9095-b192-4d61-0f68-08dc8595e840 X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 19:30:07.3996 (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: OzI08ObFfg51Y3IXXgHpZqt/XXVhthmYxvHT1F7jB2yJpfPynR1mwxgKejqnhAv6sTCZApUMR4BY/M4n/C2peOfYW2NObOJYyfcagRraxY0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB7093 The P2PDMA code does not need (or want) a page_mkwrite() operator on its VMA. 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 with FOLL_LONGTERM use cases. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira Acked-by: Bjorn Helgaas --- drivers/pci/p2pdma.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 4f47a13cb500..ac07053abfea 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -171,6 +171,7 @@ static struct bin_attribute p2pmem_alloc_attr = { * to be very large. */ .size = SZ_1T, + .mmap_allocates = true, }; static struct attribute *p2pmem_attrs[] = { From patchwork Wed Jun 5 19:29: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: 13687385 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2119.outbound.protection.outlook.com [40.107.93.119]) (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 148EE15252B; Wed, 5 Jun 2024 19:30:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.119 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615819; cv=fail; b=DeV6EhOG6yB8O2vHAmCNh6ItWAIqHmmPhjmoUQJH0/AFdGjAitCbDI38CZGKjwzeweW86mcx+gqXKyawh31UG+9UT7uAjSpTLAwkIpkvj66yiIKSU23D20CTFnnANQSAAvnIzYiexuSs7lgLuw3ML7aYQ1JqG1MpBYDtyoWbqJs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615819; c=relaxed/simple; bh=sM5X8/kb6my2Upwv3SLRjvo2VhakntM+cN119PFzm9w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ZfGye/U/tDLn0DS3XFEjwmLzS9xNeh8f4cdC044ucrolojGVbsHh34KP60rwojAKwaja1kuwWnCMd9DT5SFoV8j5s5uORv5Odo+2iFs9BajvyAIpAiW4fA9a6t6KD+S0DnFkW/YSWyxZc6sZZ0ctx1B6orUVLknlnPVRdV9qaAE= 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=PoETp6y7; arc=fail smtp.client-ip=40.107.93.119 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="PoETp6y7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NnhCaFMwFkup2VDq8pXN/lBV6JumlDZiTdFPbElDLQ2xXVV60Qbe5oPJBwps3Hj4mf0s0ODG/E4v+wXDuVF22UYyeiuEa+YrvQy4GlsBiQuM1YgF19Mpoqe9Vu/ZeTCdrAtdu6FL9w0LfeAJ36wr1g9wQkuCdDXdPZ8rf4dvfxdlpMdsV0sDc1XqBZ4SKJ/Inm7ttm2B0O+pmdi15DmBWHChdf1KyNJWARhrQTY1yiPtf4sUDUIggQMim3bjmwcQjDAnUMoQW6Wk/0K7CCpOuZniJNbwz54Zp3z5uTxxFGaear8z9AA1ANdrfRUqd0EWlyUjqLDFZbab16OPOPYt1w== 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=NXomzLN72KRZc63HTjgGadCKAKZ9c7ARjZWaUWmOvJI=; b=fbJhzYIEIy8JkTwUhOVbSJVaySHgbUiX06LTGtDOf1lkdd24u6ZvN/vJEwvs9fka9QAIM6OdO5e3R86Co08Pi1/g9gP7dVXEHXVQtRUBwec+DOIzDhEh70mRt0jqrVT81JYcTlBOlsMlfkd/40Pl5rR31yEbH9P/mrFUjq3/MTUgj0GQhGoL1ebrWeogGTTXLQThAVGv+SjS3i27Ag2njpooRYxu+hXta+4+eZp5XxDrfL5hclSzOgKFUXFbg/psZigDMInIvvBYwn5At908abJ2P+avXZGOsfPq6IvXNlwxhJkMoQgQGWnhxPLX1GybASuh7lShKF3sC4ABcl7dFg== 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=NXomzLN72KRZc63HTjgGadCKAKZ9c7ARjZWaUWmOvJI=; b=PoETp6y7IMwtaXphE0R0yCZNsh7kfOcqpZy3SIvNj0hetJFvtWeMEvPCdlLbaCOlPthRrhAdZ67UBSznak2ZC1Onm+SkBESjRtkUz/GiTHjYEy0TAe9S68PgF8E8HAQFi5c5fN56fb73CLkXdvXOPURPZPT9DzI8DiIJSpAXHik= 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 PH8PR19MB7093.namprd19.prod.outlook.com (2603:10b6:510:223::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 5 Jun 2024 19:30:10 +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.033; Wed, 5 Jun 2024 19:30:10 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Bjorn Helgaas , Logan Gunthorpe , Greg Kroah-Hartman , Tejun Heo , "Rafael J. Wysocki" , Andrew Morton , Mike Marciniszyn , Michael Guralnik , Martin Oliveira , Dan Williams , Ard Biesheuvel , Valentine Sinitsyn , Lukas Wunner Subject: [PATCH 4/6] mm/gup: handle ZONE_DEVICE pages in folio_fast_pin_allowed() Date: Wed, 5 Jun 2024 13:29:32 -0600 Message-Id: <20240605192934.742369-5-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605192934.742369-1-martin.oliveira@eideticom.com> References: <20240605192934.742369-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::12) 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_|PH8PR19MB7093:EE_ X-MS-Office365-Filtering-Correlation-Id: c8f9cd98-a27c-4854-359d-08dc8595e8d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|7416005|376005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: mKLUhvR2kaDeGHlqRRRwNzKKY1UhkljsDzu4jAGaW+NWPFw3RsafEAp59QNxZT8lzRQwIfkGJ4sdgNFW8Z1QV2fWJ9AAU/Gf9t1IWMouPcRQbB3D0E+URHX3SPN8G7tAeCgZR/qgCGfHx+KaR50XkqL0PXVRS1O9Cyi3k166lmSQlneI9ydcW8cpSjs0qZPgC0Hzifmc1gVAapsul98GaQSQvd+7drgGqipo67oP874q3mjKg9nXXsnwHhEt2ttpdhcjAC6tlybpf5BdO7M6X3CLwlKrXp4vVomU3bawvGDnRFyEHc7uz2lhLuxN/BnR17DoCfePlf/3RbiwKdTDcAJwxXVWXZtrFjhXbfLOriCv251b12szHgcdbheT/nTNnblHgURrLKNkW+F+eW//Wn3zDEE9Iir7Iai62V2WN4krqG1LbVipapYc/YiZDnMGzFX0U4z+dWpl7Mp9eDg/lbUcrsZu4Y4dqf7KS3Qckhk3DTUV+nP6OGexSzNvKcqUoR3/TElIFOMDLh3DKfFP2Yw4k0OC1+Bjkz34407vo9QX+BctFKxJe8kh6jPK+oLAGnc71Wu23HTmsfGiqjFyQoLOd3oojcfutZSHE017b88ZVMNVqKingEW4TNU341dfJ2+HM6zr/xoN8Uniw0AJFrBbD1omwsWSDQPXSfnTa35hUHbBLmOPGx1uwmueqKnuttjj/jtaKBog1+ysB5lSD3ZtqbWGiUIGs4JswnSCJQ0Y/QSufoutUKJVJLsyUk9WY/9ivaW2hu/qndFXWxLPd3cWxyfrQ46myZ43gLHZE0IUzQoGbsn0HpbGd7rgg2ypCbw0c4e/NMwBXvz5YfP4LGc0Ta2iT45ZMf9dxE7Fs4duta5nW7Yray8hMHp+mdGsFv7Vpky+7Mg8S8LThin54zmcFznt9IaBpoKCJwR+ObSe44BNQGrSJfcFLjibgkzhBYy0bvoo67nEs7uGitTAl77MLNyK+iCPMhlRpeCoV9ukSzbJz9eYFnuU+QMNkyaJmR0SlIzNeQLD2bU7wq6S+7KD3FcMiSLep3s4DGXHPT8OiE7U9VBr1dghazY2WCKYYHZftdGCEfWxjYn1kvLcD8SRJ19Fld3SLY41PdJgykQN6X3H81nKgO/dDRVDz/XB7YsfqtMmse+6z9Hd84gv/GIormfH09RG4TLV/Kjsi/JANjrIX5a4YbEkzcN2YEwIOAunOgtYGVdjooSIog3nYzKY2cXLSGcIgkpZ6Wc8pCCNPkcJ2lG6usDOG+iF9a3RBoq0rydbW0CVtvDdqVhDSaoU/6QkJFAjb7sCb0pi4MskiZmBvtqrkeKrMjoiaZduSM9aabQjDZyMdj9avDLmhwRh0tVo9YSkVoA7XSPF/i4= 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:(13230031)(52116005)(7416005)(376005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData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9foTJ/c0OBOld1vSuZVZv7UnJzsZdoDqSIOfZ0YG/HpsLvrSECQwZ6HRMexC+SvbhI8oT31xQjkm0nSb7oIQA54VuTXiPYSM4eVAFWTzr5WPPen5cfW5Ng0HJ23NGaIUQn9SVm/rTHEHHnUWNYsaTrnO5p+FUemv9A9vG4GFvF3/tdRaDf4tmVmMzSSbcK/stZc70aVdJG1wWI1SP3QymiwN+oFalpFUco+/vhqpN/9CTaAfDiScWoyk+FbbJB1URacGexnk0knwFj3QVObPeUo9Usk6cnMR5S7QRuIbnx8N2yowGpBhfQE2xk22ykthGiRi2FZtdizOFDu0wB0pebJ0i3AHv/Qy1V9hMT5uh2JNs6BTczxxCQsv3ZbrV6LmpfAAUxGCvETWLxQhoXbZzlxzUEJZ2jheAKEBS73IcnTgNkEaI0VVh+77+d/EaR5sXfZarw+4BnbHqSGUxqRZ40y58I3NBx0NTf3Z6sgV08YXoOSWON3aHjUS2OeqTJN4v+mVZiQCKbFikegZibsjeOi/e3YXZe/kKb2x9SBFXCXS+Elpb+LtQNlTNFMXcZ5XyKKg== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8f9cd98-a27c-4854-359d-08dc8595e8d2 X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 19:30:08.3573 (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: BI0UEcONtPBY/X4r+TTCEWAh7XN9ibi8UBXhRWi698FKrsBRJ8tep1KYqLgFquJmRpVjEXJK65NuXmPKwRj8MW4yycT6Au2Ncc10iuyvYFg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB7093 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 ca0f5cedce9b..00d0a77112f4 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 Wed Jun 5 19:29:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13687387 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2108.outbound.protection.outlook.com [40.107.93.108]) (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 B8BCD152DE3; Wed, 5 Jun 2024 19:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.108 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615821; cv=fail; b=uC04UcPhVkfzHJV2/2XUxNStmG95nF5pVVOqiidbM1dNDoZa+ye1/6mLe2fvO66zBrWbyiCAi8Eeon1irixzL8z3ZG89eRqMDThU1jvCn8DEoQUmgZPyPWZQU5rv9FkVwHAmaHq7nzivnG8Ni0SgP03yQnJDFLQZBvkzdCyVYcg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615821; c=relaxed/simple; bh=VUOi/nym8uyAVQs+oU2FUZ4YJ90xHnL7HrdK72INAi0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mTUhmK8tZ8ZUnpoBTbe3nfcn5spOSQzBK0f/+6aIbrghZTJ9pt16nAJNDSrCwEw67VsylY+vrl7BRA9M34lmrTfAREhVDLt5Gs6UYU8EebzWdE/BcnVQVNMAcqAe5Z1ziQgiZE66T/DWLUEPX3IC2YLmzFtg0KUudONPCE5cZSI= 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=XmY7N24H; arc=fail smtp.client-ip=40.107.93.108 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="XmY7N24H" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R5Wc5I8kWOnMSKLf6n25aiuDGSvJepxgclGwL1qop6btuSlG+Ez8kuQA8ZhxUGr2QPmgMUceWLtnNpkfrmVWe3kDcQZyO2tYab34Y0+R73oNQCKzmroEcrQqpwQ5ZeDDWlv5OKPwLEnSM4YdeaDsOgyLdDjnRyc5OQkYvFORSwb5zoICy08t8MADzMnmHeOItKVf0vt3qUA4tegPhnPxPzwahJ6aIyY/1wIMF4ijkrYT9/kQpnCyhnfXZ5TZdZb2RRP4FUL1R68mI3QP8AhFZC0KpBeN/wROxDyaUZxpdinRDYQXFyL9bv6ubmiVVHZO7whUKlu4TUBsTSe+XgcI9A== 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=j5B11FdDkWD/wobhQyNE+H9hqFfSjPlnvBrJ5gpnZ9s=; b=Z8FWRihpngsU7kU3U8m/MV2pAHAXCKbpyaUifqmgKMLz5eFmPAUOglac9n6eVTxqKjKGkS5tyeYvfDsy1fRHvS74HayNvXvQCHNA1IzChkEYhe9NoNqJWsXV3urjzlo5y0+hzFb+YtLJ98oiCsxL9u0ldt+/p8evpDFyZ24Npz4E2RBAVQDNrqs++4I4+K5F3++5wdk4Bf0jIVuStkw/U8iyX+2fa/KNqD9RvpiRk3o98zwQM6W+PdCHkZWGmV58nNKac8udE92k3A9rJM1AFH1SJqO43brpPO8OSX7f5EcwIbauVrQ2PZYGA69h+YFYarke5JE9BqhfOoFumSanwA== 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=j5B11FdDkWD/wobhQyNE+H9hqFfSjPlnvBrJ5gpnZ9s=; b=XmY7N24HanHgev8gGgInDQx/xJUqALr2VboKKJ2NXL/CR1aibK1Ni0WngaKUCOhXBiVrYK0c7uVQNz+9e7vEsPSZwL/mos3yu0H5705zKrJqKXSUEqcWbDjvU8gzqvFH6DoEHv5Dtnt6+am4CoigNEKZmrRz7/oxqE1CXKBMx9Q= 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 PH8PR19MB7093.namprd19.prod.outlook.com (2603:10b6:510:223::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 5 Jun 2024 19:30:11 +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.033; Wed, 5 Jun 2024 19:30:10 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Bjorn Helgaas , Logan Gunthorpe , Greg Kroah-Hartman , Tejun Heo , "Rafael J. Wysocki" , Andrew Morton , Mike Marciniszyn , Michael Guralnik , Martin Oliveira , Dan Williams , Ard Biesheuvel , Valentine Sinitsyn , Lukas Wunner Subject: [PATCH 5/6] mm/gup: allow FOLL_LONGTERM & FOLL_PCI_P2PDMA Date: Wed, 5 Jun 2024 13:29:33 -0600 Message-Id: <20240605192934.742369-6-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605192934.742369-1-martin.oliveira@eideticom.com> References: <20240605192934.742369-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::12) 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_|PH8PR19MB7093:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c8d2dfc-0b27-48cc-d87c-08dc8595e969 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|7416005|376005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: R1ArN8sqOQXgN2EXY67vgawmb4bfvurXXX+x8Zz6D36bmthfyun4r1Omvw3Jy5l7o53n3RVcIeXOGBbUl7/WrixD58XQfEQXsWZSbGyfnI16rzu4Ap8EWwvUEbfcFeJ4sz7pmtP7x5VQ4F9GuriYshYNFB3f2cJVVtxU4yOmESVaCiybu4OP9S1mbpfldn2DI4VglcdoqUCg/MN1iNcFcXhdBcHOAzBLlrKPFYI377J1QzH0nRennP+Mli2nswwFFN/Ry7jRB0qZQO3BbiYDj5VIgF7vTASAudSjcYJqnRcY6WHAJrRGMBsZCGjO/Dr1rhKd68NY8Kdq71agKtLHC5bsSsysZjaSNR0YzLu8D1Tnnhr20zNwYoSnHjX0SGJQSds+wE8bi2p0RPxs6D4k3ytZIJCuaQKNg5cav1e0SxSGRvoqPppfcKcq/PLVYlh9HgKpM1+o2Mol/hHKruOHRvvdYlxnnR8almVpogLYJVeAr1RKmVXf7wzw1QwbcCarKwjjghfiI3+ykBqRe69bd9bUsOxhCJ7rn8LNN3xHLL2RZYS5bEwcRCgitlaJ0YHKW7Kztravb/DowvURIUGjA5pW2RaQ1Gx7hSZCyOkr6+YduC7QJc+ntx/gm7x0hEY6u+9Ihpy8s3tpWcr7jZ7zu68vb1B1rD15ks9KE9Bp+yGXuUJq4UcdbjO6+cb4E4HDgCA0BVjTDb0p1mb+vMiLotC869Xr9sH+663Es45U5idhoMWxPVQC28JnP4J0J29rGr6UOZjJfSk+QTyaJqhEyrrWJbZty69bnwc9sArlIhJ+Rw4JYbQS91v/Pi6/YTDbD/T1+5n01R5Pr/im6hOxYdx7wiqJq1eMt5s08saUmk0hii9ovuRgqjJoVxQg4TgbhjMOQ3oZmd9Xhhjb6qrb3w/qUmIPPCOZ7+88R4rWXlVSe94VJb6AVzjeIvPIDofyc6gb/MXrXL/A9rcyPXxE3Z5cxl1OReE6exPlHQqBlXOicGVATc1bEL2OgmJs4kkMhLlYZ+Fhh7BXuDkwWzHjN7JfN7TkIuhoZoz22uqO75N8IWrJagtHKQjyd624A8FHc7cNSqHsnDqZ3tQkQn7eihbynMeOg10nmrkhfYm7icapsIqAQx/qu4Dlq/deF8penEU2Ua8qZwc4uvI2R50I7WH8wbV1wf9pffnm8APDFLbeSYy7QcGrxomahUWQ030cNiylrZdXOAMtYI+uwcssL9/ss7v7Yduvea5Wyaz50YvrYZWanrPCQKiV9ys1v47MK+jJlvEWgiNfoLYI7w6H/q9M4ptlkLYia7olnAUVlKvuNMD7DcvcHNK81PHbIHqZ7++W+83cHx7dAnuNq3RVj8TkX6yyvRgfYvyBJZD9Pm0= 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:(13230031)(52116005)(7416005)(376005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Mf35F/cWIkuaaScaGDguCG8V/by0hLcB+4RKy3usMauvo2s3BNx5o+dEypvaKXYdOCBoi0Z4N815nkILKrkazHy2itH0wFd9Os6I85A6yoQ2G/0Se3AIrn+kj1L1uIRes8nm19qsouD+VTide5OjfXkT4QDZor1OBTo6yy9eAKs2tEuP7KCXjhGWG/wy45zFMjhjyqT2vFLoeDL2m5nY9jbnxLmOeH7Mfnz2Mu1dubZ3xnyvWpzklZMBwxKkEW/md1Ka6yVG6aSX3O4ulX85Yisqg6lYMpiM9WNwZoyYESibJJMKZCTKL7hE+GZPjtAd7nDF5MdsQA4vXYsp47nzeqgTBEfAAqTImN+3OwdaK+yVvjTyQZdmmUJCQ2WlMFcQ0nrlELTuPJGxErQe0OFzDas5iRzDG7SrZAdnnpOZFfOVF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wUk3z9KJSdtQ375VgpVwV+iCMnuIgdIB5wACZG7vCGd+/tHj80buxcnL4k1j+uqjQXZN3nMs3XQV3hT9GP1z0Bh7dEpdl/3CqikLUkRw== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c8d2dfc-0b27-48cc-d87c-08dc8595e969 X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 19:30:09.4140 (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: qmVv2frgPeMSslsX9CVbY/cjzo/CaJG47zFK50JgOqg5VP4qjZ5UtoRdf9cTbDMOrSx869XKKVBNvYSv+y7U8tz5YVpGOC6C4ZUF60ca9rE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB7093 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 00d0a77112f4..28060e41788d 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 Wed Jun 5 19:29:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13687389 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2108.outbound.protection.outlook.com [40.107.93.108]) (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 073A71514E6; Wed, 5 Jun 2024 19:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.108 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615824; cv=fail; b=M/TWBoi9zF1RanrqdGiiNOyKX5N4qQTZ96y9UTWJtrsxGCk2ESBm34DXDcE/d6hU+AM5SQr19iVfSxyzogngYF8zuI5+qrzEq0ohAeUMz9rJ1M5Vxzdyx2wCxMHFDG/1gMXwkDzPG03BEqV8EBjNoQxvhLmn1LEVhf9h6zxzRhM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615824; c=relaxed/simple; bh=4a3k6y2crYCilo4927vRW7ZxB2urJxhgN01xNP/IdWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iumhYRwVMNnfaoGLwOMV5rt/QJJOANnneUOJeZWxbWp2OMAPBXmI7NTvzaBdxCc6/l0ix8hTzj+GjaVCCQB7ugekmE0JVH9SLUltwbciA0jbWwdiea30qc1c5+bjMHVvz11eMvh3w1OdVgDiHD2mztCXkq697Qs08fP23J5qvxQ= 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=pi3w3toA; arc=fail smtp.client-ip=40.107.93.108 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="pi3w3toA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+40/1HbSdhQLVXDWUzYOMVHsxynjBpASwATfSvqcJNiuP0Z6WfCGly+JSeHVin582JlnnFp3OaMma0NQ0Dy74ezuKaD4TKHycGkCCIGB4heWar/1c3OpCfDjwty6EvVUb6wnSuYXd869t/R3KI9A4/RB1FnoBrSoEVaAiqjB092ZjtXyzJQsP2p+iPeOediGJvjPk/uJ1n5Ys9erj1fzvURzxALPrjVYFtxeI7TFSEecNRk3ojKZAhrhHjs8TC11AOXFTsn6W0f6+Pg3LKg8AYa8h5YU7QhvH3qByhkjeJnWQUUdjwT5tk3c8IzzHMkVu7BM/3fbQUrF6yHEq/16A== 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=LLEvtGJwZjuGUInJS9PLacP482Vjf2UziijYhxnFPGQ=; b=KbE1hACcQLe4EUN0tP6JkzcySKJbFj7YBjLOqyTko0KC16n8/OAAbAQE+WhYy0Ub8DoJPc3ezdSmJlKRyykVQV1+Hk96alaL3klMfACcOmGn4m8J5Njgrl51r3E3zJvIo6uRP+OyDXaOs09I8IZGI8AizuSIl2jribPApnXV+ofj7UtW5m0z7nFVdnyCTuu+G9xOcVJmRM3mjZ3vdy0oma9swvajuar8WuBYOak5LdGz3db/Um6vfhI1/1ZxbC3PtSkaBBuuTx6eMdITGfjY6xJCKYS2wFxf2utzqzj6UdinVL80flKsKA+9RuZaaj7lQ4qEKXS2dtU6u8Z4m2REgA== 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=LLEvtGJwZjuGUInJS9PLacP482Vjf2UziijYhxnFPGQ=; b=pi3w3toAAxyC8KcTlZpOoHpX26inCpEg2vGib9/5uqGydOm66qHIAyhFAsIfNB/SFjjpSIYLa8uIYKfQyZTSVfEL15sTqx5adK67u5FJ1inD9wLK0QXwU/lnsLtJkXcdxMqMsg8lzpbkoq61cLd1z2u0ac0UGoG+2OiwiAcHa6A= 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 PH8PR19MB7093.namprd19.prod.outlook.com (2603:10b6:510:223::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 5 Jun 2024 19:30:11 +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.033; Wed, 5 Jun 2024 19:30:11 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Bjorn Helgaas , Logan Gunthorpe , Greg Kroah-Hartman , Tejun Heo , "Rafael J. Wysocki" , Andrew Morton , Mike Marciniszyn , Michael Guralnik , Martin Oliveira , Dan Williams , Ard Biesheuvel , Valentine Sinitsyn , Lukas Wunner Subject: [PATCH 6/6] RDMA/umem: add support for P2P RDMA Date: Wed, 5 Jun 2024 13:29:34 -0600 Message-Id: <20240605192934.742369-7-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605192934.742369-1-martin.oliveira@eideticom.com> References: <20240605192934.742369-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::12) 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_|PH8PR19MB7093:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b3302fa-a446-48fc-9457-08dc8595e9df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|7416005|376005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: WoUhsWdI3dWrJg9T87g52xJSlUVURxPCcyyDhKPF1hhfWr8myBzRA5TxcToFIkXO4CEq6z2AA4gT9+5X9m6YciHwQOu3jc5sWUEB4eiIsZe07mUT+HVQ5o15aaaKxJoB4tF0kowb1vTLXnwcxYqcUxmD3BYZ37Bg0bGGov2L3j0vTzImBJ6gYkgXG0pNBxgmGH6CO4+kQu08NPwKnwHZRq+j3pAyp5C3zrouhUsDh0pvbu2AH0O+18T56VaW0qkBx/TatrXj+u/hilDyw/eRpDQ3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4eSItZRKn/9sfa4gy3qaJJIA0C5XTEORY2ZqvCA= 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:(13230031)(52116005)(7416005)(376005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VwS2HTB3sluArf9tP/AMjIZe8Jxn2fndAsKHv7BqtII0aix5KJf3NgL/xP2vA1sdQit89Ye4uDZvLWJyjZoT2QfmEaOfR8JzZlGebpJQBRIZSftYhVIIi3WTaCi943r+SNxpYbtU/VO7YPotIjvbHRJH0s7DVuCm8WYTgyZ9ndXdM2GYBrfrAx0O1nOzYZGVJAhdpjNaifPV7Xw0IqopVxEkuUaiJRfP0xBcpJFF9o96NaZTuPdR8t1+MJQVlSWdYgXBsBOqvnLSvoAw52vNAQRdbpApMWk8mLuX2wywCPjR/5ufTKaN/VX3YycqXojbhTqsURnjUSn//tv6nLQDNYJCKEBhGFp9sSLt8OZMKIyfeYZWkh6YbP0y0b2wU1NNlzNokfF/R92hS26Wa+xlcCQIx9Mhjl4OZQT/9KMjx0trlXUUeCG5xtK5dYG+ExUThszBq1YjlExblOShkNCEhKFFPQXwPFJ1z/rFzZUn29pNNrUhtBw11bwLNR1qVpNK3ZmKuZShXFDTq1sE08d1wduhgC/2nQruvom9YQHA8eTeO3iifNjgSNBk0sFASNy5EJE+IaoJr+C5YCluWpkMUykOXCXtYEctyRWK/AisG3sqZsV1YpRRTCNK7t1TsyuTIVXHvH7z2FRWMRYNalzuCgFwxAWC2So+22EZUvilnMmUD9lSwOWbCdVZBpPgCNTwt568yhd0W0OFAyDdv4souxmopQ/XT0LAQnt/VBjJrqMdwsrXLtlJ7o1jIwkqZE6KQiV/jsRzFvmFxeOTjHf2YkKg5Pi+kGpP0rEN0rKHX7xISlaSm1zu8kIKCdcBKLKP5DHiS6vnd1eeahteF+rAHukOAtrG9tv1htx73WL0h2Bt1SBwl3PC8PQtEecwFRisqL0r5BzJtB3+KWr5ySQNzo8Y+N2jDo4rJr0GAz0qbB+63faZHd1+vuwdRKWG6XE8jXobF12cgfBzHPCsyf8bAB+0L8jZyzX1uRwmtkR3l+vnSvPqpJDkdPC7IQmlEpm9V/JoIJD5cDokliDbM9n6E3ALgEZhne4026gcdoBGtlIN03Bef7qiAqGzShcrytVulkHxOVpNFTTS9MiWdrpjO6oazCkzWNZZqXWmufd2qV0zDeXhs/8zgHvlRIeokMaPUtUIYhGY+/8CsY2p9sCc845hyob4ZeENo8PphiG+KxObq9v0mRoTpV86QEWR+ZGtLwaDWNMjLkl74C2wTpXnnfV2qa3KyDC+BDvqXS/R3nHzX/dosdyJwDcIkta/EjY+ZOy5ZyQlNQ7hm0M92eyt7KEQTV4ChNw/ywYJpG3IA+kemtRnD9NkPFbqB1nmS2mWR+mzXWJ9GylmJYtC7D6yvUdxjbb5nGCQkdvNFsYnj/Id3EPXveofN5QxVBFAqqnThdO/jUDFwPBwVPMa1rhCjO7mTT3enudTnnLYqYWh+f1hTI77Kl+AzPLdxL8+2l/2MPdRqoNueQqr57WGtJha6BOPf/lT+RY2K/HMZZ+0YYHwvi1a5JRShA0jenFOsuwwtDvSGIygwRBVYexdcfAgjXswzoz8yofD6Lj0FPrXa+Rg0DEM4g6/J1V5kHWWXgnaXVjtAaizXTXCFTpxlAIJ+g== X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b3302fa-a446-48fc-9457-08dc8595e9df X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 19:30:10.1101 (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: pW4vfJjQZhLVzHXkMV3OJtREdxV0qWStmNY5Mhj3g+/P+PsH5Ok55ex2XALbpfaYTEzPgsqjRzbj003OD5RBNLbpgz9x5kbuzKMr1z6RIeE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB7093 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,