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: 13694121 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 CAD6EC27C65 for ; Tue, 11 Jun 2024 18:28:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DB376B00AE; Tue, 11 Jun 2024 14:28:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 562966B00C0; Tue, 11 Jun 2024 14:28:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 366A06B00C1; Tue, 11 Jun 2024 14:28:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 143916B00AE for ; Tue, 11 Jun 2024 14:28:20 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9AD36141620 for ; Tue, 11 Jun 2024 18:28:19 +0000 (UTC) X-FDA: 82219442718.26.4B38007 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2126.outbound.protection.outlook.com [40.107.94.126]) by imf16.hostedemail.com (Postfix) with ESMTP id C2F79180002 for ; Tue, 11 Jun 2024 18:28:16 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b="sKhC/y/y"; spf=pass (imf16.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.94.126 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=none ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718130496; 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:in-reply-to:references:references:dkim-signature; bh=egpQP0BDXYyrYjOSywdL1sJt7M8DqRDf4NFqGyAHqgw=; b=IoEzXAF9mhPcuwXK7Tb9wF3xj9hR4jSr13oaGlNXbj+m7xcAvCyx9CC+QQVg/OC4wDnPOj a2moAXD5yjXfOfXr9z5SvR+hhnTqMfaxCNE93Fe3e1bxHYl5B9uJgRdGZjJi/lRCpw/lNk 37fIKlTUPzieNjtcPe8PwLtZVx2vZfs= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1718130496; a=rsa-sha256; cv=pass; b=Io7o0fi3fnaBsBEVGnTvz53lvGkqC4L4LUN35iBunJWr37jY4EhAUlwzoBRZdA0U1cNY49 7IvQx0yaBk8JrfMyZmISSmwREHuf1v1sdaJ3R1mFgZQvy/zPyStdNQQurboTxHI5CS5nOL lcabhC1hV+tzFf5HspjXgzE2ls/nfNw= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b="sKhC/y/y"; spf=pass (imf16.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.94.126 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=none 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= 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) 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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Et2tJRGkLposZFxbnhfP4OlqkkOlnDHrtTZZo2FMQCOaq0pPCv5lK8HbhNQ548oRcuAYEPl8uwIc/3uUkqEhx5cmzTvqdZ+05x3GZm1cRHxbnqLS/lUlQ8Zi8hDkSA8AMjl0drOM/cnxqy5Z74IvM0w7NfJ3dcIxgAsxOdszt17WbHbtc38trpVt91Bck6SdbQBO3RDD5e9bckPV8W09B3fllmcdOggqr4CeVH7ibtvsI9HZqmUc0lbwNzRQFjo4JGmnBLm5DpXi61eEbdLBLwIgd30oUMzLk24oAPkhTWLvwpYVOEUVHW/UfBTPKH5PKk32FZa4TEBjfyBPbB1gIOT7UnZxH5/IMr0mnqcSBtkkEF+uvEsGeG/pH89sZm0brTLaXESGyylCQ4YA1TNRRrC2WY/NubodmUaUu8RmsWA= 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: kxDb86xEIu6gBK+xTW9UQeEoACkzP+L5RU2ItoycO5rkrLoaHfJ/cFLdu2PjicQz05WM/T89bY2LA2xRxqOW3UpqLSQsAiQGyAd42IOBw1laCCDQW4ciLTLk7qTbkjcVhIYVez9Fxcz99hE5WOlRVAtuJzA5sTjVVw+fPohjDdjMfAYu4X1DRTN3QEpDIPgDl5IqvfueTccOvUusGWpOswrjAvjmM4Ot2RfCXKav6NzAFYxvpYxmxCoyEBDWphH2zoF9kSLDGI3kfrnyq5bpxFWi1zouI0TE0cDqT/y5jrFbQ3XH6+8zBoyQnSrRsH4v5XU+JA/aAlqUPY8dmJwqmfQuO4MVRcSt4aXwRVfu0gKLrtBwDjUaFgbCN2/C/NvQUwwSosWB1sFuDYfjZwgOiGRaospBOF2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1gSaS71t7P56q5//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 X-Stat-Signature: ybumu4d88gzbye19eq6chcjnb7gt9isy X-Rspamd-Queue-Id: C2F79180002 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1718130496-173120 X-HE-Meta: U2FsdGVkX1/zdyR0hs0sH9z1cIWY7PXbH30qlQwvNpykciAZZR5+cSg6kOk4bFc60XXiUTXLtUhiuI3Bvu1ntU2BRz/szBSkcro2JwKhl3psfwM3VRUeiWP6DdR5Y3wJsnQ6UWsaKT7Wf65QhlYK2nw4vRpq9Qvl8GYeeJHxb9gC6CEsrV1CBrSEf79XRYpri1MO0CN6jQ+AgF5Pu354YymOoxyqCjswAdM4mvMS4Ea3AGdtLWotE0PMFuJcesKcLWkiK1hF6oI7cRX3D1dlMi8jkM7mBkz1DRwUvywQ8Jl1A0NSuin3EhDQ8zVB05Ve1Le9poGMlqz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Q5/UrwGt8dvRylEJB8AWAWdK8LzE= 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: 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: 13694120 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 F00ABC27C65 for ; Tue, 11 Jun 2024 18:28:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84A956B00BE; Tue, 11 Jun 2024 14:28:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D2746B00BF; Tue, 11 Jun 2024 14:28:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FE946B00C0; Tue, 11 Jun 2024 14:28:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3B66A6B00BE for ; Tue, 11 Jun 2024 14:28:06 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B4A09C1056 for ; Tue, 11 Jun 2024 18:28:05 +0000 (UTC) X-FDA: 82219442130.04.B078370 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2127.outbound.protection.outlook.com [40.107.236.127]) by imf23.hostedemail.com (Postfix) with ESMTP id D96B0140004 for ; Tue, 11 Jun 2024 18:28:02 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=HEJve3rE; dmarc=none; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.236.127 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718130483; 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:in-reply-to:references:references:dkim-signature; bh=ltSVTnfSQLBLzvKgi3YJev86956nJV0gsu1ICDHeH08=; b=Tkr47xWnAKVUHwxeUt4Y3TZ9/FzVHS3k3QDCCgpZHsWasleOAMuIQh3YXHTti5JpcDoFdE q2FHnFK+8uLG29YS1QDkg9tDk1/GOqIz2StLfY4W18GzmDQOVtwHk8VpVVYuCcuV+wYk7C hbcQvh/B7/XKWU5H4HIxvQPqA8S4nMo= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=HEJve3rE; dmarc=none; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.236.127 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1718130483; a=rsa-sha256; cv=pass; b=2uUrigwVD9PD43QjzU9F0ih+EH4qZF6RzZ8QgMFQxt4Z47mETwlp5CvABiqZj8E+VrLvXy BrsmQIYKJUw2EHlr67DKzaFfyn+CwdLIB6ie796YqjOaz66GPrMuWDtMJOs/KteFXzgleC wgRa2fib8xGRv0uRtFyx5aMS9TRxjAg= 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= 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) 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/d0l14MzFZW4bkBaj0jt6RRnhlVwMv6b3Y42Q1vqogZLtYBcmwIK2a2tA5sCN3EmGPID/hIIO+3+8qLViRHrtEnLbU3zB2DtvhIyjGLf6HmrqZCfFizMVT7W2FOo9tNDDMxT9XAUB5X5SafFDVRdf1BHN1yAvsZbJLSAwmNMC3dqjUdCKp130TKA1lhOHBO7gOQjUkI8dG/sohEaZ2JRrxgjj1seWYkOXw0n+iHl7U2OGekAN1P53D/sziMfY+a41Xt2XXYobRaZsVeqtP5Xb2LWwVzJntO7wTaqNbRLb1bl/mo9zj12fzAEgEGsOy6uDmyamN8ZgSSFVyXkAmo/ltLbqv53owhDzYLKnHvSu2JimsjVa7OqpyK7pKvfb3WmVTUF+85CfKmLj3u8Dq4jdigbZJh6DB5LIin/hLxMeBAxLGKCk6byKgkwV/2MEBx0twTTqvXjpW105XqThtDT1jbM1ovKChB4Cgiwj6MqTOtHVPnXC/49HDmQV63QpKvTEsN3cQ3XME+Pfe/Yu0it+mJJH0JYecEVdCZHv89vXXbT+P9Wy9JbDlWDnZtQATYffRy/RAzYlqj/7KpkrhaDPpS8Adl/WVONHo0RfgvAoDQdRTec8nospGiOo5I7rp5WFHlxEVlSd5s+sdv6kAk9KfuCU6nLFUIxNFSAfOnet1fFe7vh4DYIsCtm/z2/qMQs0MKshG9Q+w9HrLpRRNNrqYEVJtZGSovF5UbW2HBGvaTCBys7LczK42lbiqPhQBIBco+Y+6C0wa60hbRFiXnuMpmJzRR6+4nrw01Tc4PALIl6C/evMR1gNgbfP9gv38mQAH1rvo3aMRxYRf1cZNoAX/AaWem74/WfdNtAnpPi0tKnEJa7Oc65HeYQI5rvyF6wffJ07vtenUWu0dbqjnl0ZAFDwy0M1qeFKN9jC2g1TvMBsGa/U2Gb06elXdZvTImFsqldRpRRzXBYdUlGhazYlUNrrqK75a/Sihls= 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: snBOHwcygg3ghtGStEnwZeut5s/ucWDTffUeYOj0/XiePGJcChY+GeAguWriPHjMft0sYKlz0fngc2dvxIlKny8GXIS7shkH37g5jynub55pM3o9byVgYui/kEqn1egQi4x0TJRJh8hV73MZa9Qs/kt/jlq2PBuIQrgVJ+gTGg9jdQffXGU4qoN54mmFAwNIuIXtNFUhqd1wxmjgTui2lNbesL+h0TzT4/lmRd6Np0Z5hzhJ14aqyx4VWR8QUqfe98dNA3MUrmerr/+5mBve/0Q3i3P658tiDlDA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Wv5qJE5XqUq4a625WTCEhxpIjzDJk/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 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D96B0140004 X-Stat-Signature: hs1h3534i3hnqbhpjsfrecyy4pf75uid X-Rspam-User: X-HE-Tag: 1718130482-455832 X-HE-Meta: U2FsdGVkX1+LsIhr+HuPvRdbzWI/ti81lazDb5IZ1ZnxsO/mxQA2KZ5sMogkzpQSgfA0ErfVAUPqf01LUQw2QW5a352flPt3l4Zqw6yl8z+CWp8jxdjPCjLvK05PxLdjrR+225zN8GHjf2fmm4C+du8hzaeXSyjlr+YeA73zy3TFcId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xZUBf0hAV9PItvVDdHG4xvIvgxLTP9JyMt6F0LL2HbhaRSQ3GETC98d/amqxx3ExwUPqxGJzxwsaY56DJ2Gl2jnFUNb0+hhbX7UowAkOcb1nXJyrZaEuOveIE77NUice5hPPn0AXeWBEyMybsjUtZm3e0KuSeRHWvx7CaP7iGk86Uj8= 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: 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: 13694124 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 16D14C27C65 for ; Tue, 11 Jun 2024 18:31:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A47856B00C7; Tue, 11 Jun 2024 14:31:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F8A16B00C8; Tue, 11 Jun 2024 14:31:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84A896B00C9; Tue, 11 Jun 2024 14:31:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 656336B00C7 for ; Tue, 11 Jun 2024 14:31:00 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 087FB120FFB for ; Tue, 11 Jun 2024 18:31:00 +0000 (UTC) X-FDA: 82219449480.10.9E54601 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2124.outbound.protection.outlook.com [40.107.236.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 466351C0025 for ; Tue, 11 Jun 2024 18:30:57 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=UvvugJeH; spf=pass (imf20.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.236.124 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=none ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718130657; 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:in-reply-to:references:references:dkim-signature; bh=zF/PKkFIEpEBi0OtXGW3K1kbUiVKvbhfvU9Blf9kNxE=; b=u80PgC90dN1mDCgcOYwRsjEECXOX6nEhwXXV4lXMRmQi4dC4rZZNXKawNyYVItujKYOA+7 zhOlR1xn4KxRFZpw1eW7TAHRYKl9jokk1Oggd23nwjti87h4kV7rSyPCkC9CZBlBRM9mhX a3uYYf3HVMrYe+R8F4IX5DAPTe+Irso= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1718130657; a=rsa-sha256; cv=pass; b=IXp5I5vHignMuTdzlJchpXb7F5Th8lvkiMhJ5bD43woX2IQER8pygYndZpee9I908ywDC2 sQCHaFM0LpQUCxKr3y+KIa+yydxPB5n0MnsZX/TO54K04MX2W7HYSLiceodAozypVjSAKW JNY6a2lxvffLIb4j2l7Uha0aMdCVROw= ARC-Authentication-Results: i=2; imf20.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=UvvugJeH; spf=pass (imf20.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.236.124 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=none 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= 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) 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+4u2OBJGHqd3rWS1Jpkc8aJ6c9kX5B0UIYpOS7rXszASXHnWbKp1kAOgBLk9F6uKRRXFoNaiAN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QM3rqr7iilQluM3EpsB3WrQYZ/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+kql0cY3eIEYNi45pq4eF/NzDonGwchOTAwjgRR56GpN/Y8wgXP70G4UCMQrCp2AMEssY4q2UTJ7tdZcvhfZrf+TASQkWVCZutOzv+knlaJYLCdN9VcB7wk/L63CCVgYmNcBKJqCj3W73xu9DDn5aZ59IGfq/Rke7lDhRX0aDksiZyflAr2LMjOquiblqBwZBsWLRCwoETrjZ9vA2zU5g0swcqp87zn+iFhP8MVT2Hd1BhXrwGfZG5YvJ4B/2wFlZSqaimwP/NAq+sE6xECUoq8T2eeQCVo2P1Fa/HRUQ79dW7JdeWDnefl1MWGjHViYMaG2JvJKjeO+t1bLZYuqwxLrtJ1P537Dya0/PBsTaccEQBy/PDc3ek51dyhh4qr39vH2GUXO4qY9rDy1cr6vfgoYB2SQCOa8ek04rK/BsGZ0AmtG7X1p5llE0SrPNp3/PesxVEDEzmhtVHvbuftdMvOZxBnAA1uR5qCOwGKhT0iu5iifZOdQmWGIyD2Oob9szxhgC4pjt7lIeTS+1zENAs/9FqqvQ+IKiLZuLWYNLW8VUD/5en7Bjb6CTTotG6QSAUHWujTlTZ/DuzWdgszzhjyvYlQE7FkX41OEQQYqtW02BGYcLq5JBPCwFtUwPmQktzBp4HrUYuEP486ayqtKIMhAZ65LCcAWPmLbGe9qmmrUuKHm4qFWfSdTYlFnxYiJGD8xYgdeWF0j5u+3lTya3tECX3tOJYrDp8qlm5pSmAy3I5YWAYLeup6sWS8MPN5gW+z2nmSfzZ8VOsLjkyhZF5O9tayvXL7ABDEbeT7lmIsdsvBgbon+hzSd3AmrfIaTygBGVJMhabdIThczd2cQQV+PLTCIWZ22VmXmMd8T0mfk1Cu1UsC77lqDNfysUY/IPv8gRxxzYkXCyxBtaXyleNhuApizpedhVPae7hgNupLJ+XCRJ+U6RKKD46BomayZXnbfxzwclHQeN4L+hPD80rCCDIY2r3ZbqjvwlPXQtIwdPp0sQy1yxAuwsZkjvpPBwzt7biDGoWzY1+ZHmPI+1iL6y2C3jcBoRpOrDgnZdEwKfrs76lBCguQRgRYY8rnGzmsnD5Q5VF0ASs3hJkhpJiyA+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 X-Stat-Signature: 3tc1yaajj8earj3t3ke734e4iasgxf1e X-Rspamd-Queue-Id: 466351C0025 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1718130657-840561 X-HE-Meta: U2FsdGVkX18pQU2pQYvvLoLhhuHppwJMFvISM6qi/bsKN+c1eDGH0HKNaXDwLVWVvpVvVI/bxzU7HIamLY/tgoyDGHHiAKQK0AiWGhBiqncCB3GXIDjv0ugxOHlQjyEtl0t8qD2n35ZAheCLIQIWLdqkalkpanborOU4thmMTIviDjHybUHD0zRQH2hb+MSQ6JtVi+pRgInKJ0u05nrivgrhBuP7De0jogE+Bw8YcaGy/E8AoSWSPeNEZw3KKagijM2yLkAXD9WEwt4MXWWt8eBpcD+70eQp0Wblf4bZzXWsy0gFE4VgDBtMcdjHzMCXY8k+1/H/ShcNPQp4sStSQZSLCkAJx1XU+IUp0EPmJxmcAIZVkHmPG28PPzh9UN6jeOfualldMJL96EeMBq7Mzleda4SBHWDz9oAo1FkezN8npbueUVQXpjkgM8qyEkPXINJ8GAxm5/ecyBhJ5HC7iEs+9ORL360Pb554vkPX+862eseESGI624XQ8HaB8VG8KUbaYXesKktqIDkw1u4HFCoZYbWO9+zsn2jQJ8jcVHUjHh9jch6xZpnswIdQwoPe5Vn8dxdgdMWtjLiD5BSpi0VsSMaGlBw6vzmgmGvkIg0scJNFnYlJYDAnTOMLpJc+tpul0X1hH/wjUK9tlHXDiRgwQZnUf7UK/a/jsLyTA83zUFbPx72BWsD9BEacRDU8dNG8uZSGc1tq9hwIQ/Z1SySRh4UnzT1i16vf0pkBkxw1xJ/fEqwDLp2eQbJW/KLD3qutjU/rTGf7dDT3Z8rBWJfEBD81gna9AVWrvIx6O2vFCXuSOutZu2zwnVd8WJmPG+GycLio8NgAc90M4ePIZRREpWfStqSFoQgsW1APLolMcBJT6iPjNigywJw4Py5ZdsEHnjmbjmifXjkLH+wv8XsfsjHLZpWkYonblp751/z38ZXty4Gz5iAhdC0OAcAnll2R2TcL7QitvNk4i2O 0HHtMeqL KlYRBkPx2IWiLRhkYP9VBJJ/mvA3jFli+j0ik8iUCp+H2+G/PBq1SFhj8sA/tPMaj1QqqP45hmYETKdmNJyT/Ak4TYgRiB2uiYf9sNUXLpm68H0Eo9VJlVluOWXdzFvyAtqT/rxLQm0iuc40rxbfgIt6V3EE0toeGYBj+PHj2rcl8rukDKvXhlRDZHqdEU8xlf/X9v7kigldSU3kpBJ+PWiQkWzFm3ciYXRqFiYfFQTJWQbLpF32/TJIo9R6QLaHoxsiH6/sU5Ki8LiHTNoFunYIYQOzIzXv/4g+X/SLb978q07BEn2g9ViSDglASrXvSFxDOeBr4i1TkNq2xJv4kKoULd0182sqnXkNHg1UGWuUxIU6RklyjszDhwYwxnzVekj+GKC1r6dl6vDoXTkFaav/HydwIaXf6bVc+hAFUkKomZr7oOu+gThhJNznWYDyTyhIOFzvlc7A6zeyMLqWTrrxjqcQwKoOwY5NBp6BgDW8E14DxGbWBFsF4QKmiGY43SYmsPiMGLIaj1rMs5YI0OpkOAsLMF9tknjXU 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: 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: 13694123 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 A42D9C27C75 for ; Tue, 11 Jun 2024 18:29:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3425D6B00C2; Tue, 11 Jun 2024 14:29:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CBB66B00C4; Tue, 11 Jun 2024 14:29:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F64F6B00C5; Tue, 11 Jun 2024 14:29:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DE5016B00C2 for ; Tue, 11 Jun 2024 14:29:46 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A17311614C3 for ; Tue, 11 Jun 2024 18:29:46 +0000 (UTC) X-FDA: 82219446372.27.B1C8EC1 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2119.outbound.protection.outlook.com [40.107.236.119]) by imf12.hostedemail.com (Postfix) with ESMTP id E3DC940004 for ; Tue, 11 Jun 2024 18:29:43 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=QTeiy5Vg; dmarc=none; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf12.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.236.119 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718130583; 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:in-reply-to:references:references:dkim-signature; bh=gvCcvfD9XrahsrBCD4LSwm0IoahU4H0qyoBCobOTXhU=; b=ERSTQQ5yByzMuzeJh8wOhexnskRvvWT2AIevDpkVzNXdzLh/Aw7Wy8c931oxV/FRJanIfp ZQzY0PSamoxPhRHFH4tX5Y8m84Rua6yuVn794IIML7gAmXY28ymo/tm6oFcrcw09/ITi/Y 5ymUzEHiYt4kVmFeBWgv7wL4iOLkr1w= ARC-Authentication-Results: i=2; imf12.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=QTeiy5Vg; dmarc=none; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf12.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.236.119 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1718130583; a=rsa-sha256; cv=pass; b=MI5evQzCbxAz92XNKi0LxX8n099WrL9kGRNaqR0jg+H+CdlKmEMWajpGkmDqp1XlEfS4jD tAAuA1vjlwb8d7sqPofR/wCGBcoiZUewWOua4JARY2sRmtjvgfvg+MZq5wP2tvDAGzg3g0 SQMd12rEpm9Z00AIqcqUql1GPbLALKQ= 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= 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) 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/YYrXHb6p1pf6feOt/nmQU9iNoHZuzz9NtGmVkU2zSKgAV6NJZn9RI7MwdHg/d60Z3EX1Rqduwhlp9lwpE2xAVPskdfut0j7th5w9+PyU+AL/CFEALVOFQRlTHo24oj/1yUwcX96aCDdd8MZVS0TNL9WbIrnLmu2pw4siYkNSLaNAbPSPKq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FS:(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 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E3DC940004 X-Stat-Signature: e8jwbbi4zjagkzqfy15iym6q5teossjm X-Rspam-User: X-HE-Tag: 1718130583-25297 X-HE-Meta: U2FsdGVkX19ZTCT1F5k6DxCOatmyNASgL18kvvZ2xtNoQ1MPfTkCWrlecuYrANRecPDAW11nRIRprj4JNjt73XIYezpl2qkHbAwmBO+eeuGs7hkqX7gVUgjFWcrLsM/WPIHlYRRr2JjCbkuoFo9Lzv5DnM/UeR6/vVhbndtjILDlvJV8nlU9Fj78j3rBhP2cly9xhadhEfH/13OR9Qp9/+UT8qHCrPoDLpp23MovPAFprmNm1Fw1wGwJAD/yFC6nQwOYxu+l7/HPMRB2eQhrt9/EG4I48EednlQEjMGTpjhF38XHxAKmB7kcvTv4lEEasZ84TZeFYroszE3BLkl8Ns73YECMIsr7Uq6/quzD2sMMA9Bwr79dbUF1HrxAF1nuGFVBLijIEW89XcZ025Wdjm2+phh62GtiZ6M7Gyim8a2j87urwsXtpn/EnEAOl+HyZdlGS8zj3daRzYSxYp8oFYjEvwnp56tNoSEJ0gdnrK8IQh9i+NsyK32MzcYwTmTW4zhNVT4TV+elGAXK8U7uwUL2Qe0fq8HyDTzCTodWEQ86L+cvVcjlM4ANvcfi996aKsnXHKyfXGvX7ujyvhe718H2oUg4MaOj7Kq1tfR5lorntZCsTGhtdPO9QWAmMszxRzQ4HehlfinlsVeJoeeGoj/kwdqgaLq7KTPhAKEKah/GXFt3dY5bFnQ+5hlH+qj2V9YnuIyTl1niszlmHFYkq5K+W4pxBQU1rEroMe6grKjsv3HBQdUNof/EOGpflO/EVTSnLBkgEJPrx2Ex1oKrU2yQMvswbOlo2nrrhjFdaIdkYumFzJW8lwahka+k+MaCGZKQh38R9ApWrLHE9Y1rvS8XCj9rTMnfuwtGRjfOU9Nh4Lz+lSiC5zQ3cH/PAiypo3IrI4RFEZa/mG1+Uu/APPJ9jR22rCH/T+DuZnojSLO2RRMPdbvXA84XB5J+zJ69EewUmvva/Z+239IKsYd /iBn6V+f d8fUIZ5L6Ibrz4um32Uz1VJF/eidWMfNt3GzRswF8TroeXoiJWko0ADyRUw6a6lCFaNoW1G07Jb1Ghx9FXIkbBixoPy6wL4reOCUxfZTJq+PJApMcqQMdSPZ78vGLI9ZSTuCr0Qb87UUvpa6sMOLcrX85xiuEDAbvuiIn4rwouOTGmoNcVxQ7dP2+p/IMLtYyB7mLwzqsGxa/qY7Cr4dhVS/oipRZpSpU0VI+mQoHcrxQL59QplmwY/s/gZ+QcL3kUoWWc4kAFO3Zsi/iGHbVzAzCU2e+sOtLNYNFPAlAmshlnH5g9AA9LxMSMSF152YVpI5QZshartRDBzLGuoEhJ3qyt0C591e1scd5Ex36nKIku3uLcaEoQUWdRe1go57hs/3KL5Hz+GxjxXWRJI6Kp1ZAYQ== 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: 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,