From patchwork Tue Sep 10 04:14:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13797830 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 53215EB64DE for ; Tue, 10 Sep 2024 04:15:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC4506B00E1; Tue, 10 Sep 2024 00:15:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D73E68D0009; Tue, 10 Sep 2024 00:15:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC7986B00E6; Tue, 10 Sep 2024 00:15:42 -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 9E34C6B00E1 for ; Tue, 10 Sep 2024 00:15:42 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 35677C0A25 for ; Tue, 10 Sep 2024 04:15:42 +0000 (UTC) X-FDA: 82547514924.29.838EE0D Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2080.outbound.protection.outlook.com [40.107.236.80]) by imf01.hostedemail.com (Postfix) with ESMTP id 7FA3E40012 for ; Tue, 10 Sep 2024 04:15:39 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=hS2ezw8+; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf01.hostedemail.com: domain of apopple@nvidia.com designates 40.107.236.80 as permitted sender) smtp.mailfrom=apopple@nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1725941712; a=rsa-sha256; cv=pass; b=15Gr9JTrBAI32oexfRESzIGnhVWZTX169eNTofiH2roPTvA5G93fRCEgagzmkTZhr9Q6Y9 FMb2evwbza71DANkLySkEjAp97RdtSPAXVsOJnU+1pOlvi+6trowDt2KvWLeLchDFyBzk1 PfCKec/rlDirEJyGEqLqmWJwVE540Ic= ARC-Authentication-Results: i=2; imf01.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=hS2ezw8+; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf01.hostedemail.com: domain of apopple@nvidia.com designates 40.107.236.80 as permitted sender) smtp.mailfrom=apopple@nvidia.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=1725941712; 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=mmVmguBDaPXZcKaagi7Z+K991/nm44PK190JdcuA+tg=; b=vAAT+J/m4yYirrC1i4BhhBGFEeNjeHPtiYlggezBe3RjoTvOYEMgXKn9+6TDjXYBU3KK+r GGSit4EZzPrR+7AG+tusK9YA9prkaHoLkne1Vu55SctffqTY888MCfEUJBdCVMVAOCvJpS qoeAvSvZ4F7nF2Ed9keZuZZcuiRFHV4= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rZBaqegP2yi+3HEsP5rP6SWphwz0NgmuPRKqrcTPzQlqnnh3rxwQmvb84jqzI1SbjPS4kUO/QlRQsJ6MLHWt0LxgW+7OX3skfETvioHYu+PZ5fJEEO2IOPHQXIOTVBKkYy2ZkWzyfj3B73HaaFwuVizL9VP999w11iCLDUWfoAXw4diIdttmgedwKCeICTkkGUmcy5hU1fDI0qWwrh3maYP+UuOUbTXnlhH59h1fK5PSbRt1WGsyxR8K0BQBMsYtxecvwy7GNRAW6RnEMJ7x0HX2+we9n/F0U/mfzite7Jo3tG0EfG6NcTnjyhEDwkXh9xn5p2cwCT+q3Wn8yG/YjQ== 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=mmVmguBDaPXZcKaagi7Z+K991/nm44PK190JdcuA+tg=; b=Zu69LGT0mUtrJOIupd5Kd12sG2ToT+DA0LEDol/NJkfmUXQAhi77jG2aW+tCXhT/ueYA0NKSSE8NUMrMvZirmpgdjI5ofx5T+FQpqyUcxCDYBHedhdvRgQcIhDq54+rGnBoZ/di9UqqAEWkNyNt4t+1FTZQgfGQZd3in1q6KAy8SRzrtkZhyZhxEB2BS24hZftW+Qmu4ByymLIFNguUqhwexIVTGRnl0Nn4RLpTqIxySai0uAbrLyHnEDDzWq5PCHNOVqPp5b93iuD4Ny7uQcyIHb9t/qRXdiNt0Kz+Rs3UnBJqdKtcpIA5Fyrfz6VyIxn8QOmsyvP2aRsfaz2VL3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mmVmguBDaPXZcKaagi7Z+K991/nm44PK190JdcuA+tg=; b=hS2ezw8+I+MLJ2F3SgAVUJQTBaY8y53MZtqrZeZxcX2nQo91JgDlnFL86r2bv/BSZz2Uwl3hhaAvoA0BDzXVkErE/Vw8Lsozm92KvTHu3byfQBs621gdxv3yBLCXfwPp41dspzVRXac1XfJjVuFbfQmNf9nooGYtIqdSmZqnMBx3b2+xXobjxNCfspvjdPMflapjdL3HASWIn0g32EKbpwvVU8UwJhIqUSVUrAlsAUv0C1pTtXVAuzbu5hp8bPSRNxZJkZ7BB+/PyN9lgFUPkyEMRvhHod1R9/P+SXZSKfZiNMMUMFT+ELQ/eZldE/0U6RLNXucHlTK8XP2/D+GqrA== Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by IA0PR12MB8088.namprd12.prod.outlook.com (2603:10b6:208:409::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Tue, 10 Sep 2024 04:15:36 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%3]) with mapi id 15.20.7918.024; Tue, 10 Sep 2024 04:15:36 +0000 From: Alistair Popple To: dan.j.williams@intel.com, linux-mm@kvack.org Cc: Alistair Popple , vishal.l.verma@intel.com, dave.jiang@intel.com, logang@deltatee.com, bhelgaas@google.com, jack@suse.cz, jgg@ziepe.ca, catalin.marinas@arm.com, will@kernel.org, mpe@ellerman.id.au, npiggin@gmail.com, dave.hansen@linux.intel.com, ira.weiny@intel.com, willy@infradead.org, djwong@kernel.org, tytso@mit.edu, linmiaohe@huawei.com, david@redhat.com, peterx@redhat.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, jhubbard@nvidia.com, hch@lst.de, david@fromorbit.com Subject: [PATCH 08/12] gup: Don't allow FOLL_LONGTERM pinning of FS DAX pages Date: Tue, 10 Sep 2024 14:14:33 +1000 Message-ID: <78b49fc7e0302be282b4fcbd3f71fa4ae38e2d5f.1725941415.git-series.apopple@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-ClientProxiedBy: SY5P282CA0110.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:20b::15) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|IA0PR12MB8088:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d92a199-4c00-4b0d-b7c4-08dcd14f385b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: N+IfuPAs7XaJc3M9yDU4ghwimT9Ez+RziZdYS1X3rruWJD4fMmspjCzE1uSUQr4fBQ4dVyFm1RsBHjsVBHRNFlTXdwFRkoldYQGdybvNVo+iDqO14q0nphPUwwcnXqRTjYIsgdr1zlSWOjCn9NRu/km9Ng0KuFVaPVnXuYS4xv+3vNSTLGAnddF5eH2Hdg0qcNWoPOLKDjz2H3pDO3+IU586Ku2fJDJS0/StNJsG1y8U1eEX53svdDpFXQ5Kj5DIMKa9MnWzLYZegzg1hjy3/nj62BYMvHtIIKTBWWKiIxnjcZxowChsLSOUlQDzmx0+E7uJwrX4Bvn+mxs0lRkzRA2p3L7YzgiOHE6//g4E3PSf2/nVf/ZeFmKDSdoctm3akAu6WoC2GZoUqzftJx4e4A8ULZJlgYrNoGTQRvaVxV7SXmHmQRHmUEC9khEFdkYSku+++muyShMfBRYDCEQBH6PBG3RgRl0RoFfJhOZfS32GWaAPWEuIVbzYPH3WLWIhdtov9NiEkE9IqtsvLSW9NvtPjrYSZQUccQVZbTHanfjmMbZH9Erfo5ZArnyqGmtzQanpxquQtpeM17SUU1X6nxecModG/2Nfh1mzm0M8x9UcsApV+AoFzJDq/VTm+Ugn0L91UA2HpuhdYGtofY0hEsGhl8s1U7oaoL9IosofhNodm60cNLAQRqQ/IC++yXWm+Tz+anhqXyU/yubCujEDeEUGe4Peg77GomhRaryzTi5ID43t4AVIAVE8upYOWgQYXfaazTyTPewRabwoxfI7q75HRK82B4lLAs/6ZxrGJYcrq/wn5Bz0FC02w3clztW4czPJboVUvAWfcrQAzfHyFINCkMh7Ypkagmwt9wl6zwBWNjdD8sam6+WpZsK7qYDZz0LorwyXycTjtru0k+TMlRA66Sa6IJ5YZQdkDeRebjOZt4WQGK2lahXUzOWyRK9iPpVxg76OSiKDFUBV4KeUdRKXk1CeBbzdNwYzXgd9owAw4Vat7QF474ojoiR5dwvqalPZ5oAcFIYEk4YjwlmHXG473ZsfuCyM7Rm4OzxCICA+8zR/UTrAFeOBv326iwG9dQWJKoR0QvUCygu/5GTD+VzDZA/RwVWxq1QACdQeD/irKyroqXvRAiAHhhImO23T6FSHiddV7bdN5omJrFoldaziiqcE+JpPgpwVuxDDSzPOrNrr3NCG3SKBkQZdA617tUBdFiazZnDy1kj+lvVqWM0ywLSRdwy1SKsoBQatjbN95/SAvsxDP7lVOocVKKQSr5nDEnPr687ix2a/sUjGXtNwIYdEXmRKwFbvbEn/H9BU4OpzPLwasj5OrHsPiVQxC2AA79eCo8qitcZ5ooKQcQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z5lgFlHP7AzaYSp3mkzVPbqYuTtAeWoEg1C+f0xOkrXprZR2ZkBCc28IqRn3ORx9CgB53vzROsRRMtgtC9bOfvfS90Tx3rWALkBm/g8KrozgWe1aIjhECrLZPgdxrAt29U3J0GV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mhi8bogdWLePblI4Y0SRb0hmyKx4+61AC0S49nkeFY8iqWW/fAiTpVkQSAqNYzY8aG3GoFWaxkXVXeHKzDDxcgeSjzLYiWFKk78yCIGIW9oBmrMPBlQqjhCKm3pumDCUUO7mNH+P4AYY82n9MfH7Gi+kLNlJXdqhC2PIKGVwgdnU3mzpHBEMW7bwFaSPt4fwDKZseUBT277HO/ejjRjZk8Th24+SZF8jRtf9eJVqYMCm1d61dzM2FOtsGt4OQedwG0RsKJzKQfjtt0V6mU2W1cJAmoTu3hOQCmIF8NsCzwYxPoPGq8awIHfpA2VgKFCGRvWzgz1LP7S9MsGOsuzfoSogrmxKAt9x65Cd8c9QSUXfEYE2UIPo9gGIXZk6qhJDc2z7mU X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d92a199-4c00-4b0d-b7c4-08dcd14f385b X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 04:15:35.9036 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tCSFupX6de5G6UEizforjsXwcCeAwCCJKj9mo9MljSe1339BjRIwjChs0P15VJepMRxtgE5Zl6tg8OZDyndtOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8088 X-Rspam-User: X-Rspamd-Queue-Id: 7FA3E40012 X-Rspamd-Server: rspam01 X-Stat-Signature: 1x5yhtt5hwnyhhwrdzcnq1rth3nzsy8r X-HE-Tag: 1725941739-227881 X-HE-Meta: U2FsdGVkX1+Tk6AHnepvGzVSB8fYMA/M83aXVmRXOPte6oQ0dduqpLlYUcrtRr4WBmob74LEjty12ih/Gbm9HkdFjhqs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elIBiXAtQ9JSjdTlWW05SAEZmSPxRTs1J/9A5zsLcL2Fm9lzxajfrshowhiyKilTVy0E+RnHOjsN1R7wmzDQNt7IAwNdt3R3a2pzYsGkAuhojKizLC3emebo6OzSHjlkEefCr1ymwSE/NGfP8rsXmZSKqt6N157qXTUJp/efrQuKQZw== 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: Longterm pinning of FS DAX pages should already be disallowed by various pXX_devmap checks. However a future change will cause these checks to be invalid for FS DAX pages so make folio_is_longterm_pinnable() return false for FS DAX pages. Signed-off-by: Alistair Popple --- include/linux/memremap.h | 11 +++++++++++ include/linux/mm.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 14273e6..6a1406a 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -187,6 +187,17 @@ static inline bool folio_is_device_coherent(const struct folio *folio) return is_device_coherent_page(&folio->page); } +static inline bool is_device_dax_page(const struct page *page) +{ + return is_zone_device_page(page) && + page_dev_pagemap(page)->type == MEMORY_DEVICE_FS_DAX; +} + +static inline bool folio_is_device_dax(const struct folio *folio) +{ + return is_device_dax_page(&folio->page); +} + #ifdef CONFIG_ZONE_DEVICE void zone_device_page_init(struct page *page); void *memremap_pages(struct dev_pagemap *pgmap, int nid); diff --git a/include/linux/mm.h b/include/linux/mm.h index ae6d713..935e493 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1989,6 +1989,10 @@ static inline bool folio_is_longterm_pinnable(struct folio *folio) if (folio_is_device_coherent(folio)) return false; + /* DAX must also always allow eviction. */ + if (folio_is_device_dax(folio)) + return false; + /* Otherwise, non-movable zone folios can be pinned. */ return !folio_is_zone_movable(folio);