From patchwork Thu Aug 8 18:33:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13758053 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 5A87CC3DA4A for ; Thu, 8 Aug 2024 18:34:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9CC46B0099; Thu, 8 Aug 2024 14:34:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4BAD6B009A; Thu, 8 Aug 2024 14:34:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C78416B009B; Thu, 8 Aug 2024 14:34:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A1DBA6B0099 for ; Thu, 8 Aug 2024 14:34:11 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5D6C91C4DAF for ; Thu, 8 Aug 2024 18:34:11 +0000 (UTC) X-FDA: 82429927902.19.808C9A1 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2128.outbound.protection.outlook.com [40.107.212.128]) by imf25.hostedemail.com (Postfix) with ESMTP id 99FFBA002A for ; Thu, 8 Aug 2024 18:34:08 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=JozcmOKv; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf25.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.212.128 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; dmarc=none ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723141983; 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=wBSqvI5dXaPzoETqbPOnxc/+b8+MULNZC8MMNCT5Abs=; b=SNS0vGUB2/R8cQTrPdbeAqEe/pcHO7WsrEBreeMakWLMrjXfDen21/SeOOUHX9QKC/zIdr pbggMdEmCCC2S+B+2yDMGymxhb+Y3AIJSxzT6MspJGsjLJvLrKZn8VOeyAamp1ENY8gjep HEWlXYqt82QM0K4hM3byc3FSKhaQPZw= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1723141983; a=rsa-sha256; cv=pass; b=8V0DwofA96hNlZsPQqTPp2Ng5EaUneGveUNwbzvh2en7q5V8yKIACoe3hHSIeGbFaEMxr/ s0nA1Kh7UWov92FwGmiS5gxRtgYluOw2piLlHhf1IV9q+JEKy4KqL8nTH16TlTWBSrysFQ ran+TlhTI3euggAiyI8XklLG/yQ/Yso= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=JozcmOKv; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf25.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.212.128 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com; dmarc=none ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e7iHeB+gO8ENeHmXvNMmqHVBDMebuXMQGSm6FcXwYVeVh9dkz+YvrDi0cT6aI+U+iRM4cJ+J5ZvnHPZLh5WpLyftTVu+zAqHLYGTLY4BqL2GoUu5EcqCQysMQloRcQ0Yh9RkUyjMBNFks+9bNrTKcQlet0kLpeU6NUjKzKV9jRhqmGtiLL5Xpi/1D2SzN4rb4wyeCFjGVnv0i783W8zf7Mh/SYY49FHUPH7a3+p4wa48JHaXoKUneJDBGQqeoA4nI2hEym3D2lRHNsZfE/AGdfccGrehPQmyycy9AW7HdRBlLEeiwOO1zK3x+IcjGlCaevCraVngXSfd7qehpYOj7g== 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=wBSqvI5dXaPzoETqbPOnxc/+b8+MULNZC8MMNCT5Abs=; b=gm9nTQmS8dKR5w3diNeHpML0mfKV3qidbZ6JFtxGiN/iFt7g21ocnDIL3kdmPmnhDTZrsftO0srP2SnfdXsF94C79uXvYLr4D1ecuXMe26WJN8AMrJkNiaxQVJQ5nLgQ3Is7g+W1ZRZrB81JLmwjUpqig3ksqK8pbKihLRKpFT0qIq18IIbjgrNf7o01cjtOhgHimIEZ77r3N5GL0SuRH6NbovGWU80ukNYy157GEGyHt0XVQgZFlFSVuN4rdI/f0Ts0aVhEIOM1W7wUUfHQ1exc/O6J01QQ3bvGK/R6FxFSsB0EpyNf9wG2GRti3Q1daO4TB9nd2OaIQk4+phKBqA== 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=wBSqvI5dXaPzoETqbPOnxc/+b8+MULNZC8MMNCT5Abs=; b=JozcmOKvyz76ll7oNloZENONSDfQsNcyGa37c8IyKEOVqTJOzmllOSvqxkzTKU8SBfShrt0QpbYU5Cse19cJjV7YvmT5+noIZs12d2oT1NFqkUj649glfXOMS3a3eFkeAPQf7L/JfMta+DAc+PuqgV0cw3eY1MUhFHWXr2cvax0= Received: from PH7PR19MB6828.namprd19.prod.outlook.com (2603:10b6:510:1ba::20) by IA1PR19MB6348.namprd19.prod.outlook.com (2603:10b6:208:3e4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 18:33:54 +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:54 +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 3/4] mm/gup: allow FOLL_LONGTERM & FOLL_PCI_P2PDMA Date: Thu, 8 Aug 2024 12:33:39 -0600 Message-ID: <20240808183340.483468-4-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808183340.483468-1-martin.oliveira@eideticom.com> References: <20240808183340.483468-1-martin.oliveira@eideticom.com> 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_|IA1PR19MB6348:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f15b87d-7b51-4821-929e-08dcb7d8a83f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: ljTw4fek0YiKThM02yRvlu+OTVvwBSWQyPHsXATUsNjn1zHABDYKi/vI6GVe3meNuOjNhiDC7t5mGYBTkJlWKQW5z1aGR01d1FISnXFfTAvoh6Tlpf4ItUHHJkS6r+DM6O20zBDBCjLsY7wFgH8fAzgQn39CTmGBPGt+C2NR2Sg+bpvZMr9OCr2bv5BQ0TWit0FEbTIiS+tHbzXRYtSmaBoaBsU7CLA0V5jNQO2GB/iZ6HfMEyMUGR55PRk0gl2aQMbAjs8vtj100zWPagqZwAPU4ZzeOPYKfTGnJqtttPwmn6gOSmE9FOZ9MdU+VfaBvQiibYFko6/RtWiOGDHtqBgf3xVq9F4/vsqo3zJjR95mzxoWh/HOhVDLGRgCHnPb3jbdw2jTlR+dzkrrPRuB9FdUTDfSw0BhT0TENmWh5D4ifMPRi+wwxIwfk9b1VWr6tZWZd9TEfilgCvlTq3/bcmTzMzzDZLORVj50oP3ZRpyvAQE85NR5Gm9WGTguSMbgy/zJVMS7ywK/nT+q9StIifkaQcdX55+aU0kUNN1N+sbtORgUUrMQKwIaqifNGd0+favZIxjSZH/fFiAQ0MwTxbRLF96YX5JKlw+QDwRURMW6xyXEyrfmurPbJPRvfzVIMrnqNHjEgkeWpQ3OCBPMsnm3mZwNoHl3TDWFikdFCQLIDa5ieN13wVPiVzWwEsDUcGdQ4HAO9hVPtXmzyeLABsQOejFfqml4RlbTdFUUdR8V9OKSqVRCpjFKidSOg84m8XTqtvy4vOxMs3Ap61Qm8CqnQ5bPa8nANrWqL5O9xCryQStISybw48KpPHgRYHf1HM//XD8hNIc6VxcFcWZN6RC+SUdmWuj1oFf8J/sB97Os2YCy0TfeSbg7eJbUwMnue4ECe2D50ArT7I66WtmI04cUTB7Jbq9h8agY9KCgelxxPG5A5rT8a3Z8punJyCrMQ24Qq8Ec3kUMwmzuD/zBnQxs+yAvQ+LQJwszQdcPGM7ZH+25hIwFLYRvNANo6qb3Y/V4bwJAEQrOp2aqIMSQWl+CbyR5SNw0YOYsM0HW9KsLZrcCpWJXbT+yLoSuRDXes2GwrLWln8c8XIsJtK8uXKxSIxYJ5bb5VjXfQeZLZ5iUtsJfxuL0kgU0qgH+luCvOf9gDKDMNqgXqc4hdbtc1HSPoCHkQ6MYEf8gJKwR+MmWI5ZJ4BRai+AXQ83p2QAIw7H2HXIXwdUKwmGe8sldhZ65gcLp2GBcbq8jaG0N7cf18vTeT1bpYpM17YSBNzGywDi5bHglaqKFYQRTc/385MaKkowYfiQzWRYTeTqBpKfrL75lq3ZKPl5+R2RQmWHJt0LfcpTlkJuhfyWR2LWzVoFutOjTqGEszZZToxu08UI= 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IfrUkY+Y/+ZnKAXpgWCkpPSuEnaEUuiOD3MGAbZLeVp3jkFf4xfTSbDLPLoKqFIET+2AU/A4QTjfOE7uJzk3mlhgbielDAnH56v7Afq0Kg3XBnLw0B5zlu/d0PTZw7qGIN56NKqaQvLX3j/fCm+ZfHQWkfgfYNCXyNrEKZwmVU3pMK1WzoUso7ga0xtJrJMDkUXuOzmou1yxocJ6LeSXfV6Rkmukvl2LztpDrQvSx123ZjtplgVeixqUCVbAJa3EAlt3MhbJ6FkYVgR8ZnCEC1sR+RY/2sEJ0fQqNwMP/6opoSPXJolqOwFJC46eAtyQ5HddIot7OO4Gj/J0S+u1j3rVgqcoZwb9Z3C5BCB19GrG+9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b5BB1AXEtZmt1jw4KZyB1y/u38SKOI2ZfPSkp4fmGbnBXD8lV1drNXKF1WDLa2NRUXJ9ldVnpgh94cltrgBwzKbtU2N9v08N2qBb7ucQ3shvk8hut7DAVzEElYDXS0BZ9aXH4820rs5fLdWSKr3vg0qFVYMCqvB1TU3/J2drgfs5ptSX5suhL2tj1vRwvH9u3e2rb5jWKJ4488= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f15b87d-7b51-4821-929e-08dcb7d8a83f 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:54.4761 (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: 75Bc8jM1rxkkdoKhWtPCyhLbSgyZ4DaAz06MBYv8sb/txD4peWOctwkdjxgOJ3509TXhJXCFcnsA0UsZ391Z+7/qPcMMGEWcuxJ6XyIV1Y8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6348 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 99FFBA002A X-Stat-Signature: w5tyjk88s11d8kpba34j37wjyyhktdxb X-HE-Tag: 1723142048-409582 X-HE-Meta: U2FsdGVkX1/fBwozxNDOCRTjmAOvJRkPXejB+VSvGr172AYa+AJD/BGV6ViQUXvRARaukcSoycpTZPaz5A9CB60dyMeb9h/MCUb0d8Zxti29BrWy55JBXyPD72O9LGRN+QdxF6OdM4HXeGEIns/1LZ7405oQxVQ595ID3Ei87tBN8xc0jqCXamXVHYJK6tQv2YCY//YQbI8zG5IdtMjIG+sKlQCCNrePNq+FyTMMj0BphSTzTs6oNgKEaM56Z/6zSy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+WXTDbXo/IDmTWlvZEXrysZjr3sApbOHASzpMggt8Co9nTd5OGUTag7ASDqs4FTv1yCRizYglyILG2RFBmxacN0c+PtNi1wO5wE3lq88kugGNb65B7DzLbsTMie+GbTP9n5hMqsg/4tw3HM96kUb9JJGm5cinYiR1wsn2bOqlgF8u3/mSeeDKSJWHwbqXSfyzO1NNsh3/1oCIL 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 54d0dc3831fb..df267b7890aa 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2547,11 +2547,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; }