From patchwork Tue Sep 5 21:44:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13375123 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 E25E1CA1019 for ; Tue, 5 Sep 2023 21:52:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64E2190000A; Tue, 5 Sep 2023 17:52:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FEE68E0014; Tue, 5 Sep 2023 17:52:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 451F890000A; Tue, 5 Sep 2023 17:52:42 -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 33DFB8E0014 for ; Tue, 5 Sep 2023 17:52:42 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0177F80B9B for ; Tue, 5 Sep 2023 21:52:41 +0000 (UTC) X-FDA: 81203893764.30.E47FD56 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf05.hostedemail.com (Postfix) with ESMTP id B0D8C100017 for ; Tue, 5 Sep 2023 21:52:38 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=kmyImPsw; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Eb+qcFrM; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf05.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693950758; 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=FIBN6YhPsvUwRzPH0L9SXh5tL8FY8pkar6teks6b5sk=; b=0E/cYcq4E0KbVMWXZWPtFyWPmoswhF0XbNrvX2eMyoSvKr/agh+ph1x+7EyD2CqC2RdzMD dApOy/nhlAg3Nmn3fVrECPHYFqVIZ6HqDQwmUCM9SREVNYB4VVwMqh36ZnhORldepNRZe7 B3ZuuU1hFd15cTHNRvGaIHTw4Hc+VxQ= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=kmyImPsw; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Eb+qcFrM; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf05.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1693950758; a=rsa-sha256; cv=pass; b=FEyJN9GmszdK2nzQSXD6X7HpIyX6w4Wk5bFwCh+7A5GHL/Qyx8QVVBcmzkulnbcRKsICsJ qDZW5IVdMAD7+3cKhjmRQh/+a+lxf0fBhMUnVGSpSf3n4Ao5ZOvwmyxUiOr6bAH65ePxp0 zd/nOmjN/nGKu5B687R2GstVzihCCNE= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 385L9wGu006968; Tue, 5 Sep 2023 21:52:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=FIBN6YhPsvUwRzPH0L9SXh5tL8FY8pkar6teks6b5sk=; b=kmyImPswIIXavrg9A7ckMlZ4unYskU8NbtNdPSV4R2GQMy/6v4VZLtboVx8yseJCuWsz lihOxGy609ciu4KfFEVEFNniIyf31L0N6VwJVCxcjtpyBe5PGRbtXmv84AaXgbdW3WSz S9tRk2E1NNGNjUqGP/0HFJbRndrfX8yI0HrrH3pdOtfjIeIZNJ8TD75qu9g9o8BKU9Ho AT8YuZMnjKar8wBEHCqlGQ6NcbRr51Vo7pqbUEY0V2ugK4VSkEWCiX+Fv+78jhq/d8ef zqc5DvyrTj1cvTsZ9CR7V/qZj7DbgLn3ORwCcjr6NwNSIddVoY6I7o+rYkKWfYb6IIY6 fQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sxc0g83vr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Sep 2023 21:52:11 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 385KA9Hf037099; Tue, 5 Sep 2023 21:44:22 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3suugbkmr4-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Sep 2023 21:44:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ST5G7kN1J1M43yFRzSZhnxF0odlMqK5i+ADW9AfnLUkLW/bK1vrkjpzyfV+FcFOBMhsimRABsJZuZsyKduLhOIJWWTOl+39d+BZFQ808XP5vmo06Jrc/By6/8swWx8ribFk9BsF11ITdn0Pcqu4YWY4hIJA5WDqKW+M/SAwYwsLcfCKEwyLDrLIRr5v6j7t7HtqIPLZPD2vgX+C6FYgNrXB5vb8ubPdChKHKqsWCWUarAfIqqdRuVx3wKppWUvAw3OwP5KJbRmEptYmGYh/kRR0+OamsK4mcRTkFrDtDc22xFxum90UiMKQC9clLgySDFPyIO8kObPEYtlJXJVM38w== 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=FIBN6YhPsvUwRzPH0L9SXh5tL8FY8pkar6teks6b5sk=; b=bPghD+J2LtFKubKXF94BYeMy5Lwlqzo55ifZ+lhFiE2L9iwGE7B2SHJD6x21//CWdq1KRPa4mrwn+Fiib0S4vaaN55ftz2mwSYUhP2QYkyojPdtorq3No8hbq1n/o5gTlFg234ybdBk3UN0CA/Q4gTcFAchOJtPOV/i/4/ouS4uipSkcDZqr9VfU2h2etHlGPRSRp/4nHeYLjuVfFMsNpxj31VtpjqkZbBHRAgrEVdHsBfn92pLfm5ZgO28Bk8/c1Ku9pvjHVG8//8oCLfpUO5QLuNvg5zYDlNQMZXoibQ3DqSgzteeCthD47hcLBwGHZNiqjvB+IZKtZo5QujupQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FIBN6YhPsvUwRzPH0L9SXh5tL8FY8pkar6teks6b5sk=; b=Eb+qcFrMUrFUtj5iJJLd9/CVb4+cmYL1izF4IDuB/JEn2LpQJjCIhpfdFokBnCTXQ8FNmdSkzfQv5De39wbT4wQSqxxW1BDTl3GYqjL1Dqum8TiKXFtUasX0i+7fp2YNGCxnqT1u3SanqioaiWYz9i5El8ScYEBptn4KqPZug1I= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by MW4PR10MB6395.namprd10.prod.outlook.com (2603:10b6:303:1ea::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.33; Tue, 5 Sep 2023 21:44:20 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::58d8:cf97:ae4b:1715]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::58d8:cf97:ae4b:1715%3]) with mapi id 15.20.6745.030; Tue, 5 Sep 2023 21:44:20 +0000 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Muchun Song , Joao Martins , Oscar Salvador , David Hildenbrand , Miaohe Lin , David Rientjes , Anshuman Khandual , Naoya Horiguchi , Barry Song , Michal Hocko , Matthew Wilcox , Xiongchun Duan , Andrew Morton , Mike Kravetz Subject: [PATCH v2 01/11] hugetlb: set hugetlb page flag before optimizing vmemmap Date: Tue, 5 Sep 2023 14:44:00 -0700 Message-ID: <20230905214412.89152-2-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230905214412.89152-1-mike.kravetz@oracle.com> References: <20230905214412.89152-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW3PR05CA0024.namprd05.prod.outlook.com (2603:10b6:303:2b::29) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|MW4PR10MB6395:EE_ X-MS-Office365-Filtering-Correlation-Id: b2e4eb51-c3b0-4302-8f57-08dbae594302 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aQqduTujRkMeFk15PIjXX7+QdwifXw8/Ue/iYvtas74zlZVmxkZjkiMa57oYQa7eOfvjgs6U9aWweUwqwZ+nADvHDa5iDHRXHnPRa1JKutLqB4CbVnTbfKVEOOsvE0bvVC534+5Lp83zvAzGl06pMJuNPk5xtocPVebGokzsznEWAYJR3yap8Unn+nyCGtJV03cGy9lVS59rABYe4jvrpe7EHcnlGd+RdnZ6dwQeF943ljubDVGPwQVm8nWQZC9EQboEIj5aSlCqkE/kleuVYme3rrUZc9lCskSPqTbEJ+1NFoHG58mzzh2KxSlULSfj7hOUl1szdE1nBF1HSO4P3Y+a7bNNcUsGbqPmKn3A480lP5cAa/85SdnsW2QHOacvifzuhhO5lUWVwDXK0kw/zDhYRwGWO2pAC95xg+CPbGBe8neUDwdrGBDiR3AOY0qH5iIEKaP53cE4k2tJ9j9YJHwSvECajLz2dNaLZHiv9I0VyvNTbGewoEByZDABayXwHpaghZbebwRho6r9PTWbg8wrEsWUjuRGrm87UcwJC7XgngWAEXumhgwWvNEAw69N X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(366004)(39860400002)(396003)(136003)(186009)(1800799009)(451199024)(6666004)(6486002)(6512007)(6506007)(478600001)(38100700002)(2906002)(7416002)(107886003)(1076003)(2616005)(26005)(83380400001)(86362001)(36756003)(66946007)(5660300002)(54906003)(66476007)(66556008)(316002)(44832011)(8936002)(8676002)(4326008)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7X7LLAtLrXRTHmKLbKC7/EsYnUtPO01VfWjWFFjD0r63JETud0YLz6B08ZRjDTc9dy7v4fgDXNjYEYvxjVHOLuy3TsXZ09AR+318PDlqzJKvkBte5xMXVKo+huawRFUn//VZKz14SlQnkECUavgrxNeoKN1wG1SXGysLBo174j5TzGijDk0KEsq444xbui/0wPW2qNpKzSKvMKHF+SGeqSeKFpaNC0wdS7A82a2PPTDO4rdsw8qB1zGNAXwN5TmxwOWUJ8a02VADxtBAkt7tFo1R1g9LUR/pI6TdD8+7eP/Hc+pT2cGOkKWWn0LrpObGdMOEjoKZAWRP/qdscGsp1RX2pJ+f6EB2i1EUIIMegzhclERsAOUtIJAuVA/lARDQ8UIKJaVKUO7Tp9037iW6NJgm+9YBhegiJXrcEAN1Rln4YJLNCqpLkMNo+cxwQNU8Hi5nQfv605nBV36mHb3w0pMXeDMyE7dQyYIj8tWG9UBA9U2LVJBA9JMexhP43ybBOwKlkgnjA+xwz3Vnv9xDB3Qe1xAitvGBPDgwCtRdvhMzrxtN+W+Nkmsr8kbVed5pc/tjTOMOKJ8q2VuSki5VtxstPyGJO0d+oziCcklXe1RIDKqr8Mp78hQiKm0p7eCMyznjeAS5+fjemTwDH9JW4VeXF9eeKWT/AEQLvILhjqzhywmuqsYVGPlcwCicOhgyVOcKztz2KPOJSpJhMI0sSFw8dcOR+R5FywAKQ67O8IcgtQriHTVle8ijlciR5wxeZ3+NDmURnToDJfy/aK/xx6q9SGtyPlrgkyOM5vn+o5RY0FqcbWRdc8Nt8YklT5HraOnHN63SbEVygvE4j0rXVMs1KLgs/H+n+R9ps4NeBcfT+gtqp2Wn/KBTzlMDtrVN3e4uwje/TsIxG3NUDti3BFw/+2Mx4uByWOtftFnOpfmZ/NrxjK7gACt6THmEtsNNP23sbRohQLST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Z2ea4v6RyD9XwPmgX5rzY06UFr/GwA6Bw6N1lNZojBMMOSsvbIfn61f/RWQZEcexY15gbZc1qH4uEFeRVUj9zpDpcAn44oFve+/YYb6cUnrtW/+1IyiRs9RwPgBcL/aePq19/UN1q0IemoiCNaZRuROr6PR8TWUEhWkfvn4Pc1FtbTtxzVsM+HEJGhC8OWYqg+xHLZm8VKRkC5ILF9MMahW2r5cXlTYEmc+3ZgHzIwzJ7rjF6/5GtKk+wY4dDjdI97IASp/Af8Hl6FlEoS6zvFCBJQ/JLGn1oNX8fdzKRvQwi2wIQ2T5G12+IETjR0/R9DddDztiiw1IywW9/0ks9Ux+hcPIo3sVo3OU3Ltyj/IywPJai8PddyBg+WqR0yYOFv2qJjNeCijunpi/ccOaA/0YCFMDL7XNpuYNlJsc0Y22DOKE2LnNxuVziGG4pg4f1ah8c1gEHZOcBzPiBLFw8xWOFIEsg6p7NZk+ARZt01r5B/sveGjhk04sTwg2pdNOMofLxPqIcdQop1hpcVfxJ0Mwc7ESWmXhVP9D6II5GRjXNEz39+tIWJfhPw0WDocYQ6X757ck0cozn+SEYqKNEYa9geWhSQR9w9X7OZpPJXSfr84J/HKbGjauG2o5sulTd3KFlkHMEqzDoA6ZolGuutipOwbNJUd1I1X8e4A0jGiXd9W11HRDq6Yhtli7qI0sbLiXstKOgaZV6Bf6bWX4oNjJKlMVrglvvXOEbS9SfJw2PYDB1pidKd0KtgSOxhO8EPWfM8bMyj520aZwudGUtZb22zqZpw X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2e4eb51-c3b0-4302-8f57-08dbae594302 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2023 21:44:20.3786 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hxjtT/BJ+eb27xxv5YEprnQzSWgCQO1mNymvpXcUawwyDhSqpsshRNnQkmlOM/WhAaB/nqERWcAZJqcAGRAmYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6395 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-05_13,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309050189 X-Proofpoint-GUID: jMekqK1luzh1A4vhH0HMzfgFUmQxBFYn X-Proofpoint-ORIG-GUID: jMekqK1luzh1A4vhH0HMzfgFUmQxBFYn X-Rspam-User: X-Stat-Signature: nmojki7x5bdddhdo31kfd9h46qeoibdd X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B0D8C100017 X-HE-Tag: 1693950758-43528 X-HE-Meta: U2FsdGVkX1/udEa5q14KTb3Snmqa5mSDI+NHouJ8XRGduQfoFs3/zacTZnKlfV0LZI8kJQ9LFGkeKXFndL/DWPWHV4MrjtIs/lQs5u7S61l2sZzsfGGyqBCjy9nO2ee2wIK3pYQEsLNkEk0pm6CI01K3eVXXpQ7dmusFcgOOWhZDADrtAVXIW2QukP3GmWIEoQgKYP34b+yGeoklbLV4jkwQYhAciyT7hliePUzyGWhGZ9Zo9zmhwrh2c+IoqwL8YH+3aBdCCAhLw24q3jTsyHB16M6iwHs3DqpDcz/7JmhewccaXjKYTNjMopcM/bn0YnG5gsu2tPQDslkTfub6eh7ee+q+bM0YXciMDkBLpvC3vlta1M6tXrv//Ysm414WI1pPVhAYiU2JOD+BPk9YTCnqVk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9bKCp+NrWodXZAVlt3X 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: Currently, vmemmap optimization of hugetlb pages is performed before the hugetlb flag (previously hugetlb destructor) is set identifying it as a hugetlb folio. This means there is a window of time where an ordinary folio does not have all associated vmemmap present. The core mm only expects vmemmap to be potentially optimized for hugetlb and device dax. This can cause problems in code such as memory error handling that may want to write to tail struct pages. There is only one call to perform hugetlb vmemmap optimization today. To fix this issue, simply set the hugetlb flag before that call. There was a similar issue in the free hugetlb path that was previously addressed. The two routines that optimize or restore hugetlb vmemmap should only be passed hugetlb folios/pages. To catch any callers not following this rule, add VM_WARN_ON calls to the routines. In the hugetlb free code paths, some calls could be made to restore vmemmap after clearing the hugetlb flag. This was 'safe' as in these cases vmemmap was already present and the call was a NOOP. However, for consistency these calls where eliminated so that we can add the VM_WARN_ON checks. Fixes: f41f2ed43ca5 ("mm: hugetlb: free the vmemmap pages associated with each HugeTLB page") Signed-off-by: Mike Kravetz Signed-off-by: Mike Kravetz --- mm/hugetlb.c | 31 ++++++++++++++++++++++--------- mm/hugetlb_vmemmap.c | 3 +++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ba6d39b71cb1..c32ca241df4b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1720,7 +1720,12 @@ static void __update_and_free_hugetlb_folio(struct hstate *h, if (folio_test_hugetlb_raw_hwp_unreliable(folio)) return; - if (hugetlb_vmemmap_restore(h, &folio->page)) { + /* + * If folio is not vmemmap optimized (!clear_dtor), then the folio + * is no longer identified as a hugetlb page. hugetlb_vmemmap_restore + * can only be passed hugetlb pages and will BUG otherwise. + */ + if (clear_dtor && hugetlb_vmemmap_restore(h, &folio->page)) { spin_lock_irq(&hugetlb_lock); /* * If we cannot allocate vmemmap pages, just refuse to free the @@ -1930,9 +1935,9 @@ static void __prep_account_new_huge_page(struct hstate *h, int nid) static void __prep_new_hugetlb_folio(struct hstate *h, struct folio *folio) { + folio_set_hugetlb(folio); hugetlb_vmemmap_optimize(h, &folio->page); INIT_LIST_HEAD(&folio->lru); - folio_set_hugetlb(folio); hugetlb_set_folio_subpool(folio, NULL); set_hugetlb_cgroup(folio, NULL); set_hugetlb_cgroup_rsvd(folio, NULL); @@ -3580,13 +3585,21 @@ static int demote_free_hugetlb_folio(struct hstate *h, struct folio *folio) remove_hugetlb_folio_for_demote(h, folio, false); spin_unlock_irq(&hugetlb_lock); - rc = hugetlb_vmemmap_restore(h, &folio->page); - if (rc) { - /* Allocation of vmemmmap failed, we can not demote folio */ - spin_lock_irq(&hugetlb_lock); - folio_ref_unfreeze(folio, 1); - add_hugetlb_folio(h, folio, false); - return rc; + /* + * If vmemmap already existed for folio, the remove routine above would + * have cleared the hugetlb folio flag. Hence the folio is technically + * no longer a hugetlb folio. hugetlb_vmemmap_restore can only be + * passed hugetlb folios and will BUG otherwise. + */ + if (folio_test_hugetlb(folio)) { + rc = hugetlb_vmemmap_restore(h, &folio->page); + if (rc) { + /* Allocation of vmemmmap failed, we can not demote folio */ + spin_lock_irq(&hugetlb_lock); + folio_ref_unfreeze(folio, 1); + add_hugetlb_folio(h, folio, false); + return rc; + } } /* diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 4b9734777f69..aeb7dd889eee 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include "hugetlb_vmemmap.h" @@ -456,6 +457,7 @@ int hugetlb_vmemmap_restore(const struct hstate *h, struct page *head) unsigned long vmemmap_start = (unsigned long)head, vmemmap_end; unsigned long vmemmap_reuse; + VM_WARN_ON_ONCE(!PageHuge(head)); if (!HPageVmemmapOptimized(head)) return 0; @@ -550,6 +552,7 @@ void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head) unsigned long vmemmap_start = (unsigned long)head, vmemmap_end; unsigned long vmemmap_reuse; + VM_WARN_ON_ONCE(!PageHuge(head)); if (!vmemmap_should_optimize(h, head)) return;