From patchwork Fri Feb 4 02:00:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12734749 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 657C5C433EF for ; Fri, 4 Feb 2022 02:00:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 224196B0073; Thu, 3 Feb 2022 21:00:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D3E16B0074; Thu, 3 Feb 2022 21:00:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 024126B0075; Thu, 3 Feb 2022 21:00:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0064.hostedemail.com [216.40.44.64]) by kanga.kvack.org (Postfix) with ESMTP id E68D36B0073 for ; Thu, 3 Feb 2022 21:00:20 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9A8B090F78 for ; Fri, 4 Feb 2022 02:00:20 +0000 (UTC) X-FDA: 79103442600.22.A1E8548 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2082.outbound.protection.outlook.com [40.107.100.82]) by imf22.hostedemail.com (Postfix) with ESMTP id F0842C0004 for ; Fri, 4 Feb 2022 02:00:19 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qo1E4zRyweH1vXjlCsHVuOg9VE6xAUD2dvxzqdCZzf1QrUWbqfrVT+N+niUdNLV66DhiWuI36Eo0dJ2cAqeEKdhtM5Bn6PTVfkS3yNpRXEyqS3aWGqThutywmcfFWaXSQGzdrCaZILvR0jHqnFkMtMjQo3rDp0PwbJNrzTd1bzoPXx865wjZ01Gg84IC+5ZgPzbj2IDIGE1tJ1Xh6TX3vFRa8Az99oFrC7TdnvYPZO9KUHTmX292DYBWBPxUaIlw10+kUpWc6T9UYUKU33XHLVBj07gKP3vkkKdK2rdawakatl7Pn8wugMVlddfPPtVoztFh8rc/OdA7lADyADWgqA== 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=gt9FML4BvPljKe8LmT7vBY3GhnKo58zxY3NZZD4vJkw=; b=h4U/Ds9k4jU22p72+WPatC0BP0g0EQ86nmCYzl8i4cBeCJ1CSm4Nc6PliXT67GyqN8QWfAFLb2HkXx9QWNUGnBTqsGMfuak2TF/GX5FIKa1NcI7wO/GJSFvcpA8Q34to9v4fFxkUFqpakpy+dA4y6Q6ExNSYQk4AW3dNiKhOR6E/Xooq6y2M3J9oZR1K+9Iyc2jfeE5oOqE4kH4UF1ePq3rMgXeXSck0C9Bah9BVwYOdpazrcIGIK5+K4JDrmhTZkKgXd6XrKWveBOPajfd3/UHEjBPfE8NCT/QX8hzWdQxRZD/l8fcCtONYiI2zewxhMbB5Qt9d/b3mO1IvHBVBWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=gt9FML4BvPljKe8LmT7vBY3GhnKo58zxY3NZZD4vJkw=; b=JBO0tt0Ls9wnGBFx5uGnfL/ETVqPnq3eS/BicOxqZbW3oOAXXI0i6P5ihy955TF16TFgYaCWVkQDYHd3u65rrICY0iUcri2fU/0YBj/KV0jvEaH4kt+VjxupZKP3FeXfj23ueahnVw+xhvbdQ+FxJ1E7mCjoLBLIenFJTT/pdK3i0RLKe/byRt35mKUQFhH+lpkl6eg25I600f9Y4V2QmEj2qtFemmAjdwreg9k12QvsQSlMLLApqXMTf5n345c6lhMz3AV8dH8EAsVnYbVgSSrhHBs9v6/Qy8Q6S5P0dD/exmFR4RRYyfj+8b7VXaQrUzRcTS060Y1V3cTBAHZuwA== Received: from MW4PR03CA0209.namprd03.prod.outlook.com (2603:10b6:303:b8::34) by CH0PR12MB5027.namprd12.prod.outlook.com (2603:10b6:610:e2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 4 Feb 2022 02:00:17 +0000 Received: from CO1NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::d) by MW4PR03CA0209.outlook.office365.com (2603:10b6:303:b8::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.14 via Frontend Transport; Fri, 4 Feb 2022 02:00:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by CO1NAM11FT029.mail.protection.outlook.com (10.13.174.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Fri, 4 Feb 2022 02:00:17 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 4 Feb 2022 02:00:12 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 3 Feb 2022 18:00:12 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Thu, 3 Feb 2022 18:00:12 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard Subject: [PATCH v4 1/5] mm: Fix invalid page pointer returned with FOLL_PIN gups Date: Thu, 3 Feb 2022 18:00:06 -0800 Message-ID: <20220204020010.68930-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220204020010.68930-1-jhubbard@nvidia.com> References: <20220204020010.68930-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4df8db0e-5082-4d73-6c2b-08d9e7821765 X-MS-TrafficTypeDiagnostic: CH0PR12MB5027:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:264; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l4EP6O26CM7HfDvyDQpMZw1da0aJSenmzqLv2EQYBQbSAg4SBgDZ6fdidmaSJ8KyvojrZGmx1/d+5eX29ehRCOAJRnYtCLtDe0RzGqTdFIs0Ja8qvHeyMG9MAHOZLNzSwzHQSAiqRsragbFmNXS25fMz812IwFt6Hs9Lxya7BEHXvqaxW3k41jeYNCilF7m6VzdBP+YH0vr2oSwzFQ8hMt7/r4wyMMZiCWEwJzlW6P0zPuwSXWeO9581pSXr2akOI3u+ZM46iVy1q6ydDRzMadshau7AcZRgP5ZYgP0Iawv8uHrBZ8HPmaVj3O6eaPv4N2i8NWm8WSMUokSr9YFwbCZVucTxdl3k4JC2cU88emwpB9hXSqUMAiZJxyl/ivb/JhQQYxbWBfjUrQqIp36GvJ+KKKWo7axHsC0AvjnPVi58CZOvx8y7LaFJYeXN40HZPKsY6mrcGX3elfY1ZsEs1MCgqt4kpdgdVN4e81pTBdpG6E/rGEULkPnUV8Kuh0Hx6I+JWFFYMfF6xjSi7pHSLPyxbI18K+8JKrl03vj8f7L37b1ceyCzYSIA0s4hmiSigouUql/PV6z5G8jhXkXHBVMmdtO5w27jnfiBA7HUCUYn/eHyfc/FhBPW40a0KoqgNTd2LV4pBAB5jsHWDeQt8f1aFnVnkapYxK95PQv2XobfLrkuysGYgiL3KbYz9CHJlDQC3uKZZN7INlbcaXCX2w== X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(508600001)(81166007)(5660300002)(356005)(6666004)(86362001)(82310400004)(2906002)(8936002)(4326008)(47076005)(40460700003)(110136005)(54906003)(336012)(426003)(83380400001)(186003)(26005)(1076003)(70206006)(8676002)(70586007)(36860700001)(107886003)(316002)(7416002)(2616005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2022 02:00:17.2829 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4df8db0e-5082-4d73-6c2b-08d9e7821765 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5027 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=JBO0tt0L; spf=none (imf22.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.100.82) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com X-Rspam-User: nil X-Rspamd-Queue-Id: F0842C0004 X-Stat-Signature: pzn3rt17nab7yg94359m9jn98xw9pfh1 X-Rspamd-Server: rspam12 X-HE-Tag: 1643940019-121253 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: From: Peter Xu Alex reported invalid page pointer returned with pin_user_pages_remote() from vfio after upstream commit 4b6c33b32296 ("vfio/type1: Prepare for batched pinning with struct vfio_batch"). It turns out that it's not the fault of the vfio commit; however after vfio switches to a full page buffer to store the page pointers it starts to expose the problem easier. The problem is for VM_PFNMAP vmas we should normally fail with an -EFAULT then vfio will carry on to handle the MMIO regions. However when the bug triggered, follow_page_mask() returned -EEXIST for such a page, which will jump over the current page, leaving that entry in **pages untouched. However the caller is not aware of it, hence the caller will reference the page as usual even if the pointer data can be anything. We had that -EEXIST logic since commit 1027e4436b6a ("mm: make GUP handle pfn mapping unless FOLL_GET is requested") which seems very reasonable. It could be that when we reworked GUP with FOLL_PIN we could have overlooked that special path in commit 3faa52c03f44 ("mm/gup: track FOLL_PIN pages"), even if that commit rightfully touched up follow_devmap_pud() on checking FOLL_PIN when it needs to return an -EEXIST. Attaching the Fixes to the FOLL_PIN rework commit, as it happened later than 1027e4436b6a. Cc: Andrea Arcangeli Cc: Andrew Morton Cc: Jan Kara Cc: Kirill A. Shutemov Fixes: 3faa52c03f44 ("mm/gup: track FOLL_PIN pages") Reviewed-by: Claudio Imbrenda Reported-by: Alex Williamson Debugged-by: Alex Williamson Tested-by: Alex Williamson Signed-off-by: Peter Xu [jhubbard: added some tags, removed a reference to an out of tree module.] Signed-off-by: John Hubbard Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara --- mm/gup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/gup.c b/mm/gup.c index a9d4d724aef7..80229ecf0114 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -465,7 +465,7 @@ static int follow_pfn_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, unsigned int flags) { /* No page to get reference */ - if (flags & FOLL_GET) + if (flags & (FOLL_GET | FOLL_PIN)) return -EFAULT; if (flags & FOLL_TOUCH) { From patchwork Fri Feb 4 02:00:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12734753 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 C4D0BC433EF for ; Fri, 4 Feb 2022 02:01:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5CB086B0080; Thu, 3 Feb 2022 21:01:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 579B16B0081; Thu, 3 Feb 2022 21:01:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419DE6B0082; Thu, 3 Feb 2022 21:01:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0114.hostedemail.com [216.40.44.114]) by kanga.kvack.org (Postfix) with ESMTP id 2BE596B0080 for ; Thu, 3 Feb 2022 21:01:27 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E79658248076 for ; Fri, 4 Feb 2022 02:01:26 +0000 (UTC) X-FDA: 79103445372.09.5C84194 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2065.outbound.protection.outlook.com [40.107.237.65]) by imf17.hostedemail.com (Postfix) with ESMTP id 87AA040002 for ; Fri, 4 Feb 2022 02:01:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iWyoYJkXKgASKv/txtylxCKQQ+LcGHTW5DEMI5okLLzyUB8owAQNCYlQQQsvlmqlLc/qAMweCCxQhRuMutQK5lpcttsaO0Xmp6hmNpSx0N3atGJw+icq7xlA+EPgEjila00xJcAd1nRwEm6l8CZpS+Vfyk8c61+N5laqg0zwjg39h66Gy1TfJ8A9D4JUVY+MndrN5tklyM+uDf3ezwYYe+aI5VkmtrgPVKnPShXHOnqn3FYrmP2bMJxmFOuDhrtjGfNrd+GZCKSt5fk9u6rkk4XTkbr4DofedKLSeILVOW9PumskJwfAnun8K/G7gDE1Q7v0hqnYJoTtU5bjjWouBQ== 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=rIFxx0JMJhZKbtCOo0EVoclEbiVY2wSwOwxE/BalMcs=; b=KXd7CIRel15FfNKV42gYY8RGKzpEZ3xILjhhoCH3Nzwe0Liw/FpXWIkN/Kq1oUnrkehuaTWr1HljqwCOotHhhPoC0j94tQx+F6RdkFNcnDNqjRZlml8erhu43TTreiFnmgk3F8gyyCTU0wOL9x/mJTTQLUin4odiNUfadz8I+ywQPIc2EiBCEPFKEYAYp5+Rfd3jBvnsR4WMZdDMlNSOKavq3KvDjMlxiAqKSGyAyD+84C9hYBo7JeApQwo0+DY3VakMdqO5S2yQEBGzXBqJrIyJiGrf4X+iLGZmEXGfPlzoKMSfPC8XtflEB+hnN3jIzV0vruBhq1fomTDn7dERJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=rIFxx0JMJhZKbtCOo0EVoclEbiVY2wSwOwxE/BalMcs=; b=Eblf77GwdLcZch+QlVHC2E1wet+UcKAofl5u55m3/9vDE/ruYGOsV7L0GYRGZfZ8WbdImI5TsS2C+guC21cBzbLisENHPaj71rTnvgfyEoiiP8Yo/rsOGQepFCmNwUYrXagVpasg0SG8SD8763j6kLFXBvgUxuFSzGRxN1bmKkfLPetexbPb+aRsinckl4+bPVoo7oTort6jx96LCTjdaQFEq9osFy0wcTxGUb6drn+7TKSUyKSGYzi+QAADjNfpdjAKq0Cc3FtmmF0JwFUMwbX5uuzfWPhP6UNs+cCQ6lprZsgHIv/nw4Xghrwa7Lz/bz9aXjqM2ODbbXXqgmU7Vw== Received: from BN6PR1701CA0020.namprd17.prod.outlook.com (2603:10b6:405:15::30) by MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 4 Feb 2022 02:01:24 +0000 Received: from BN8NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:405:15:cafe::58) by BN6PR1701CA0020.outlook.office365.com (2603:10b6:405:15::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.16 via Frontend Transport; Fri, 4 Feb 2022 02:01:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by BN8NAM11FT019.mail.protection.outlook.com (10.13.176.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Fri, 4 Feb 2022 02:01:23 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 4 Feb 2022 02:00:13 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 3 Feb 2022 18:00:13 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Thu, 3 Feb 2022 18:00:12 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard , Jason Gunthorpe Subject: [PATCH v4 2/5] mm/gup: follow_pfn_pte(): -EEXIST cleanup Date: Thu, 3 Feb 2022 18:00:07 -0800 Message-ID: <20220204020010.68930-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220204020010.68930-1-jhubbard@nvidia.com> References: <20220204020010.68930-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66af168e-d2fe-4384-e675-08d9e7823f1b X-MS-TrafficTypeDiagnostic: MN2PR12MB4192:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K8C44WVBcECKpASMQ8dXOfaEKaqpgF6cAYPbukUQLaudfCiadIOK9WG9JDJaiOWjd3x5MarJWi4CRXfSaTjG8zO4OpNaDj8/k+Xt7vFLBKwZf6xLbwAVhUKrwkjEA52r9krw1vyM3byYp4clBy5kx0q55VV2hWAMMtovL9LEPdlry3mrM3pnOlXkXkoecHAGMBJNbEZj8kR6LDSKfa7mPfGgYTsusSVJzVOUzbojr8tx+AjY6iJih+sbmqC+M4Tis4DVCFZT31s/YThGhh+/6CzT79WSXU8c7wlEhRnvdfwPbk+mdS8Jg+jkq/PDYJC0BdBHDcBT7m8I5BgN+NKp6KTURB6MWiJsCRhVYD0/Itq1X3uEu/rR97hw6AaLRUAiH8XhsNH9ubZiEr2Zqp3TKNCV57Gr2U86MjXhzGJ4oVaXF6r4DtZWYBX4nRf/el4B8T2+OEFZB69wgFBbmK3t0hLRPrng43oN6rKLmYVY7IBoFoYRTZbUKAOu70AVoSB30rIPeU5s5JO5+vH/qJ8jODM/wKD9nG+XQZQCp00FvoUieF3blsH3NS1Sp/gh8orBuEk1ivW4bbSH0GpT+cKYzJbqyzxJJnZDFMaTIfclLAitglCG0/UsGv51PU0rZOrPeHRzpT+Kc9gXWBP0vEYXJ4ONAZUt2ftJYYBrYNgTdl/1jsa4ZEhuaP3vs15uTqSvd7RHiVsH66FVVQKlcOFjug== X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(7416002)(40460700003)(47076005)(107886003)(316002)(6666004)(5660300002)(1076003)(186003)(426003)(2616005)(26005)(356005)(81166007)(110136005)(54906003)(336012)(8676002)(36860700001)(82310400004)(8936002)(70206006)(83380400001)(36756003)(2906002)(70586007)(508600001)(86362001)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2022 02:01:23.8475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66af168e-d2fe-4384-e675-08d9e7823f1b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4192 X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 87AA040002 X-Stat-Signature: uxfosfdjpxeh1qz493wdmbupjqonfb18 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=Eblf77Gw; dmarc=pass (policy=reject) header.from=nvidia.com; spf=none (imf17.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.237.65) smtp.mailfrom=jhubbard@nvidia.com X-HE-Tag: 1643940086-426150 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: Remove a quirky special case from follow_pfn_pte(), and adjust its callers to match. Caller changes include: __get_user_pages(): Regardless of any FOLL_* flags, get_user_pages() and its variants should handle PFN-only entries by stopping early, if the caller expected **pages to be filled in. This makes for a more reliable API, as compared to the previous approach of skipping over such entries (and thus leaving them silently unwritten). move_pages(): squash the -EEXIST error return from follow_page() into -EFAULT, because -EFAULT is listed in the man page, whereas -EEXIST is not. Cc: Peter Xu Cc: Lukas Bulwahn Cc: Jan Kara Cc: Matthew Wilcox Cc: Claudio Imbrenda Suggested-by: Jason Gunthorpe Signed-off-by: John Hubbard Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara --- mm/gup.c | 13 ++++++++----- mm/migrate.c | 7 +++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 80229ecf0114..2df0d0103c43 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -464,10 +464,6 @@ static struct page *no_page_table(struct vm_area_struct *vma, static int follow_pfn_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, unsigned int flags) { - /* No page to get reference */ - if (flags & (FOLL_GET | FOLL_PIN)) - return -EFAULT; - if (flags & FOLL_TOUCH) { pte_t entry = *pte; @@ -1205,8 +1201,15 @@ static long __get_user_pages(struct mm_struct *mm, } else if (PTR_ERR(page) == -EEXIST) { /* * Proper page table entry exists, but no corresponding - * struct page. + * struct page. If the caller expects **pages to be + * filled in, bail out now, because that can't be done + * for this page. */ + if (pages) { + ret = PTR_ERR(page); + goto out; + } + goto next_page; } else if (IS_ERR(page)) { ret = PTR_ERR(page); diff --git a/mm/migrate.c b/mm/migrate.c index c7da064b4781..be0d5ae36dc1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1761,6 +1761,13 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, continue; } + /* + * The move_pages() man page does not have an -EEXIST choice, so + * use -EFAULT instead. + */ + if (err == -EEXIST) + err = -EFAULT; + /* * If the page is already on the target node (!err), store the * node, otherwise, store the err. From patchwork Fri Feb 4 02:00:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12734751 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 57E1EC433F5 for ; Fri, 4 Feb 2022 02:01:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E8B46B007B; Thu, 3 Feb 2022 21:01:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 973A56B007D; Thu, 3 Feb 2022 21:01:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 63D1C6B007E; Thu, 3 Feb 2022 21:01:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 54D676B007B for ; Thu, 3 Feb 2022 21:01:19 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2666420ED5 for ; Fri, 4 Feb 2022 02:01:19 +0000 (UTC) X-FDA: 79103445078.02.BD51C11 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2063.outbound.protection.outlook.com [40.107.101.63]) by imf06.hostedemail.com (Postfix) with ESMTP id 5C46E180008 for ; Fri, 4 Feb 2022 02:01:18 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A7e3aLjCYZz1sM6w7n5rkLUhV/F3NVZ7sEPFVIKZI4tPBAKsNBLuRnCF7P+EVX4pZFMENNPilMuBjZM93aQi7DyKBlc9ZWgVIHVcnhd7J0bGIYryPTeEaDtrrBgh4xXST7sBXj/z3T5pj+sH3Vbuh2PAvhDGwr/jwN4/u2sdBkYLllyg2OyibsLXi+uFcy2BDyBtynv36/sDjQoWe45cxsoOZYebHSX0pzOysgN35xIG5MAFl++dEwHhoft/nQGr0Q5qdCl8Qe00tLO4+7AdjjZ1C/+wjZpEXe7U+8Act3AIUuizrpiw+bfbJxNWpuC/tMJKLNp0jWlhrTP6eCakhw== 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=VqmeqmDK9WNONzndgAGAbct149ZFM+Hb4kqc64wfHqs=; b=FTtOevJf0mjsrHl07iJzTP6+cw310bhLL33//UyXpOvfKSFWrknePPxfbUqt7rM963RLHQlkN1YTKXussOpJqRibFZtw63IKtrRmHYk9tCJBblClaBYg9mfEUGV1VUuvSv86r+dq3DHSpA/BpKe78zx92J0Fyio4QQgbL7TAs+lwQH0PCnTyTCOK8EVzhVj+b4xujMeWhED32YGoBWQafkWJVAiH+dTYzCxEeA+fSRlCWbE54GOvQBywfgD5Pkzd3ztJlBmd1/zIfFwwbzI2Te8bzO1OMgnXnFQwe8dlk4+r60NCYf1ofW1/4rm4df6jIo94uA2FqEx6bmVTN7M7jA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=VqmeqmDK9WNONzndgAGAbct149ZFM+Hb4kqc64wfHqs=; b=FEC0DWBUEaDQ4ETWMVC+5IP52b91ni3TEWDir3PX9qqr3YwuGMd58gkl24pY91fukPEf5gVp+zCvuudsP1PZyEGQmsiXF2RlPaLM6mrYNu7w6u9AOEKDQKaQ68eArVQwEOaA88Ehk4JtHmEucs5ngBGyZMFKDWhahmtfDwojKvmsHxDD1Jp4ME5YRr2vgwtpkraacfzZrHUPA3GnaWpBNUEBGOVOInshRbxp2pyfmCVU6EwCIUd7r5KKpmnT3z6sVm8csz0jwjOWobRr6egPKnBLmZ0qrdWXZh3FDSII/P3RwLx5ldSG1sBNE9Z/3IUoJsrjdTdf49FOAgfCHD0wZw== Received: from DM6PR11CA0016.namprd11.prod.outlook.com (2603:10b6:5:190::29) by DM6PR12MB5533.namprd12.prod.outlook.com (2603:10b6:5:1bc::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 4 Feb 2022 02:01:15 +0000 Received: from DM6NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:5:190:cafe::a6) by DM6PR11CA0016.outlook.office365.com (2603:10b6:5:190::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.11 via Frontend Transport; Fri, 4 Feb 2022 02:01:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT057.mail.protection.outlook.com (10.13.172.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Fri, 4 Feb 2022 02:01:14 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 4 Feb 2022 02:00:14 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 3 Feb 2022 18:00:13 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Thu, 3 Feb 2022 18:00:13 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard , Jason Gunthorpe , Christoph Hellwig Subject: [PATCH v4 3/5] mm/gup: remove unused pin_user_pages_locked() Date: Thu, 3 Feb 2022 18:00:08 -0800 Message-ID: <20220204020010.68930-4-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220204020010.68930-1-jhubbard@nvidia.com> References: <20220204020010.68930-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2bb76ccd-d28c-4df6-32fc-08d9e78239b5 X-MS-TrafficTypeDiagnostic: DM6PR12MB5533:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:972; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lXDOabUPRlexvCwUphlvhxd/3X3Xp2/mgMR8M7scX/FVAP41rfVVbrrTKU6hLkns7yTGR/JfXuxehgP0ma4DtwaInYxcmSboWWHI1HXi21MjCD1CSWWciGZgps4DuBzOt+2cJ48dOA2FwpiG1nkkamhK+MIKLOUkpGckhXKDpLD7kfUEP3FaejXye20v+gANtjEwP5RqmUi7U98zI8N7MPiLOxC/qjaCX1tY5RPngjn1p4q2ySdYxt4eJdaxaJhPCaYD9ypqhvD632e7JeUD4zT0mb7M/nZks5D0UlCaS0zS8HXPhyeEql5gO4U+KZ/8tbNrtrqekxRNUnxCIRm2SHsvqeREHIGiTC738S5dDFNCVywpt8SCeF4a6YWiSfTC0SgxU/ERhDxK+9zstP1HrPd4V4slaf+un5wUoy+jRc7drwJSba1CZEeZoJ48HjIBl8T1IeIHnqE6+9QC5LzoUUopJ3WNC2yYHTOE5k6M3PpjCRbXcHl9T/GU8bvS+z7i34sxeyNafZ7Cj5JeIxfdutCYQdQZrgGPsZAPsE5lsKwv89KQCXJSR1J768ie/sYct1B38SvX+Aij0Xy5Vglp0Hv6glO7VYozgs2/fdKtVRwy8yuxggVyIzLWaoBn0R8z6kQf53KABLuHsU3invTXa3HuDbS6c66CBOOadqe2dJ2Ge4AEWSFkmAuQsBu6zRLtigWs1WOsJhs2NIwVAwhuOg== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(8936002)(316002)(54906003)(110136005)(83380400001)(8676002)(2616005)(70586007)(7416002)(70206006)(4326008)(508600001)(2906002)(36756003)(5660300002)(6666004)(1076003)(186003)(26005)(47076005)(81166007)(356005)(86362001)(82310400004)(40460700003)(426003)(36860700001)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2022 02:01:14.8327 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bb76ccd-d28c-4df6-32fc-08d9e78239b5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5533 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5C46E180008 X-Rspam-User: nil Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=FEC0DWBU; dmarc=pass (policy=reject) header.from=nvidia.com; spf=none (imf06.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.101.63) smtp.mailfrom=jhubbard@nvidia.com X-Stat-Signature: 1mbyqb6b4fqkhtnmcbiwgknpyynbtxpp X-HE-Tag: 1643940078-301736 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: This routine was used for a short while, but then the calling code was refactored and the only caller was removed. Reviewed-by: David Hildenbrand Reviewed-by: Jason Gunthorpe Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig Reviewed-by: Claudio Imbrenda Signed-off-by: John Hubbard --- include/linux/mm.h | 2 -- mm/gup.c | 29 ----------------------------- 2 files changed, 31 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 213cc569b192..80c540c17d83 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1918,8 +1918,6 @@ long pin_user_pages(unsigned long start, unsigned long nr_pages, struct vm_area_struct **vmas); long get_user_pages_locked(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages, int *locked); -long pin_user_pages_locked(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, int *locked); long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, struct page **pages, unsigned int gup_flags); long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, diff --git a/mm/gup.c b/mm/gup.c index 2df0d0103c43..6664dfa7a38f 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3146,32 +3146,3 @@ long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, return get_user_pages_unlocked(start, nr_pages, pages, gup_flags); } EXPORT_SYMBOL(pin_user_pages_unlocked); - -/* - * pin_user_pages_locked() is the FOLL_PIN variant of get_user_pages_locked(). - * Behavior is the same, except that this one sets FOLL_PIN and rejects - * FOLL_GET. - */ -long pin_user_pages_locked(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - int *locked) -{ - /* - * FIXME: Current FOLL_LONGTERM behavior is incompatible with - * FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on - * vmas. As there are no users of this flag in this call we simply - * disallow this option for now. - */ - if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) - return -EINVAL; - - /* FOLL_GET and FOLL_PIN are mutually exclusive. */ - if (WARN_ON_ONCE(gup_flags & FOLL_GET)) - return -EINVAL; - - gup_flags |= FOLL_PIN; - return __get_user_pages_locked(current->mm, start, nr_pages, - pages, NULL, locked, - gup_flags | FOLL_TOUCH); -} -EXPORT_SYMBOL(pin_user_pages_locked); From patchwork Fri Feb 4 02:00:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12734750 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 7410DC433EF for ; Fri, 4 Feb 2022 02:01:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D924F6B0078; Thu, 3 Feb 2022 21:01:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D424D6B007B; Thu, 3 Feb 2022 21:01:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B949E6B007D; Thu, 3 Feb 2022 21:01:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id A6F106B0078 for ; Thu, 3 Feb 2022 21:01:18 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7318520DA8 for ; Fri, 4 Feb 2022 02:01:18 +0000 (UTC) X-FDA: 79103445036.02.74730FF Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2088.outbound.protection.outlook.com [40.107.220.88]) by imf06.hostedemail.com (Postfix) with ESMTP id C5C44180004 for ; Fri, 4 Feb 2022 02:01:17 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kFE/+/kQWU7Sv9aO4fUJx2kpywL3OQBQD4UGd92Oxmj+tWgKEkrckLLCsuVrDPXmR4kPphxZpvHl77G6zlgJKCrGqPPn5+4Cs9cvb87yr+6rxRjf9WuoIk/J5zE/UJRqyu4yfsuaT6UP1i+p2KcGKrpafH6vGNcf32wRaubWdCd1YRKs0+o2J9tUDKdE1GE3wwoy1sZ8sq+8YVAHRtcbHZdeObuP7zvpgnA7+Le+d2y8qWkkFlohWAdlODYkdxCppdq+wvlFbweVtdFeGntqxTZ9iyZruMbaF4e6B4Fj3+53hQ3Nt4nm3itvESOwxyOev8Epb4Lr2ZKCjOOFMj4CLg== 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=XKpptENJJnJtIzFcPNilhjqWWC4uFRvZ0zxpZOikQbE=; b=C7ev3/iIuXTkxLg805T28lx9ILVkcBbeJZ/XglNBTkNqpxWObj5qmoxZBGdJJ0R8cU/1L56wqSw6vCIZY9wt0ycmTQdB/ylufuwAAzUfWikU91Tw1gDIpZj2rSYnGtic7Qu1JJ/T02TXRDVavgeqxW3lBEIJYDKR9RLyt8PYWJJpeWuLrItOmDz8H4GG7i2bnYqM+FYcAu9ahg0bd0j/gt9nnv+7RK/FFEwOnBlxsxK9KiZFPVR6Ca0aSV7yq041khbiFf0RQs/qj4nLsl+2k8t0+RA262lIxf9eIf9Yd0+rFrvCw4+ZZFt2RhmIPNq6DOFrz8RBrsiGWZ3gG5+GGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=XKpptENJJnJtIzFcPNilhjqWWC4uFRvZ0zxpZOikQbE=; b=Avou752TaBy/Hl6b7bcNLDlfyCfRHqdR7w4A6AIbQZRCazBziYv5bkA/F0zFrSmV/iMdpyl/KWXtdhtIMW12NMBYIoMPkRYb/MVIehIl+m4mQfhJDk1OVOZMcKn9p1bmvkguh8gTQ0A87AeM6mYZIfcVQEcwLaP0GApVaSkSXQkOPjJKkkO+8lhvxJQOmvi70gs+ftTlpB5TjeDsB2xoE4B63gwN0CsdrTnZIVF/Oty9NbkQIrtxSrw2nEvyS+dtY2bn5Gl+GSFoX6lLF4voA0dzzaWQsJinGZ6R6gYgCZgslgkW3Ws8GU9xGbmLFNI+OzxDpgFzZG4siLO1P5DMPg== Received: from DM6PR11CA0015.namprd11.prod.outlook.com (2603:10b6:5:190::28) by MW3PR12MB4442.namprd12.prod.outlook.com (2603:10b6:303:55::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 4 Feb 2022 02:01:15 +0000 Received: from DM6NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:5:190:cafe::88) by DM6PR11CA0015.outlook.office365.com (2603:10b6:5:190::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Fri, 4 Feb 2022 02:01:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT057.mail.protection.outlook.com (10.13.172.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Fri, 4 Feb 2022 02:01:15 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 4 Feb 2022 02:00:15 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 3 Feb 2022 18:00:14 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Thu, 3 Feb 2022 18:00:14 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard , Jason Gunthorpe Subject: [PATCH v4 4/5] mm: change lookup_node() to use get_user_pages_fast() Date: Thu, 3 Feb 2022 18:00:09 -0800 Message-ID: <20220204020010.68930-5-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220204020010.68930-1-jhubbard@nvidia.com> References: <20220204020010.68930-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 560ebe94-484b-4f80-561d-08d9e78239fa X-MS-TrafficTypeDiagnostic: MW3PR12MB4442:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nTXrCmqsT2/uAw2xCghVLP9a6axNYiT7cTBe4dMsFcrwlWbMNq2LbiOrnUi3W/zzRKcGoOhk/PfiDnMr6EFz0h1fyJNY5XPPIcTvY7QRLUexKkYo/g59+zr38wdNJjWzIkQaYxFnebVEQUlNnhJgoa5WznZ2rbQK+04GrDRA36cbgZPmjoJh+zKSUSxNlsna/Z8mpIBK6EV398QlVMkc00i58uvZfsomFmad/EqdyF4SlQiS1ZOA9f95yvPEiDzfuj6Ek0AcewbEtUNc0oc9TWF8achm2zU4DwqIsAtcm3xA3baE/4LH/HLQW5IEuPq8NS71k7FfMliyxoFQBcTjnCfVVW4U0Pp2FO7pEkGaslU6iXBIYmS8rrDU11WXT33NatC0ck1r2hmUP/OSNbAp7jcQxP/vQmrhIeGaglsReVg1x5iXk9Dc2koKSAjv13d+FCCyVrUr3Fy4WBFPgBzsJC2SvMZ6kFKXdV6smFTupJAXJoD0xIpwcBxJJmE8cowOALprMawXLWVPYzSAjleapXaFgrIfRHsChmx8SqWEev8/txFiZwLn6X82ENcntl8cIFBVpVSIMp87rXY4EjSLhyGZ6quHQ32iSXWCmUSqVAheOEhgGD3RNHFUFLQVVIr1TSVdFvqtCXXZgk0GPOvcwVihgYvXkCJCPnUyeb7vUm9iFjKkSfxU49/XOTGzpOZLj3NQzGUVyAs68tl99yUXIg== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(83380400001)(336012)(426003)(1076003)(26005)(70206006)(70586007)(186003)(40460700003)(110136005)(8676002)(4326008)(54906003)(47076005)(2616005)(8936002)(36756003)(316002)(36860700001)(107886003)(7416002)(356005)(508600001)(5660300002)(81166007)(2906002)(82310400004)(86362001)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2022 02:01:15.2857 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 560ebe94-484b-4f80-561d-08d9e78239fa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4442 X-Stat-Signature: qhfnkhe3o1q881fme11hzmnrqb9bzma8 X-Rspam-User: nil Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=Avou752T; spf=none (imf06.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.220.88) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C5C44180004 X-HE-Tag: 1643940077-328967 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: The purpose of calling get_user_pages_locked() from lookup_node() was to allow for unlocking the mmap_lock when reading a page from the disk during a page fault (hidden behind VM_FAULT_RETRY). The idea was to reduce contention on the heavily-used mmap_lock. (Thanks to Jan Kara for clearly pointing that out, and in fact I've used some of his wording here.) However, it is unlikely for lookup_node() to take a page fault. With that in mind, change over to calling get_user_pages_fast(). This simplifies the code, runs a little faster in the expected case, and allows removing get_user_pages_locked() entirely, in a subsequent patch. Cc: Christoph Hellwig Reviewed-by: Jan Kara Reviewed-by: Jason Gunthorpe Reviewed-by: Claudio Imbrenda Signed-off-by: John Hubbard Reviewed-by: Christoph Hellwig --- mm/mempolicy.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 028e8dd82b44..3f8dc58da3e8 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -907,17 +907,14 @@ static void get_policy_nodemask(struct mempolicy *p, nodemask_t *nodes) static int lookup_node(struct mm_struct *mm, unsigned long addr) { struct page *p = NULL; - int err; + int ret; - int locked = 1; - err = get_user_pages_locked(addr & PAGE_MASK, 1, 0, &p, &locked); - if (err > 0) { - err = page_to_nid(p); + ret = get_user_pages_fast(addr & PAGE_MASK, 1, 0, &p); + if (ret > 0) { + ret = page_to_nid(p); put_page(p); } - if (locked) - mmap_read_unlock(mm); - return err; + return ret; } /* Retrieve NUMA policy */ @@ -968,14 +965,14 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask, if (flags & MPOL_F_NODE) { if (flags & MPOL_F_ADDR) { /* - * Take a refcount on the mpol, lookup_node() - * will drop the mmap_lock, so after calling - * lookup_node() only "pol" remains valid, "vma" - * is stale. + * Take a refcount on the mpol, because we are about to + * drop the mmap_lock, after which only "pol" remains + * valid, "vma" is stale. */ pol_refcount = pol; vma = NULL; mpol_get(pol); + mmap_read_unlock(mm); err = lookup_node(mm, addr); if (err < 0) goto out; From patchwork Fri Feb 4 02:00:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12734748 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 249A0C433F5 for ; Fri, 4 Feb 2022 02:00:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B6116B0072; Thu, 3 Feb 2022 21:00:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6650C6B0073; Thu, 3 Feb 2022 21:00:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B91B6B0074; Thu, 3 Feb 2022 21:00:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 39B666B0072 for ; Thu, 3 Feb 2022 21:00:20 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E6E9B8248076 for ; Fri, 4 Feb 2022 02:00:19 +0000 (UTC) X-FDA: 79103442558.13.3FE664E Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2073.outbound.protection.outlook.com [40.107.92.73]) by imf16.hostedemail.com (Postfix) with ESMTP id 4BB9C180005 for ; Fri, 4 Feb 2022 02:00:19 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WKynv1996B8ZGO1jjheDhCHexBKthfQfca0P8f/Vs+lHUk98RTVs/Otb9bvYgXDDnKz33Vq6Rkzj7V5n3CkiOoB8D5JRQ4rAri7w18LCQS6oR2cQmmc3Lp6TQOVzuxrbHIZPi1ddaCVL0s4qya41H4B+qzmvqap4Tphm+PzNAUyJNI8B+8dfVtwUxqE10oAqjlKP9Yp+G8Ao9eFrSqQduyhzbfnKnUVtjqYdXa8Dh3yEZ0fX5vEcUTzyYigvB7MJzbaNnzF0Et9WukXvHSeknrXVigOFsetWS6YudllHzLuLt+FU0PyK+dUia5UIuc+zeoMtn7lqgeNGtFB1NqG9AA== 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=Sjp5WIXah4qEy4VPRd2JPXIcOGxf/jEUN8Mk8w5H/TQ=; b=dS8Hlekmr3DJKRu4b+0jShOPWBfdhRNViUB7sA6rncM6A707mnBKaVEclR2+gaO8deneP6uSYOkSXxMhEBCtuWat5xUcrFQWWsSWRMg7Uo61bZDiMXgxbmM7mYEyw+93MoxAgprCPyAKfxxQwSwScaNaj9UMR/kTMcRghrln3GoSnQN9dRWwB3jG9nWds0mj+VtYhHtzyOUGTKnmlpLFGuUsxmDI97w+KZgVVBJghWynwDdWP2e5/4WdZ7272/jVn9CEMb/GQn7k4y3VwJawNWk0qf6xORrOJlxZFubsA9NVu8YxR8vD/wzQn3xsqKtJnJSdiEU+4C2isvo/6WEkEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=Sjp5WIXah4qEy4VPRd2JPXIcOGxf/jEUN8Mk8w5H/TQ=; b=IpUiPSRIxcDbUDIF3Y/AplxldU0zmKksYU4u8bxoOyti2TC0XkE0amYtupEils8AKRv9tC8xes7m1g9G+w4CS6x0SeZxgD7Ir8G7PaekKF3T7eTBJFyjTfKYXoNlyaR4jXR7kLXnDvJIpXFFQlXvDkGbTL+HYREBSSHx9YNE3yx3TfS4nH1kyuBfHIutRC9a96ILc6LIaJ4y5T9Ar8kTkvXbUe2QoOo+OSkqz6tE+Kce/Mdz/8HscntrMemQZwh0gIGd479WcOtZRfCXfRhRIzWBQNQKgBNhj9Lt66HcH4pU3L6H/zDae5AJnMWbh6cTPC2CfkX+uxRDTYa/eLoyoA== Received: from BN8PR15CA0040.namprd15.prod.outlook.com (2603:10b6:408:80::17) by BL1PR12MB5320.namprd12.prod.outlook.com (2603:10b6:208:314::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 4 Feb 2022 02:00:17 +0000 Received: from BN8NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:408:80:cafe::68) by BN8PR15CA0040.outlook.office365.com (2603:10b6:408:80::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.14 via Frontend Transport; Fri, 4 Feb 2022 02:00:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT032.mail.protection.outlook.com (10.13.177.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Fri, 4 Feb 2022 02:00:16 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 4 Feb 2022 02:00:16 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 3 Feb 2022 18:00:15 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Thu, 3 Feb 2022 18:00:15 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard , Jason Gunthorpe Subject: [PATCH v4 5/5] mm/gup: remove unused get_user_pages_locked() Date: Thu, 3 Feb 2022 18:00:10 -0800 Message-ID: <20220204020010.68930-6-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220204020010.68930-1-jhubbard@nvidia.com> References: <20220204020010.68930-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6115e15d-34c6-4185-ee38-08d9e7821744 X-MS-TrafficTypeDiagnostic: BL1PR12MB5320:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Ok1+ImFdUQJHLZFhblAeXRDmO/8uAEDdpqPr2BKYOVe7eIB4B9tOHVVyk82ZV0mcd5qdJWK9nY8BsMW76eoBy9QUgliyVsJ4+c6SJCh0CzAArtRjh3Mz7nBRmvbFVhOJ3zy/1TRsifYGBU6/XakZTZGLV+1LrC69qR2f9VJziie7B2v5qcmSSDuGIkMbdcb1s54RJswzZoz1mvbdsyXqgA8WBLZHvlUAY9MvGEqWT9LdOGq1o19yqdjWHxoCFVvMfDvKSlN4emha4pjywyioxfGsITTMmEnxe4TWh4VqQgX+RCog0tjHk1bY52OkoVx5zFg8UnvfsUFe3kagGluSsDS4XCX3kcESU+rsW8n5Bx106lvJeYPSsqZusKeL2e2rXcdrl6eD4U+g7OGPgbMswDpp9qxcpf8Sz3zu3JI+lL8CFCub/hWTV9ik1KLQSRRakJ2xU9MmNMLRHuWT2rsqcNzqa2+jjR2k6SHRYz/9pNV76XLq52PRwx68E3Xv3fO7LUpidEqFwQbw4DIyZOJ4xqZgHPU7PjoQ0oESzxqqjw9xCkWM3PoBEZRkYdkEZhd5dFcEAS51aytZa8uNG6wMAXZ1c2wAslLrVdh3aBCpwKq+0HU7B6qb3uwQ33YMve7HdJY15dZ0oaDGXbL2krZ2n8Ubszelzv+Rnb3Y7NHrV8P9TWZJuftKh9r1NQdIrYWVTvKLo7oyZZyD3SCOmWkdw== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(186003)(6666004)(316002)(26005)(70586007)(70206006)(4326008)(82310400004)(426003)(8676002)(508600001)(356005)(336012)(81166007)(2616005)(47076005)(83380400001)(54906003)(8936002)(2906002)(36860700001)(40460700003)(7416002)(5660300002)(110136005)(86362001)(107886003)(36756003)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2022 02:00:16.9919 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6115e15d-34c6-4185-ee38-08d9e7821744 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5320 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 4BB9C180005 X-Stat-Signature: u5nfmhmrofsrfwu7bbmq3ij9t8inogp9 X-Rspam-User: nil Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=IpUiPSRI; spf=none (imf16.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.92.73) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com X-HE-Tag: 1643940019-294955 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: Now that the last caller of get_user_pages_locked() is gone, remove it. Cc: Christoph Hellwig Reviewed-by: Jan Kara Reviewed-by: Jason Gunthorpe Reviewed-by: Claudio Imbrenda Signed-off-by: John Hubbard Reviewed-by: Christoph Hellwig --- include/linux/mm.h | 2 -- mm/gup.c | 59 ---------------------------------------------- 2 files changed, 61 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 80c540c17d83..528ef1cb4f3a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1916,8 +1916,6 @@ long get_user_pages(unsigned long start, unsigned long nr_pages, long pin_user_pages(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages, struct vm_area_struct **vmas); -long get_user_pages_locked(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, int *locked); long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, struct page **pages, unsigned int gup_flags); long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, diff --git a/mm/gup.c b/mm/gup.c index 6664dfa7a38f..7337520afa49 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2145,65 +2145,6 @@ long get_user_pages(unsigned long start, unsigned long nr_pages, } EXPORT_SYMBOL(get_user_pages); -/** - * get_user_pages_locked() - variant of get_user_pages() - * - * @start: starting user address - * @nr_pages: number of pages from start to pin - * @gup_flags: flags modifying lookup behaviour - * @pages: array that receives pointers to the pages pinned. - * Should be at least nr_pages long. Or NULL, if caller - * only intends to ensure the pages are faulted in. - * @locked: pointer to lock flag indicating whether lock is held and - * subsequently whether VM_FAULT_RETRY functionality can be - * utilised. Lock must initially be held. - * - * It is suitable to replace the form: - * - * mmap_read_lock(mm); - * do_something() - * get_user_pages(mm, ..., pages, NULL); - * mmap_read_unlock(mm); - * - * to: - * - * int locked = 1; - * mmap_read_lock(mm); - * do_something() - * get_user_pages_locked(mm, ..., pages, &locked); - * if (locked) - * mmap_read_unlock(mm); - * - * We can leverage the VM_FAULT_RETRY functionality in the page fault - * paths better by using either get_user_pages_locked() or - * get_user_pages_unlocked(). - * - */ -long get_user_pages_locked(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - int *locked) -{ - /* - * FIXME: Current FOLL_LONGTERM behavior is incompatible with - * FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on - * vmas. As there are no users of this flag in this call we simply - * disallow this option for now. - */ - if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) - return -EINVAL; - /* - * FOLL_PIN must only be set internally by the pin_user_pages*() APIs, - * never directly by the caller, so enforce that: - */ - if (WARN_ON_ONCE(gup_flags & FOLL_PIN)) - return -EINVAL; - - return __get_user_pages_locked(current->mm, start, nr_pages, - pages, NULL, locked, - gup_flags | FOLL_TOUCH); -} -EXPORT_SYMBOL(get_user_pages_locked); - /* * get_user_pages_unlocked() is suitable to replace the form: *