From patchwork Sat Jul 1 01:04:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13298851 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 BD8C7EB64DA for ; Sat, 1 Jul 2023 01:05:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E5D98E005F; Fri, 30 Jun 2023 21:05:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 96ED28E0059; Fri, 30 Jun 2023 21:05:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79A178E005F; Fri, 30 Jun 2023 21:05:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 632588E0059 for ; Fri, 30 Jun 2023 21:05:04 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1D0771C7FC0 for ; Sat, 1 Jul 2023 01:05:04 +0000 (UTC) X-FDA: 80961248928.25.45D9658 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2086.outbound.protection.outlook.com [40.107.101.86]) by imf25.hostedemail.com (Postfix) with ESMTP id E4F66A0004 for ; Sat, 1 Jul 2023 01:05:00 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=tF3q6G6L; spf=pass (imf25.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.101.86 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688173501; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=cbfo5kEsoA7YYwuAfhDv6dwtUZhjWTNomL86fymbh44=; b=tlxE1aeaB/kZEcyzurql5ahdjqS0PrjffPJblmBHspYlaevWbgUAXvIN+CmjGdZyH6mkzE E+UAf1xRKtm12Rt15PQVvubHEgjUP8lK5eO9Danl/1X2C7E7g0dPslvvQJ3Uke5aTE6nXJ 8Jrc3tDRVn/kJ27x2Jae6huKRDr927M= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1688173501; a=rsa-sha256; cv=pass; b=gXtY6W/XZAfZEA6xU9oqMTarcw3G+4N5pluhLF4G0iRt+StH2SaqmhWiV9S726Z/2yWpQZ h9lizfGF/W2kB8WPnrVJEJc2IzWI4w9tDdgvgPZWRDi9OQm7MNYVGdPUIkU4G9jNzvnE3K Wbla/xCUh2gSqi2QIbn/BI5rF15WzgI= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=tF3q6G6L; spf=pass (imf25.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.101.86 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dam9mLXEiFl8fNKALcBTmh781xGhj5tXdQD5PK+rw9GuVtB9Neldxp6BLROGPVQOCWU+XEKcv6+XCgm8P+w2F+C8BwdJvTnS2UDviVz79+oXcejd4EjMxUBsVmPsg9XQoGgilWsP+LUwilgi5lBBlbuiJdJ4jUjir0CO1OdOcoxiyXUNhKBDihTfR8v7D8hbbDKBzfOA+JHxQJbkVO+YegMLDG0YmsX+BB0nj22koNIAVnV0T3y/mVDqyQJv7Mx8YkkYHE1VSMahbDUquC/UEiKPViTPCdVZ7W8F3qJi5C7Sga2z8t4eXsgPuyiEJSkhUzftSd5Lvf/dkeglfC325w== 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=cbfo5kEsoA7YYwuAfhDv6dwtUZhjWTNomL86fymbh44=; b=VHDgLFD8MXwsapj6MeNWzgmlti+pNVWJdiRHP9SVhWoEH9hc+rJYWOlIJbkbX5nZcRJVj8nuGTWrRLWaL3YueoCxruepxFjc+f0UzurbLNU038h13BQhvKw3/jZEuEnAOnRVKYS5z6n0N/tODfRC81qcZSn9fLpFIoT1fz7ov2gfaXRIrZ+11OyFkwiI3+30HPNpNuAveHV979npqLEOcRIk/hbTBboOEYFe5nIRcDRuaB+euGsNrR0UhNEvZcDJpuq9hakUt/0zXJbwb9IzgwfDmV7OYyP5wpQG4xqetf3lnGre33y1HpD8BkbzK2eK0zWOZ58V+4M6U/7+tF3P2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-foundation.org 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=cbfo5kEsoA7YYwuAfhDv6dwtUZhjWTNomL86fymbh44=; b=tF3q6G6LfCSQJCgajrxP+ZOHS4ukjMcn6GfK7nuuig1hCjREByzhxfi+mVx/It6kjZ9Vu60vdACpUtTByPBSSiaAS97wKjXZrL2wkxHn5F9lubZPoRMRQIva8RZ2rBjRC70HqdoovaFMtcR/x8KUCaOIxrJZlHitqp/bTKI98+XFDkhvkuFfU4FrIaugevMkphIYHAN3vAdAr8hgtKdpnKoxaFlR1O/v8kByOvurw2+XNT465Y3M7rOCIEe76WH9o9Es3d2nruD+n0bmNxmqQyc991D7CTysMgU06mwiCKoNTdNy9VXH3GzCZInnzTrWJ4yTrNnO7uFLS7z/Lksu+A== Received: from MW4PR03CA0271.namprd03.prod.outlook.com (2603:10b6:303:b5::6) by MW4PR12MB6975.namprd12.prod.outlook.com (2603:10b6:303:20a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.15; Sat, 1 Jul 2023 01:04:58 +0000 Received: from CO1NAM11FT103.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::aa) by MW4PR03CA0271.outlook.office365.com (2603:10b6:303:b5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Sat, 1 Jul 2023 01:04:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT103.mail.protection.outlook.com (10.13.174.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.43 via Frontend Transport; Sat, 1 Jul 2023 01:04:57 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Fri, 30 Jun 2023 18:04:46 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.37; Fri, 30 Jun 2023 18:04:45 -0700 Received: from blueforge.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Fri, 30 Jun 2023 18:04:44 -0700 From: John Hubbard To: Andrew Morton CC: LKML , , John Hubbard , James Houghton , Muchun Song , Adrian Hunter , Al Viro , Alex Williamson , Alexander Potapenko , Alexander Shishkin , Andrey Konovalov , Andrey Ryabinin , "Christian Brauner" , Christoph Hellwig , "Daniel Vetter" , Dave Airlie , Dimitri Sivanich , Dmitry Vyukov , Ian Rogers , Jason Gunthorpe , Jiri Olsa , Johannes Weiner , "Kirill A . Shutemov" , Lorenzo Stoakes , Mark Rutland , Matthew Wilcox , Miaohe Lin , Michal Hocko , Mike Kravetz , Mike Rapoport , Namhyung Kim , Naoya Horiguchi , Oleksandr Tyshchenko , Pavel Tatashin , Roman Gushchin , Ryan Roberts , SeongJae Park , Shakeel Butt , Uladzislau Rezki , Vincenzo Frascino , Yu Zhao Subject: [PATCH v2] mm/hugetlb.c: fix a bug within a BUG(): inconsistent pte comparison Date: Fri, 30 Jun 2023 18:04:42 -0700 Message-ID: <20230701010442.2041858-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT103:EE_|MW4PR12MB6975:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c3ee5b4-5cab-4b89-0526-08db79cf301d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hPpSLCg50N8njx/oz9U6FX9jTfp2nWhujwMKWZk7xyu73dvNlNayEDFLV4zGiVjtyDtHl1nuHp43ty0Clb1c9Y59JC788A+gD72oxH15ZAEGK6feU+EVA3Aa5tkGkOWjW0FTS954DdAhfRIxBeC+HIQsLJN9dTTotjAN766OqVtrM/MpeDmXxoQeaA96rN2gaYk5BfQcTjaKBkA2eN2OM0p6Jucq4iSAg6XoyYvKna0P4QXV0loHqAalavngQpDkEBXCYAeipSWBNkUj6JfmeTC6EgbdICMTFMzUDk4F+v6Z1n4DErsY13Uu9mGs+6w8EgHYrC/vPSLJDuRpQNP/ilMtDJImlaEG2hHT8EpExVc5lbEz/8Sg4xmeqNRRHDBQvGIQaNaVYqzCJi9BF1BWmaVsNA5Du30Rr0mKxI2OMvD1tqbBxkE/dYcQtdUBzw3Yi4OwBNCmkxWknqkowitXlWqQfbyG13qhhB/UMxE0a4MMpGvvvrWMNOcS4A3SNlZshpCUTDbHO2ujK1G4Afwmu6PycL/ZrFt3YqgcBShhBi+TlxbjcSU6HNdMTn1cfomRQ2xyXUwhCypUfm6nwzpP8MFe8GrfObegjT88M62ZAFNvGQOQVaM5+Y7FQh09e9R7GzyTUY6N5l4PKjbHQXLVaLqcwXVOJsoY+nXd80Np1z7RrxB+VMqxdyt/k8iB//OAbt3XEM2TPcOGsq6yGAjRZE66NFOTHEGhvJFsrhDXy6ZtKgpVAlUAs/2dYJjDFdlq X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(39860400002)(376002)(346002)(451199021)(46966006)(40470700004)(36840700001)(478600001)(7696005)(54906003)(426003)(83380400001)(2616005)(336012)(36860700001)(86362001)(40460700003)(1076003)(82310400005)(40480700001)(47076005)(26005)(186003)(2906002)(82740400003)(36756003)(356005)(6916009)(316002)(70586007)(7636003)(7416002)(7406005)(70206006)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2023 01:04:57.3894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c3ee5b4-5cab-4b89-0526-08db79cf301d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT103.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6975 X-Rspamd-Queue-Id: E4F66A0004 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: krphcxot4wux81yqjqkfry1fxcs81gm1 X-HE-Tag: 1688173500-405212 X-HE-Meta: U2FsdGVkX18eayNYXA+oJ9cTT5Xd5D+77ese3yS6xYJ5M7b55C8/0yKXSxfGqeCLGW6NSNXrhzgbAOkfYhX50K6GtI4VyD8eaasu0YY97dI7LS/PymHm8nLl3jZcovWxODRoL6zKpv/7vQ4Fxn3zMkIa2sV3sq/LLBH41I5Pfcy8W+VPt/epIj0k8GoTArDJ30A6o5ZUulibuLYx5Did5WrnVqmKitfs5CA2VMR3QEFfMBksQyxN4Bxhp8Zh2mZX6l18ICYdFuZ5njOA4dblaIDvRn2IJUzYrdanNYUy4bH29wYWvbyy78SHVtfKoTXMZ7gGl4FI6f/IlUnBtGXcJWho1ppozaEh+HAFjb6d26YbKmvdP06n+PoSmWGlAunAuXnvGw6wHlWcRjCkTlV7GySNp9zJLPnD+h5b5GDFIQyr0J3e1RcPnL2xSEPi0AETgY9AoKu94SWZ1uTM6Lo5JcciHv0ZGNY1y//R0M9vLo4QpTnBVwn2qH74/8gvE6+COyGZX6ENuHtkUFUq51+6f+CCzvum6M41zGPxjhMGFtCaOVLiwOnkBM/YXGGj5e1YWbLbBkA0Clc/9Mc8B7UNaAtUshOEEj9Pui9tvCm/4KcDJ97FF5DYpXk9+Goy/azMas97rjqNtaNb9Ne+XJajkXWZG4F0h7Sf0eyrQU4gwveToLO8tdAG5Z33nuxypZcq8TyXFQT80lyPMNeEQU4pqyw1pGitrBAOOoyvOA70aqEOgClTQjOoMvGpVHyk+mnpSve39pqYkZMrB1RaI/1uLIb19kEkUyjoGtevUKt07wxn/vYRnwPruceEbhK0Z7KG8+GFNCmLqbDKMvx8XPrcCXniwAKJrSMljfYGxJIkCdirDqeXQHDCHOB/hJTRPrWLEPBfdoIsk7r2hZzPXy1Ldqj+0vUXRahCnS+GX50nCucZp4ttHIO3KOxqL1U09Dt41O9jOXsvM4AFs+0FKWE dwGpa3NC NtRsBPFTrtcwKz0URHpUkKsPHaYmr/uwN8ev0ki8AhSj5ExujuX6ADuxpmRr0RaaTgYIBLYij5JH9Msh/MF2oaDJE2xMVmCFTn7+z7QgdcEarOjR2Mwhe8wbh3FJ8TkHu4u0+vsPEJlmBQD78aGEbpcftQ3T5Upraf/W0Zsq7v/vH5MndNE4qy4B85S32flND6olW2dQKlnx56oKChFakZi/JE8ER3xh7JnfQf8n1gOWPlQmVtZyPdwoEbx1JCDokLSuwTIkRqirYist14z96eEvWoMFxppF0W0nqXTYIoXj6Y+yyMxKrlVey3ssPWAFZmfAE6xQ2TX51mIVL4p858fRAyY546JPcewAp24nEAqEI6iMBLunk3R9be5xE2J0KgLyUnQb6eTtaaw7mCCLiZLkZcIJFvXdBoG0ZIcR76iI9HhYl2OFY+2u0RzJ1UQRek2KwXhr4MJf1k/axNnsTwsJukcnqEaLLtdq8N2Y2iC50GRbB0+bze1CdgvAWR+bK+dMs6PaTrwIVismpyVWme+H3a5ba1bfoWHZHODCuRDWst5j+77XdvG8YuC0c0Ri3TpUVgmSbVIrjNLF/xHV1qtVxCyVDhKUFWOIZ13rbQdtqCzPgeHi5icEFMkpac6bQLA3y8kKAc69XPg708h5JxmvsXEW7NkVBeXXncX0HFNIX5XzYzq06ZgW73JzGwBtuIOo5hU0t0TfnA71L5enV2QtRjpU2YJz6kfzpR2w0ssabdcBj+slkcrgTNbANQP15wdQ26iv9lb70IHfO9qxD7mEtEAQLijWVoF4Sz6Rk68VIsXxXDhBvLKxgJ9JnHdLLe8qElJrm8VDCaS3lRTyMmXAOLvZemzdnhGlKtA/jFhJ12Laohj0pSBbYWWMs6YJmgBlOzAM5BEBUQ5tH0U8eWfawHvmnkfMpzv6QABOhLeK5axLKYJAOw8uHAQ++CnnGnVPV6kuFdKiavqqMBDyR/zZkh98/ IAWLLi4o 1pw26iSRYh4E6uAg6l8N+zjbcBy+MZKuM3DlK0C1etpyM7Uo+0e6o7OUp7MRnwIBa20ib67kE35i13swHfo8To+4EVPqtnIT9GI1Q4lzmDCXe43H1dDHLwFPGBsJgZp3bvQ860lr6c53BqIOAM4VCw== 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 following crash happens for me when running the -mm selftests (below). Specifically, it happens while running the uffd-stress subtests: kernel BUG at mm/hugetlb.c:7249! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI CPU: 0 PID: 3238 Comm: uffd-stress Not tainted 6.4.0-hubbard-github+ #109 Hardware name: ASUS X299-A/PRIME X299-A, BIOS 1503 08/03/2018 RIP: 0010:huge_pte_alloc+0x12c/0x1a0 ... Call Trace: ? __die_body+0x63/0xb0 ? die+0x9f/0xc0 ? do_trap+0xab/0x180 ? huge_pte_alloc+0x12c/0x1a0 ? do_error_trap+0xc6/0x110 ? huge_pte_alloc+0x12c/0x1a0 ? handle_invalid_op+0x2c/0x40 ? huge_pte_alloc+0x12c/0x1a0 ? exc_invalid_op+0x33/0x50 ? asm_exc_invalid_op+0x16/0x20 ? __pfx_put_prev_task_idle+0x10/0x10 ? huge_pte_alloc+0x12c/0x1a0 hugetlb_fault+0x1a3/0x1120 ? finish_task_switch+0xb3/0x2a0 ? lock_is_held_type+0xdb/0x150 handle_mm_fault+0xb8a/0xd40 ? find_vma+0x5d/0xa0 do_user_addr_fault+0x257/0x5d0 exc_page_fault+0x7b/0x1f0 asm_exc_page_fault+0x22/0x30 That happens because a BUG() statement in huge_pte_alloc() attempts to check that a pte, if present, is a hugetlb pte, but it does so in a non-lockless-safe manner that leads to a false BUG() report. We got here due to a couple of bugs, each of which by itself was not quite enough to cause a problem: First of all, before commit c33c794828f2("mm: ptep_get() conversion"), the BUG() statement in huge_pte_alloc() was itself fragile: it relied upon compiler behavior to only read the pte once, despite using it twice in the same conditional. Next, commit c33c794828f2 ("mm: ptep_get() conversion") broke that delicate situation, by causing all direct pte reads to be done via READ_ONCE(). And so READ_ONCE() got called twice within the same BUG() conditional, leading to comparing (potentially, occasionally) different versions of the pte, and thus to false BUG() reports. Fix this by taking a single snapshot of the pte before using it in the BUG conditional. Now, that commit is only partially to blame here but, people doing bisections will invariably land there, so this will help them find a fix for a real crash. And also, the previous behavior was unlikely to ever expose this bug--it was fragile, yet not actually broken. So that's why I chose this commit for the Fixes tag, rather than the commit that created the original BUG() statement. Fixes: c33c794828f2 ("mm: ptep_get() conversion") Acked-by: James Houghton Acked-by: Muchun Song Cc: Adrian Hunter Cc: Al Viro Cc: Alex Williamson Cc: Alexander Potapenko Cc: Alexander Shishkin Cc: Andrew Morton Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Christian Brauner Cc: Christoph Hellwig Cc: Daniel Vetter Cc: Dave Airlie Cc: Dimitri Sivanich Cc: Dmitry Vyukov Cc: Ian Rogers Cc: Jason Gunthorpe Cc: Jiri Olsa Cc: Johannes Weiner Cc: Kirill A. Shutemov Cc: Lorenzo Stoakes Cc: Mark Rutland Cc: Matthew Wilcox Cc: Miaohe Lin Cc: Michal Hocko Cc: Mike Kravetz Cc: Mike Rapoport (IBM) Cc: Namhyung Kim Cc: Naoya Horiguchi Cc: Oleksandr Tyshchenko Cc: Pavel Tatashin Cc: Roman Gushchin Cc: Ryan Roberts Cc: SeongJae Park Cc: Shakeel Butt Cc: Uladzislau Rezki (Sony) Cc: Vincenzo Frascino Cc: Yu Zhao Signed-off-by: John Hubbard Reviewed-by: Ryan Roberts --- Changes since v1: Added Acked-by's. Fixed as per Ryan Roberts (thanks!): changed to ptep_get_lockless(). mm/hugetlb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) base-commit: bf1fa6f15553df04f2bdd06190ccd5f388ab0777 diff --git a/mm/hugetlb.c b/mm/hugetlb.c index bce28cca73a1..64a3239b6407 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7246,7 +7246,12 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, pte = (pte_t *)pmd_alloc(mm, pud, addr); } } - BUG_ON(pte && pte_present(ptep_get(pte)) && !pte_huge(ptep_get(pte))); + + if (pte) { + pte_t pteval = ptep_get_lockless(pte); + + BUG_ON(pte_present(pteval) && !pte_huge(pteval)); + } return pte; }