From patchwork Thu Aug 8 18:33:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13758051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99004C52D71 for ; Thu, 8 Aug 2024 18:33:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32B0F6B0093; Thu, 8 Aug 2024 14:33:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DAA46B0095; Thu, 8 Aug 2024 14:33:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 154506B0096; Thu, 8 Aug 2024 14:33:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E85586B0093 for ; Thu, 8 Aug 2024 14:33:55 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 695A61C1DAC for ; Thu, 8 Aug 2024 18:33:55 +0000 (UTC) X-FDA: 82429927230.15.3F74542 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2119.outbound.protection.outlook.com [40.107.95.119]) by imf26.hostedemail.com (Postfix) with ESMTP id A019914000D for ; Thu, 8 Aug 2024 18:33:52 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=JHudj9wi; dmarc=none; spf=pass (imf26.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.95.119 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723141960; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=E21BUy7gHwyM6Sc7f4tV0vSARFCIgfl8bfMG0roKu0c=; b=KCJBZCW/b6A+spCqw0XMpxMk8TK367WPnB5ODMlvalGsxtsEqoWHq4uYwTeqEPXxRLr03w V6B8ZZC6bnqQ2GAgs44JhJt3goJIkULqOeP1Tv7hzmYZ9aRR/4mZmDndPRkgD2eLgkQwUy dcX11fJLnLbmGAVg/TkPSsiiWI4b0QU= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1723141960; a=rsa-sha256; cv=pass; b=XvRqoREBwVocfIBEGjB/hbYoFCykjyl4rlYnDRS7PCImfA+TLtbofE/zc35vMK7luHijuY +K00T8/DB49aG5Z9p4LYL+qwmqUgIRqHabcFcI3AalDFUWmLNSiGavbEqQw+ETq/e84m/j 3U4MQhTlJEh9uvkRIrH3B5C7kVW1ij8= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=JHudj9wi; dmarc=none; spf=pass (imf26.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.95.119 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sxsKhHpuDY4YwDQ6o2dVIzJtQB6YaIjZwfoaQgj7MrFAa8OBtebDoe45MGwju8GdlRclnoefq+Ga5FKaFvTcQUBXyTJGTgmh5RFPMvrdg3460BzI4mi09SK7+jWqdMR9jblA4qlxk5OBmj45bnwDu6qysG18g9W+d3TCE6U9aqI/kvTrGycPkTsLNOYko8lFk9q/bp+bECEh08u9iAMJY5hBs6MPOpC6BXp15Q4FuhH+spE2ZIrAwHPOAsOw8pRrEwkuXfMO9Sa3P2z7LFZuj+4MDqyZph7rbjmcc3rTjM0OdIIEzKpNb8AdHRFrGbsaDwcvG28vmilsfIm2iwiiMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E21BUy7gHwyM6Sc7f4tV0vSARFCIgfl8bfMG0roKu0c=; b=jDvWz2hgHG3gZ9TEIq1Uag3RISDWJPT+Ds/+OBkBmeoDaCfmUhEGKWK+BnLNlTQgQ/B7K9MoUt0fANPupFJ8VMgO7rtW3bBZLJ/hJ8EeMU+Mzie00Vw0cpkwJyFqNDqOswRAgqOQ5/VF3rZicbsUtx+STQyjOt9Wv/mn2YnTiFP9tgVLlmYXT8/lAhzwjPdgKguKU7wPy8nvARvssuTdPZD7gx9PJdQVqyJgzRr3NxB42LJg9kb6wnbOrofeZRL+lK7ZrAerQggUxVgflRovlWWFJp8J3l0Odc/2q+2GYvROQXC46qr8o0E4UdVGCZ41MXtlseGie9Xal+BeKLMP0A== 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=E21BUy7gHwyM6Sc7f4tV0vSARFCIgfl8bfMG0roKu0c=; b=JHudj9wiAqGJdIbklR9vy7ilyM1a7cOqEt+7bcQNTGitosO6TCaC83IsKrVppNQKDg2jZ4nLHkTkmkPj6jsqDkQblXK9KxSk1sf1bkAJHirAZZ48R7BwpZOCz+pu5Qj/5xpT042NLYkgHDki2dR6LIoNeDUltD/SotmF7ZeEP0A= Received: from PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) by PH0PR19MB5049.namprd19.prod.outlook.com (2603:10b6:510:79::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.21; Thu, 8 Aug 2024 18:33:50 +0000 Received: from PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849]) by PH7PR19MB6828.namprd19.prod.outlook.com ([fe80::69c8:bdb9:b882:b849%3]) with mapi id 15.20.7828.023; Thu, 8 Aug 2024 18:33:50 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , Artemy Kovalyov , Greg Kroah-Hartman , Jason Gunthorpe , Leon Romanovsky , Logan Gunthorpe , Michael Guralnik , Mike Marciniszyn , Shiraz Saleem , Tejun Heo , John Hubbard , Dan Williams , David Sloan , Martin Oliveira Subject: [PATCH v5 0/4] Enable P2PDMA in Userspace RDMA Date: Thu, 8 Aug 2024 12:33:36 -0600 Message-ID: <20240808183340.483468-1-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: MW4PR04CA0072.namprd04.prod.outlook.com (2603:10b6:303:6b::17) To PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR19MB6828:EE_|PH0PR19MB5049:EE_ X-MS-Office365-Filtering-Correlation-Id: ff354e5f-c5fb-4be3-714e-08dcb7d8a5a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA: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I+RhxGYi+IwOxCD4ZF+LfrQrsCYoOsVnQkCIBJntLHrVIuf14zoveFIC7sbKtPmKTmGYVNRh6EczPcn2sA4O5g/DpcUKnIv+Ux4ccogu9+TEy0aG7jM2Q7ldiid94dtKSpw3fPhIdEMdaKeNuKwbjqKKAHaiApdqtnkDXy+nOZZN9HleU4q10sDfeaE3IM+YHu7xioxDzX9m5PVOc/+wnH+oKKM5bK0tXXCMIRbg5UxTJ4/qN/ClcsYfjSkO+jQPCUxxBusKMZ7HV3lHiv2/8xu61VB86ym6yGJPZNHS+Wo+pd6pu5jVrmVRQf6zVMUkfrZ64ThJaF0bPeHVp5co1rOEA+EhVrGGbsHiL4pc0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR19MB6828.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(366016)(376014)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bOq7j0K8dPZAXX7WsTq+0h70Oj+621GFAdj65tTL6dsClaiwt2e5pO692FrBH+yFaVzUDHsTVdMVlEXSlPd0WD01b7hZ9pjEs2PG5qyuqFRC7MUHd8Bqn+jHN6Sg9fyTsvUGdEeAHqbBTLVoZngJzJykqmrUKDzlhLSFjPLGJs25iisJx+ANTE7NgLCScLxWCdn9RWwTzyjrrpMJjkVRKg2aVANSXItNBrwVI/cmjTsr4X95XDVEnGuXvAG7/w6mk6oGEeo+am2Goj1GdHkc5izvfaC7sozgVymnAsO/M1mSv35CNwQMhAldKqomHanlHc3eNvEmtnfdBbuzA0kloo2I4sIN8lp7nJxauJeJJzLF8nu0cxXcjzgv5KggF+tAkYV5Ggxlf2aLh2Hrna+qonJkutdO0shq37yfzn24LQSv/xBQzb2TU3pCdTIOuIID16ihxKgmRACkIQ0Iau/dY2VkaX0xFe+V9aJ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2mQQY08Acus0z5QDJaPaAhzosZWKeoYJjlSRooW3IBViV4lbeE8/wEfRbG/Rp2w= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff354e5f-c5fb-4be3-714e-08dcb7d8a5a2 X-MS-Exchange-CrossTenant-AuthSource: PH7PR19MB6828.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2024 18:33:50.0851 (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: efgq6txvKBCYq+Q0+xkLNkvvccB6KSx9cu3EMwaeKadJr/qAF/NwBP4YlJHCvBoyULjcWoMct2ik9rAXHxF/50MqJ4XuiU4gilYxSCjUwFU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR19MB5049 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A019914000D X-Stat-Signature: wt1pa4xfg61dd9t713wkj17sufi8sq63 X-Rspam-User: X-HE-Tag: 1723142032-857166 X-HE-Meta: U2FsdGVkX19elcVfTLgSxx9nsUB0Z5mnCqvKmofT3iRsKkrNBH6m92KqSts2V+70GDlvQl4klrvUZ8rLk+gsciFzLJhMBvO+yoPyrsnlxajxsaO8WUhZor6jkEcoXPsq3+leOUVw5sErYGlevvAELOMNf75KPclseJKji3sx+sKSAUt6xa1TI1BnYbnBL+58/Ygjo038tmpDFOiwSUxFjfI2zYxW/niLTqeXugUOKVzmQoikfIpOjCrAfEYTiFxzbFFQFdFJ8xuMaILx+SQ5N/GkdIEF5MSXmq+gdBU2KAbJli5KbsteqCMJLWyqgLGf3qlfTGsBEDi3h9m7bSbGCZcJd3EleiG96ZwjV6X1V86tFHEz/Qvt95pTR+RlucHjfJCu/kcDdlOtAtOW2lrIC6NaXr4KCvP0d5UtG/lMejbbPkgCp0QhG+9DJkzl0Ek4XenvO5tXuPIsVHVHZYbhB5N1p3kE3+mTI7COuEjCiLwVqaiDzBD/6DUZLEDb8IouuhIS3xDEmlvnFo0pXL1SnDYBOtJ9qL9PTuj0Pj6GJdrHDQxA8wEfMS8CNa3qD2kNcSoRipujHOUaPErHrDLYdQl6tzSSw78CvB2I4JcqE5h3iSdHpikrbRjXjlmYaz2ROZSW6pFipbXM4zpbSVkrMqSJOZhDnUhrV/29xmaY6xkMZ5X6ng58oIl2V84uy13Cv9lx/JlEX7D150l+kMjRcGgKbzQs1OjKqi5nEc+e4GtyGqgdgfhezoNAHOImSX1lHcL0n0dlcOnaHRcGwEPxVPL/xq/JKIuybEsrkiVJQsrLV04d8p/U5xGTwAUkjiLCXNRbkfH+/Ae/0R5tsgXlOiXBstv0Qf4kAvJ6/ZDY2GANHubCuo09qP/C6ZveTf2+6QR7tqguFvchKnM+Vqr37OhpXHwDTtBwlSPnKgbw8TYKHfXcZVAz0zJdQk6J6QieutQPxJdHTdw5sWZCaNm AT29w0b8 yODbUX63LnXdZKDahUZNO4zVFi2aalNSjC8eg9Bp/0taY7PzaMdO5Use1UsLVHTdCxUS2Ha2oL2KGX1W3HR18ii7Fob7HP8fLOPIWSnCdFCUvXHUHOrYDrXpy5GBGnnsEHDSZ1gFdTvN6stbLoXshsHsXW/pgpiH8yB6JggaeFGOB4hEAykzVgfFLDGJt/Dha+lPK2ly1uVnAFo7OuDi8WW+vsorNziU/BPtjNzF59lymPZBZSIrSDT6PRLqY1HCTB2To9TDKcZ/wL4UByoze196lPWWpKC/WjtX1IZuRatUqyy6WnPMDYNAaXwD3MDDfZuTX X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In the last version of this series, there was a discrepancy on how ->close() and ->page_mkwrite() were handled, as just the latter had a WARN. Matthew requested that they be the same, so this version adds an extra patch to add a WARN to the ->close() handling. Everything else remains the same. On a different note, I was wondering which tree should take this series. Thanks to everyone who has provided feedback! Thanks, Martin Original cover letter: This patch series enables P2PDMA memory to be used in userspace RDMA transfers. With this series, P2PDMA memory mmaped into userspace (ie. only NVMe CMBs, at the moment) can then be used with ibv_reg_mr() (or similar) interfaces. This can be tested by passing a sysfs p2pmem allocator to the --mmap flag of the perftest tools. This requires addressing two issues: * Stop exporting kernfs VMAs with page_mkwrite, which is incompatible with FOLL_LONGTERM and is redudant since the default fault code has the same behavior as kernfs_vma_page_mkwrite() (i.e., call file_update_time()). * Remove the restriction on FOLL_LONGTREM with FOLL_PCI_P2PDMA which was initially put in place due to excessive caution with assuming P2PDMA would have similar problems to fsdax with unmap_mapping_range(). Seeing P2PDMA only uses unmap_mapping_range() on device unbind and immediately waits for all page reference counts to go to zero after calling it, it is actually believed to be safe from reuse and user access faults. See [1] for more discussion. This was tested using a Mellanox ConnectX-6 SmartNIC (MT28908 Family), using the mlx5_core driver, as well as an NVMe CMB. Thanks, Martin [1]: https://lore.kernel.org/linux-mm/87cypuvh2i.fsf@nvdebian.thelocal/T/ --- Changes in v5: - Add a WARN in the ->close() handling (per Matthew) Changes in v4: - Actually handle the WARN if someone sets ->page_mkwrite Changes in v3: - Change to WARN_ON() if an implementaion of kernfs sets .page_mkwrite() (Suggested by Christoph) - Removed fast-gup patch Changes in v2: - Remove page_mkwrite() for all kernfs, instead of creating a different vm_ops for p2pdma. Martin Oliveira (4): kernfs: upgrade ->close check on mmap to WARN kernfs: remove page_mkwrite() from vm_operations_struct mm/gup: allow FOLL_LONGTERM & FOLL_PCI_P2PDMA RDMA/umem: add support for P2P RDMA drivers/infiniband/core/umem.c | 3 +++ fs/kernfs/file.c | 40 ++++++++++------------------------ mm/gup.c | 5 ----- 3 files changed, 14 insertions(+), 34 deletions(-)