From patchwork Tue Jul 11 22:09:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13309428 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 B8FD7EB64DC for ; Tue, 11 Jul 2023 22:10:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A9816B0071; Tue, 11 Jul 2023 18:10:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 259546B0072; Tue, 11 Jul 2023 18:10:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AC986B0075; Tue, 11 Jul 2023 18:10:19 -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 EDDF86B0071 for ; Tue, 11 Jul 2023 18:10:18 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C4A33C03A8 for ; Tue, 11 Jul 2023 22:10:18 +0000 (UTC) X-FDA: 81000725316.28.C47F2AB Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf13.hostedemail.com (Postfix) with ESMTP id 470052001B for ; Tue, 11 Jul 2023 22:10:14 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=eKAdZdsa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=h2MfyXZn; spf=pass (imf13.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1689113414; a=rsa-sha256; cv=pass; b=QpU4JtpfLnxa3EVhGxrZy5/MC8LJIpYu8f2HsSQ65ORYMzsvK7D+qmqiauc8u28ujScHNc 7OP0OptUw2jAXngGPyoH90xniocpnpovwDtt9dGE39IZwggNoSmMGfAc5iwFKqZvQG/Lu+ BqMpBjllNRHwQe/5H00xYO8Ei15FK/8= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=eKAdZdsa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=h2MfyXZn; spf=pass (imf13.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689113414; 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=2DxMbws++KqvbwdoPM7T8RtLODfPW5/jpMuy/WlrZ88=; b=jtjv3Ref3os/6wJ+TCIZC0+0R1y24jQP8ufFw3slkFFcLCY6Ay+CyQk8N34x51nuX5VBn0 +7qi9L+f6/CcSmsH4rI4EScg9vtVUV4J6gmVx8jhtTjoidkbQhOTmDjhq/q4NMkZH0nA24 KfNtyaHI1+yOjUlitE14SpfRrNPMqcs= Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BIDS3s025206; Tue, 11 Jul 2023 22:09:55 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=2DxMbws++KqvbwdoPM7T8RtLODfPW5/jpMuy/WlrZ88=; b=eKAdZdsaxIHv9OmULW5zzvEnlnTqoL0XrAk1Ssz5H2EKQZmWCW4Y4vu1x0IEa2VKFPDR 8Vm2PW0yQgHySvmS1WYaAXxTjLoQJ8DwGPciSxKbok+2AhmzLXbX7X+EJe8y1/sTHpbJ peUuRjcBsHQw/QSS6So7WgyisuH+c1JI/cMVjDdA0r0RSLqwPnVyRoYvWtpEM452KRem vWhdhQi2fy9z7R9vPLBPDQ4j2/8WliNSzZxwyWW3UPjuUSxNDLWZu1L1Zkw7JIeuxELz khPPFAKJemackWmwiV/couf4WaFIykx30frRu8052k3GgUVrBi9fnKSwQSqW2HKL/IXq ow== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rrjmhbjem-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 22:09:54 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36BLd7ie008596; Tue, 11 Jul 2023 22:09:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rpx8btb17-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 22:09:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QYhzqgM6xJNEMkAevI8c7HHevzEO7Al0/1SyfhGfjoX56HuF2ILLzqZEWzgwZkV5BHExoXbLIXcH6hU5Jm4Rk7ibsGKm++5zVDiVLuum6SUaPtGx9Xkzgve9bhJfhV3KwW8zZXj9WZpzp/j+wwqYzMWWR5Xy88Qm+VbBAt7Vc4wq+Z8SB8NVTOrzcTek7wOBwCcnL0QMhjsOBD08qhj+uINnU8E2lPpNFR56kcWW1Xy6jOmN7oQjUyVZsD05Ma9BEzLGHOSrY+tvmvaaWGT+i8mKbIqudFbT4rZT8A9TU4fuxIxECBLpSGgNjjE5iyCtHiehCA/WIXXXxX4OME89+A== 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=2DxMbws++KqvbwdoPM7T8RtLODfPW5/jpMuy/WlrZ88=; b=j/y1RrVoP8NwdfviOCNxu4V2x9aOiQmpl3DSQ5766CPHRpgpoJdKusPR/NKe0TSiIycLLnaqKRNPqLQ7eqFRQg68SQPep7sKz2wr1EfsgauPzWs6sgTwckMDfHQtG1zUGlv3q0cfVOZrLYRU9BkyDDstY9oGJKWmXluKbV2y+4rYk6taq2auuHClgPkQBLY+RQmhezJRjKLKAfyA4GQQxxtR3obuUzE277v2A+s1+hRPmw9GnXmvFY7PjpqXPDl1ypw2QqLsDtHOEbWYKybOTxv9qrpEAVRftER3QrZMqBcGL6D1qlsosuyhBTh3Th8vZJ42cxCL45Wa6+KqRI3sUg== 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=2DxMbws++KqvbwdoPM7T8RtLODfPW5/jpMuy/WlrZ88=; b=h2MfyXZnYM4H68WzPfak2QLnIRhnfk7puMmKoxvDtFGmOO3DC8ihvn1cs57aSlsKslccgRyBTbHEeGAZVF9hxgRpPoAt0pKXw3abAGCHzR+umaMUkYrSI6EukllP8eThImBoLaoH6Q7yFb8I/NtiIm3+egskrY3prfdrbcR1Zrk= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by PH0PR10MB4775.namprd10.prod.outlook.com (2603:10b6:510:38::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Tue, 11 Jul 2023 22:09:51 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::4a17:13b0:2876:97f2]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::4a17:13b0:2876:97f2%7]) with mapi id 15.20.6588.017; Tue, 11 Jul 2023 22:09:51 +0000 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Jiaqi Yan , Naoya Horiguchi , Muchun Song , Miaohe Lin , Axel Rasmussen , James Houghton , Michal Hocko , Andrew Morton , Mike Kravetz , stable@vger.kernel.org Subject: [PATCH 1/2] hugetlb: Do not clear hugetlb dtor until allocating vmemmap Date: Tue, 11 Jul 2023 15:09:41 -0700 Message-ID: <20230711220942.43706-2-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711220942.43706-1-mike.kravetz@oracle.com> References: <20230711220942.43706-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW4PR03CA0188.namprd03.prod.outlook.com (2603:10b6:303:b8::13) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|PH0PR10MB4775:EE_ X-MS-Office365-Filtering-Correlation-Id: a0a996e5-c080-4473-f866-08db825b8c4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5mwe7JKbpJf29CNH4kRC8GpUL39E6/bHPjuS+IRvT4WNW6ZoeWBHj888gWBxKLo36lNsRLgXnb2GYtGcV0leQYAz5kTSf0AdFCDE2jXaWrWbo4UhGVHHMkERRiVB/+JtNkL6lPug/ple/sFlBYk+SDPlqHLNOqypzSmdZqvhphnRsVZwCdpTSgMxNZ2w4k07tw1aRoTCr37AfiSxuD4I4lgwDSzLXAbd+VvsoNUOHz7jS4/4rQFvu/7ZuSOtcTx/+Ez+9HA5kKjlaVI/FOHCUbLyuPwWyox2oS/3xwEH1DbSBKEFl4LJ569ShoprQuFPJFuLw6PN99fDjQq3e8t2UsnYPyyJqtO9enkDCLPD+JsZuc/GexPs2MfMYbg1LFw7i1cjIV5/WyFLtQsTpfdk2qyyPvCAxP8PdhtID0cOGKJlwPAzHmGa6zu50E+SLtEZaOXMmzsu/a2lnaInqbYIBil0SA07kYwFls7uLRjgiFq1fuvwTaMunMogqxgiRZRwy7JirLO7Mb1/bT6Bt6grFNK3xdZmXkpCuw3KdO5h+tGlrxd4CRc0BX9WzLuSBK0X 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:(13230028)(376002)(396003)(39860400002)(366004)(346002)(136003)(451199021)(6486002)(186003)(54906003)(86362001)(6666004)(2616005)(478600001)(6506007)(1076003)(26005)(44832011)(7416002)(316002)(36756003)(8936002)(8676002)(41300700001)(5660300002)(83380400001)(6512007)(66476007)(66556008)(66946007)(2906002)(4326008)(38100700002);DI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2GRwgp+m+bWpjn3dTauYzWwTcJSMDL8TKQwTi+2wvG+VwKpFg0oVTfPU0UvbfsiXolY6me/63sSKH7r+HT7ie3HI1DdicJwtJcMq5xTOraPlX3Aztb5BNOLUSnn3Q3bp1bX+fUVS+5XEfeosAF6+QXpVn6439dNMUMQFO2la1QdgjnMtRYQymnk8yA+OaQqRRGXRSpNOlivjzITRmHfEN6z3P4eulj+B/uOykhpcPSu77fKO7ZkNenqQMceutRQgKSLmZLx7/lCYD+JHxpV+UQC+GL2UM41CT5bqBd8FoO2BaByS5R+a897wdGKS24Ml0QxSlKjhyoW9tdTatNEv5dMiS/DJ7Fiwnr7DimCz3CFIpyRBnaBoDocCWXOwH9OVAnaW8axoeSZ2bTRv3yT9nS80YEUP2uAJLJ33+LFZiqWMyXSsQFK2ItQzkxkNTbQIABON9WlkUAHYoLIX67lES3mZBBpy9iSadVcw5+HDx26ifG9/Nw8zw50Ujf/75yM/qMHK8ioJxDSTwHlgrQPl2sPZyUtpFaX1N53kt41c70ZET5C/Jgwj6yFoq9UtfSDQMjX5gPvi0v9Zcw4Ln+U7UZ1Txk5CqA8Zc+wSa+uzNr1EbcoJ2g+5lffzioCwDkomUSzBtuO X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0a996e5-c080-4473-f866-08db825b8c4c X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 22:09:51.1812 (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: akqNV6v6s6FVxxU7PTC58AxW0TXs1Cx9E454OQchD6j01fchQKmgC0BlPiho8rQGmeK6B3RGThQhh74jjN5Jhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4775 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_12,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110202 X-Proofpoint-ORIG-GUID: zQdPaF_yMgoqbdw8IN-rbPkGgq1QEPSK X-Proofpoint-GUID: zQdPaF_yMgoqbdw8IN-rbPkGgq1QEPSK X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 470052001B X-Stat-Signature: 614dau5ccbe4auzbr8dq8krzb8u9ydpp X-Rspam-User: X-HE-Tag: 1689113414-820453 X-HE-Meta: U2FsdGVkX1+SHAz4xuTd4uMkZWwfM/as4uCcywKk+LjZaZObcZB2glVzXWklpEHsd3JC/YXb8hEH3v4DazYbIXS98CpoLJiVFjhjW+fMh9qvLHCs/u8PloOBR3KQhDYJtQ/UaG770ghnPdp0MhnL814st3PvQqxSMaOmyYR9C5K6jrnlPgso8vWdZJa2Alcx420zbm36Rwjml9nV8xCHPqfBq5XnEnvKMSb7i53bM90A3nfZBNYH892CTPMIIKruBpCtn+NZtdr11Vcrk77vCJ7R7p5dRJvGj0osTrCADn2mA/09+wXEbq86hLyfinCOv0qzt6BVceNB9RtfnooKP7LLP21sixyIjkZi8mUxXXaNa00ksl5Ajue6FFQ9eBouyTgS+U/HnVWAmp1iKPdRAcy81xERPiwUolYptzn2HL1YoZ0Ub0uxJFfCxp1v3VQ7dDy/qxZfA4qfKrKaq3LKlqF40BdAZuBPb+6Do6hjjBuVCixFPNyH7IIkFZVF9zmhiotAca/x0i8RupcVcku188U9JDjKdGU0fRGjYGBR2efh1+yddwisIixAGWBh+M0DdnEHvUtproEYMO5ALFihhUL4PPcQSGVCDhMUwjv2iVxGt8mbW9UuJ+/y98gTjRAZwpUWBajnDn00EkKPeVWsnSUjpCIrOP/LUVHD4caR+yZDIRGSjdCZhrKEvekQeYTMxBMY9PlDBg/8SKsOVVFOUEPT5gKiwWykjFSjSL7dZUkqtHsz5+4xetRac/zCMN24s54dcDQ2CiF2AgH5Crps863X2KEjDWWyBm8ELTzLwiZbYOtscD+1KHrQ3iz74aB0Qq5qbqJJIyXmpNVC7LtwaRUgj7JgB9Z6O61BFkFP5SviItdhGfNT92hHWoon7yFpVtaza7JcvU6GV2585BL0fTEx1KDq0pEKLVp5Xx8fnA/v8oZOaLeI0bxbMcTtI5qLDsga1UV6vR4CO2nCTaV 5ChcSFV5 7JGwnO0D0jdxcpaUelOjViTaZPUFkX3K1eTvG/dNPD7Y54iQRueAKWNHSZmebOb55CMmFzjaAWOaHhc4XLRB9v9ukSq0Vm7qkW9YkPncLHS02Xvj1z0CYxlqbvGk617vb3726d5Th3KPuYF7pnYXqqpzIRMwLZpEBJGJReNsNpR87FXbT29DN4lb1gTZOXzCVOv4YxPAsPDYdRp8h5ZM9CyzerWzOvbJRVUau97krn9uzEB+Zn9ezXWc2TSraTgCDsRlnTmN+HRGyf+N9Ul0IbT8sQRxqjBod+5NQ5FvfLk5KmByYmZLS5hMm107nbQYmh3zO9kO5RUISu2iWp5Zz8cQt9SZYNoyffrOxdrGQrs/NdZwB1KhDB3Nxunt0aK/EI3cXJPMa9VNX9VRZxj1IHJKEcJrUOKoyFY4+fedMZB5yweabCbVggrXbtQ== 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: Freeing a hugetlb page and releasing base pages back to the underlying allocator such as buddy or cma is performed in two steps: - remove_hugetlb_folio() is called to remove the folio from hugetlb lists, get a ref on the page and remove hugetlb destructor. This all must be done under the hugetlb lock. After this call, the page can be treated as a normal compound page or a collection of base size pages. - update_and_free_hugetlb_folio() is called to allocate vmemmap if needed and the free routine of the underlying allocator is called on the resulting page. We can not hold the hugetlb lock here. One issue with this scheme is that a memory error could occur between these two steps. In this case, the memory error handling code treats the old hugetlb page as a normal compound page or collection of base pages. It will then try to SetPageHWPoison(page) on the page with an error. If the page with error is a tail page without vmemmap, a write error will occur when trying to set the flag. Address this issue by modifying remove_hugetlb_folio() and update_and_free_hugetlb_folio() such that the hugetlb destructor is not cleared until after allocating vmemmap. Since clearing the destructor requires holding the hugetlb lock, the clearing is done in remove_hugetlb_folio() if the vmemmap is present. This saves a lock/unlock cycle. Otherwise, destructor is cleared in update_and_free_hugetlb_folio() after allocating vmemmap. Note that this will leave hugetlb pages in a state where they are marked free (by hugetlb specific page flag) and have a ref count. This is not a normal state. The only code that would notice is the memory error code, and it is set up to retry in such a case. A subsequent patch will create a routine to do bulk processing of vmemmap allocation. This will eliminate a lock/unlock cycle for each hugetlb page in the case where we are freeing a large number of pages. Fixes: ad2fa3717b74 ("mm: hugetlb: alloc the vmemmap pages associated with each HugeTLB page") Cc: Signed-off-by: Mike Kravetz --- mm/hugetlb.c | 75 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e4a28ce0667f..1b67bf341c32 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1580,9 +1580,37 @@ static inline void destroy_compound_gigantic_folio(struct folio *folio, unsigned int order) { } #endif +static inline void __clear_hugetlb_destructor(struct hstate *h, + struct folio *folio) +{ + lockdep_assert_held(&hugetlb_lock); + + /* + * Very subtle + * + * For non-gigantic pages set the destructor to the normal compound + * page dtor. This is needed in case someone takes an additional + * temporary ref to the page, and freeing is delayed until they drop + * their reference. + * + * For gigantic pages set the destructor to the null dtor. This + * destructor will never be called. Before freeing the gigantic + * page destroy_compound_gigantic_folio will turn the folio into a + * simple group of pages. After this the destructor does not + * apply. + * + */ + if (hstate_is_gigantic(h)) + folio_set_compound_dtor(folio, NULL_COMPOUND_DTOR); + else + folio_set_compound_dtor(folio, COMPOUND_PAGE_DTOR); +} + /* - * Remove hugetlb folio from lists, and update dtor so that the folio appears - * as just a compound page. + * Remove hugetlb folio from lists. + * If vmemmap exists for the folio, update dtor so that the folio appears + * as just a compound page. Otherwise, wait until after allocating vmemmap + * to update dtor. * * A reference is held on the folio, except in the case of demote. * @@ -1613,31 +1641,19 @@ static void __remove_hugetlb_folio(struct hstate *h, struct folio *folio, } /* - * Very subtle - * - * For non-gigantic pages set the destructor to the normal compound - * page dtor. This is needed in case someone takes an additional - * temporary ref to the page, and freeing is delayed until they drop - * their reference. - * - * For gigantic pages set the destructor to the null dtor. This - * destructor will never be called. Before freeing the gigantic - * page destroy_compound_gigantic_folio will turn the folio into a - * simple group of pages. After this the destructor does not - * apply. - * - * This handles the case where more than one ref is held when and - * after update_and_free_hugetlb_folio is called. - * - * In the case of demote we do not ref count the page as it will soon - * be turned into a page of smaller size. + * We can only clear the hugetlb destructor after allocating vmemmap + * pages. Otherwise, someone (memory error handling) may try to write + * to tail struct pages. + */ + if (!folio_test_hugetlb_vmemmap_optimized(folio)) + __clear_hugetlb_destructor(h, folio); + + /* + * In the case of demote we do not ref count the page as it will soon + * be turned into a page of smaller size. */ if (!demote) folio_ref_unfreeze(folio, 1); - if (hstate_is_gigantic(h)) - folio_set_compound_dtor(folio, NULL_COMPOUND_DTOR); - else - folio_set_compound_dtor(folio, COMPOUND_PAGE_DTOR); h->nr_huge_pages--; h->nr_huge_pages_node[nid]--; @@ -1706,6 +1722,7 @@ static void __update_and_free_hugetlb_folio(struct hstate *h, { int i; struct page *subpage; + bool clear_dtor = folio_test_hugetlb_vmemmap_optimized(folio); if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) return; @@ -1736,6 +1753,16 @@ static void __update_and_free_hugetlb_folio(struct hstate *h, if (unlikely(folio_test_hwpoison(folio))) folio_clear_hugetlb_hwpoison(folio); + /* + * If vmemmap pages were allocated above, then we need to clear the + * hugetlb destructor under the hugetlb lock. + */ + if (clear_dtor) { + spin_lock_irq(&hugetlb_lock); + __clear_hugetlb_destructor(h, folio); + spin_unlock_irq(&hugetlb_lock); + } + for (i = 0; i < pages_per_huge_page(h); i++) { subpage = folio_page(folio, i); subpage->flags &= ~(1 << PG_locked | 1 << PG_error |