From patchwork Tue Aug 29 21:37:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13369676 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 EF344C71153 for ; Tue, 29 Aug 2023 21:38:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7408E280017; Tue, 29 Aug 2023 17:38:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F0BE8E0029; Tue, 29 Aug 2023 17:38:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54362280017; Tue, 29 Aug 2023 17:38:05 -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 3DE898E0029 for ; Tue, 29 Aug 2023 17:38:05 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E417D120317 for ; Tue, 29 Aug 2023 21:38:04 +0000 (UTC) X-FDA: 81178455288.19.D850CDE Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf30.hostedemail.com (Postfix) with ESMTP id B567F8001F for ; Tue, 29 Aug 2023 21:38:01 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=jIhRhp7k; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qf+NAwki; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf30.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.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=1693345081; 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=FIBN6YhPsvUwRzPH0L9SXh5tL8FY8pkar6teks6b5sk=; b=OuApeYwzBtih6aBkher5eO4pDc6BzOKn0Yj9sPhcQZZiNKfwRlKOb0fcgOMRYPuEU0mvlu BJaflNkyAWQ5BXczbIhVXii/AZOAkd+h4cuBumlF8lIELpFmVJnQ50kw8HzkhjrTFdEehQ urLAbWRnLdfaBd75Zn6ZGTaSEuRsaeg= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=jIhRhp7k; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qf+NAwki; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf30.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1693345081; a=rsa-sha256; cv=pass; b=u5zWFFCL/t3twAU/TLgS5Q1l5z2bk6uwslILAGhv5aFaOXg9c73chVvCQX0srfdz02tSWe BZlWblIYVt8VVzFbljMEqRgf84UkjsulJWuqn93M3vyhnRrjLqw0lHf7eBedQK/SboMN5o cnF/+yCFYesKI2rxZU8gaWXsIH56OQE= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37TIiemb031375; Tue, 29 Aug 2023 21:37:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=FIBN6YhPsvUwRzPH0L9SXh5tL8FY8pkar6teks6b5sk=; b=jIhRhp7kqKCa61Q+qvvomc3+cKf8QuLqZihpEIATmZhu9y1bpgSAGemIx22PoKwH648t mZIaWssvoIO6bnXVPGDxZ6vBz+cFQsOU4NmwtFrV8alFrMc8l9EJXxh8zKYOCwDghm9x 7Admbpcxp8oMJyZryCEVNsmCHXEHyTnR+5BZUM3G7VLtOL84kOicMU6nl1awabx0qB/D GNgMjz9ahekrDdN4nvNWcj9Pi2DFO0ltPARJTVOzgD9Uxxr/X8E92gkqfnlw/1zOMNeo 4ijpTPJF67HuPZKs0JGhlDdtpA5fjq6xkYNkeGHUU6pX8p0N06siZpBrb9ml6+6Jl14d nQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sq9gcp149-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 21:37:43 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37TKWW9K014286; Tue, 29 Aug 2023 21:37:42 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6hnps93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 21:37:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cNsXUfAXj0/Vd0Etjhyymk530NdTFHd7+OR/NT3IvRVX3YgXh0XphF351bYes3RnN4Hy+FVXGmd0EEhLZfvRs+5Li9ZL1X+c9AvkxRlRk6x8inqPJsXZgrj8DujG9azrdmTiamXTUVY/Q7cck++Ra7fxUKym3Hf/5igYZ1sxlM/CYjchJ6iQCu2Z0IBpYYuF1EGRH0PLlyMKKMMCqBvQDOtN/8ZZEulHzq7Jur1v3dXuRnCE7wcQlMm26Hrv3HI1S+RpzFK2hX//MgA45CWisaIYC7e4UrO/M5AN0MXhzqf736ZzA/ZF0nWoeLgZ5bX42RJxLCoHcu/Ry6IxEQL/4Q== 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=Wpcj+koXyNXyx0a6OzUdv+xosxuyG6p4dcdPnMmVunoQyn5OZrpuX9zbfTIur+BTaLKo7yLBVkre6rEUoILjbuUUlzzFQqDxMo/FNz5/ZsfeNK/nVu0GH9DQwlGWndaif4/xlvwRtcIk/l10hVNCLRMyuqB1aeBKlFU/hMxFBn7i18X0NpdPll6Y70VaYNyYeeAsAJbBVNg9hSwnbNciOxSTYgtG1dn0l0s/DjAK1kttv7YK92R8pQa3GioOKpq9BV1GsFa973RzVD2P3QVIU0AkzWW8J+YUXEA1ertCzk06KtWjrPRwtoONukgrZ8ZvnC4+JK6SpmdlZUS57v32MQ== 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=qf+NAwkioOmWl0B7cUJPH7DiqBDD3m+SeE6Pk5YZ688gyf9lR80xxLMXMK+9S2Mtj62k4r0eRfY6prWHXsyfRpk1E1jZEGKt+zkUiONCu7E8t7dA4+9bWmd3mf6svF9gpGY9BPZAruxZawC3pa2eNyInlTEnyk5BOOeqVNOgz2w= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by MW6PR10MB7640.namprd10.prod.outlook.com (2603:10b6:303:245::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Tue, 29 Aug 2023 21:37:39 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::92ea:33e7:fb66:c937]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::92ea:33e7:fb66:c937%7]) with mapi id 15.20.6699.035; Tue, 29 Aug 2023 21:37:39 +0000 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Muchun Song , Naoya Horiguchi , Usama Arif , Miaohe Lin , James Houghton , Michal Hocko , Andrew Morton , Mike Kravetz Subject: [PATCH] hugetlb: set hugetlb page flag before optimizing vmemmap Date: Tue, 29 Aug 2023 14:37:34 -0700 Message-ID: <20230829213734.69673-1-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.41.0 X-ClientProxiedBy: MW4PR03CA0141.namprd03.prod.outlook.com (2603:10b6:303:8c::26) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|MW6PR10MB7640:EE_ X-MS-Office365-Filtering-Correlation-Id: f70240da-6e31-4ceb-68de-08dba8d82af8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e2c60XIzweOSz/O7KweT1ZTcNWCMLDESghDCeexWo7+SJSRkDBYSUmGr3cnPGe+6oYx2q242DKZlM+oN/ovZa8Odu9PyskvGd7Y5XIacTeR35EOHzfC7OTCfxuXpij2r8ZyzgMNp/87ONuROusUO+wjgsbVMB2ce5BP0cY947nAyM6n05RclO5XMwhrDPgodKGTGk49FoZZDZfNVVjsTrf4+qgm1v0SKt1NdmdBR0z6DwlPH0m5BUiuO+Mpir7GMj/rjyFBHuSzPwk4ysFwZCwvFR0UxZh9tpsAsOZwKYJ5FR0zGK9yK4tuYRQ9fDKVp93nbTwQ2jqsTwVCPhPLEhufRfMN/sRgMdbgAgkxm9VNX+4ucg0Qmu6I9Gu43eGvFBB1xD5Pk7PtRefZ85MgpBxoe/08r58Ojud8Sn0CzsoVyeho+fUmVrfypPwVjD9pKBJnr0AnbesIUKk+5CieiQIj7QmoQKYM86ZIowKKfphex1DRd+KbqsQoLHGp2haraWP/u+zZ0WS7E18qy39D6vkiG7e47Y6JeJiKeQg5wG45NgLSRewh6jVOYpW/hk3My 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(1800799009)(186009)(451199024)(6666004)(6512007)(6486002)(6506007)(83380400001)(26005)(2906002)(1076003)(478600001)(107886003)(316002)(41300700001)(54906003)(4326008)(66556008)(66476007)(66946007)(5660300002)(8936002)(44832011)(8676002)(36756003)(86362001)(2616005)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ssFO1zVbx5s/Mi++bSzlV2o/WXIrhPJXh0PPXjetclNukdB12IR6NIIcP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QMHIxim+UHWyAA4hfkZ5xchqQv2fB10NUGRAZsCk8+MAvOWFVT171fZgD4Hla1+FtU97yd/vdjo3WXmPT3B/31IsFgfADlqZDXF/Kj1mu9pC8iV5/bxn1v/ZLr4AM5Y/3qd8uqK3jm1FmEuTn49JZTDGbTdNdZ1AjD70PjmVISmyoMyxKdyhSSZSRYSj3XG/dsFEhpYq2tDq7fYPKuMsmDYlpSyVzy3BiF4qqS26C3g8WcsAdVH9qLCpXkZkZi3dxT0GBDMlEfwYDnDch7GfDQScWceCzgUZ+8I9LP/mk92g/a9E3lXK0VISq10o9zY80DZw7bixO9avZoSfBytKP7q1ZEn7AsH5j1fcjA8luG4rbWsggqWDRrmyd+D2Qgmg3kzjzturuDrbkBH/bAahb+aYgcpaRwVvL+uasubmLBEedRISlER+WV/Y9jkl5tB57BkCSCwRROtaFcDWzu3g= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f70240da-6e31-4ceb-68de-08dba8d82af8 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 21:37:39.2575 (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: oNEoO16+TnVyKZvbsEfylSgEGCqiAbCHbCRuXXhDKFdtW1pDgFqL+f9CUEcH0PKTYXCKtTR0h8DVa+BsEKX7PA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR10MB7640 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-08-29_15,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290186 X-Proofpoint-ORIG-GUID: Po97OXFQ295PCcXRWY215wcGsbgK0sRP X-Proofpoint-GUID: Po97OXFQ295PCcXRWY215wcGsbgK0sRP X-Rspamd-Queue-Id: B567F8001F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: y5x8hpm4q6wcobgi88ktd33gkamu439k X-HE-Tag: 1693345081-172454 X-HE-Meta: U2FsdGVkX1/J/tzNDibbCDdBN+QI8dZojs7T8jsmb2pL/oIRhOS2wdKODyhYfykH9LKNY9cjYxStkP1K5cLU/g9kNpKj/dYrOlbvrLPDrK+eKwIGScdNIBvQj/eDuvABYbo3plK25v95GsE4Gdz4zVxBjMKZvERUT3OzzuBYbGXDR6lt8ET72ZCpEg3BQyE+SfFrqZT15J6OGeZXGFlV8nApg7W4+kPhaKQXkIzSoRWvXwtweh3jar7wPNMhcJSFKJ9ARrjsn5ZyfOjeWJsHJudL5RgHyMWpMzUB827SwRUSP+afyDhONHQHPZWOJ60UQT8ts8ub78YONysJfYL/NaXnFBQwKj7gloY9ij7rHas3iRwjPYCvmScF+KJ3aLFikjVxL1Lur+1w/0MUcpx1yBfQQgBTSrCBELyHjIFDeuz7e02bPspUbek5GJJJyeC2jKNsDfKQHzObxpbydUpMAdbBeBDkpBNgZQnAoe667bjcFIYaJexSawxNFF00clrXiX473dFrqSoDva4VcCve+wUmeggVq2nACEuw/YH5YiSCGx1ktGdH4Jt5CXu5aT5m5dUk/7qGIUuBEs0Q94/fJv0hwcom4WodKJ0bWnmh4iteKloCI1TJeH1lB+OwKXweQSEEI60TL3CYkgyuKAkbsaonvv3cpJxef8M1XYh/FOZWuTLvNgCAkzy04P38EZtE0XC7qTkEjhtC60PCNP95LhuAoiQTaHtHakJcyabolgASpBlVYnmzm7xn1vcky+SK8JyDNwh5LGrk2mgYbt4DG7B7pF+891gUNiRlGpT5DPzrQLlwMEFSGZVu4x+v8Vty2emxX/UJdGNQhdSd5drOqQ2rmKuKs8IHUSTat+VsK5jvgICElti6agUCoiPFaIHJwZFiEwLxKnws6GQYuzIuBSEcm5rwVIIQiOxU/PZuBdQpl2kufdPVYfrEkfiKuanC6/blyjy7g43214KzZPD P4BcTHni yFF2ubzUQQNgSByhXjuMF5GuRDgffQ4Es+EfSLQZ69xROBBykAbB8F66J7mfzULfEM9t0QTgRxxF4AWU1tZMQG9jokpXocuAbzhY8OXuU9gfZuMosF2H1vOmsSuFICdOFzcU4w4YpTCp5e2uREM5Azrmg/FgYfCe8tpQqTdg1CkU7uCe7nQh2S7CCONNIBXyTBnEbn4l5qSxvgEIJqttDdkqOKfWu/JWnxXjdqDe58UUgrzm+88SLZ2ohrtOMf62C0NqGP/2apbMRePy5pLNK8FuSjRJAoOEouHw7DfvypPs55nPsEDJP5yYeY1kH6ESP5Mkf8K7TN5Ms+HbRPAPNSt+XSI18I991PT4sPPomb/cicjx78vqV6cdyJAc2bHJL07bOhOBeSiX41aRsoSstGZMKjlrEH5FqNic1GO/8ooih/zJQY8Jt0SHHjkoQZZnP14YZx0lSx9awBeBNb6bu9ez6lSruaDVgP4OfoFJIMWyLDUoGmorSAJ9OGUhjjAKxKLn/oAcf1FX3MSk2DRYZ+S/teMoB+PJppwPfvw7xjvwR0fY= 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 Reviewed-by: Muchun Song --- 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;