get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.2/patches/2219953/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2219953,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/2219953/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260405125240.2558577-29-songmuchun@bytedance.com/",
    "project": {
        "id": 2,
        "url": "http://patchwork.ozlabs.org/api/1.2/projects/2/?format=api",
        "name": "Linux PPC development",
        "link_name": "linuxppc-dev",
        "list_id": "linuxppc-dev.lists.ozlabs.org",
        "list_email": "linuxppc-dev@lists.ozlabs.org",
        "web_url": "https://github.com/linuxppc/wiki/wiki",
        "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git",
        "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/",
        "list_archive_url": "https://lore.kernel.org/linuxppc-dev/",
        "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/",
        "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"
    },
    "msgid": "<20260405125240.2558577-29-songmuchun@bytedance.com>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20260405125240.2558577-29-songmuchun@bytedance.com/",
    "date": "2026-04-05T12:52:19",
    "name": "[28/49] mm/hugetlb: switch HugeTLB to use generic vmemmap optimization",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "58704e2329ca640b03651b46bf43603ca9fe2002",
    "submitter": {
        "id": 78930,
        "url": "http://patchwork.ozlabs.org/api/1.2/people/78930/?format=api",
        "name": "Muchun Song",
        "email": "songmuchun@bytedance.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260405125240.2558577-29-songmuchun@bytedance.com/mbox/",
    "series": [
        {
            "id": 498783,
            "url": "http://patchwork.ozlabs.org/api/1.2/series/498783/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=498783",
            "date": "2026-04-05T12:51:51",
            "name": "mm: Generalize vmemmap optimization for DAX and HugeTLB",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/498783/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2219953/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2219953/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linuxppc-dev+bounces-19358-incoming=patchwork.ozlabs.org@lists.ozlabs.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "linuxppc-dev@lists.ozlabs.org"
        ],
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=bytedance.com header.i=@bytedance.com\n header.a=rsa-sha256 header.s=google header.b=P8bHFICq;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19358-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)",
            "lists.ozlabs.org;\n arc=none smtp.remote-ip=\"2607:f8b0:4864:20::102d\"",
            "lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=bytedance.com",
            "lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=bytedance.com header.i=@bytedance.com\n header.a=rsa-sha256 header.s=google header.b=P8bHFICq;\n\tdkim-atps=neutral",
            "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=bytedance.com\n (client-ip=2607:f8b0:4864:20::102d; helo=mail-pj1-x102d.google.com;\n envelope-from=songmuchun@bytedance.com; receiver=lists.ozlabs.org)"
        ],
        "Received": [
            "from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fpXXS1DxXz1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 22:56:40 +1000 (AEST)",
            "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fpXXF22llz2yv4;\n\tSun, 05 Apr 2026 22:56:29 +1000 (AEST)",
            "from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com\n [IPv6:2607:f8b0:4864:20::102d])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4fpXXD1xwGz2ynH\n\tfor <linuxppc-dev@lists.ozlabs.org>; Sun, 05 Apr 2026 22:56:28 +1000 (AEST)",
            "by mail-pj1-x102d.google.com with SMTP id\n 98e67ed59e1d1-35d965648a2so2429616a91.0\n        for <linuxppc-dev@lists.ozlabs.org>;\n Sun, 05 Apr 2026 05:56:28 -0700 (PDT)",
            "from n232-176-004.byted.org ([36.110.163.97])\n        by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-35de66b4808sm3748505a91.2.2026.04.05.05.56.20\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Sun, 05 Apr 2026 05:56:26 -0700 (PDT)"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775393789;\n\tcv=none;\n b=nCZSvCDdlIdtdS69ldn0Pe32UrSjFFY8aBXjIYp0z29UIHbs2LSCOBJGr/Oj6MMV+3QVWGgO5ppDXLUwK5sCvOzKr2N6qroUITGC8NpxGndSIzrZQYQ3Eey4h47/mc2uF0YjMViAorx7MWqv2I96lk0Bscx1YLL04WQCp2l/lfTrKZEpLTwy8qKOv79XIyALqfcoznWlWD6zZCZFug11oYqJB69xYZhmCPbk0ICuhsy8JkmmA22Zg0y27AYi3LkxIFNJSpEmm6fA8jzWpcuEsu4eRNJBe4R2S8J7Ak9dKgjGG/oMfMGVWK4ZrAgidNHKzrEzGNMNl06P3z38ftuJdw==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1775393789; c=relaxed/relaxed;\n\tbh=awaFXPFMYUbrBte65uesX1HHeaiEoqtP90DsGctc43A=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=k2vmzqNR2uShxVl5CHS+U3V/IwfAoj5lJEgYzSFtUHYACWm2z7tukYtARXg8Dig+CNw8+6M8wpkRwu53Dg8xmzRsghFV5yxpd6I7hISqwIDLKgUCJjZgU3WBSO8yZOzlsP3bh1ldDFtteHRawdRazGKhhsUH2xjhjY6wNsa5rKgV4MRqoWhNJo5OHE6/m2nPQUZzM7x71LkGLvq+8SunyJo2qON5q9wV5++pAIBxtKZk5CTS1s2UzMqRMgfxOnD5WwrykK5bEYmTm0EUSDnTVTuBniW0QsRmvJtzpBj3A77shjJQ5tlYMteXX00iKLJiR5F7Ov1o/nduyUptlj+iDg==",
        "ARC-Authentication-Results": "i=1; lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=bytedance.com;\n dkim=pass (2048-bit key;\n unprotected) header.d=bytedance.com header.i=@bytedance.com\n header.a=rsa-sha256 header.s=google header.b=P8bHFICq; dkim-atps=neutral;\n spf=pass (client-ip=2607:f8b0:4864:20::102d; helo=mail-pj1-x102d.google.com;\n envelope-from=songmuchun@bytedance.com;\n receiver=lists.ozlabs.org) smtp.mailfrom=bytedance.com",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=bytedance.com; s=google; t=1775393786; x=1775998586;\n darn=lists.ozlabs.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=awaFXPFMYUbrBte65uesX1HHeaiEoqtP90DsGctc43A=;\n        b=P8bHFICq1YpSes/Vu1wDrfie3oCQ+1tHcssX1TZ1Xh7lS8QOphAZlZzpe3dAZkziy4\n         RfQdAyvCeznqbjYuViyiJFF4U5JS1G8ME+V3n2mEvJTPeSZLgzp6mtT1Pk5vW5PSJjpx\n         F3GQ4O2FmMhB4rndwX6v4CeI/5KIiY+W88zwshHMFhIHSob6B0YWBYDVuI7cjozRQxI6\n         3yMVbfnkS264tD23K0AOhPuaOjIF8A6z9mnbXyj/0bR2An3ZNHHdQPY30dwYIbIgSni5\n         RXXeMs4gx5pYlZMmNS/13+A9+thWazQ8iTMzsPOP71v9gAoHDGHcFvOAz+R+8+QL0dN+\n         9Gvg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1775393786; x=1775998586;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=awaFXPFMYUbrBte65uesX1HHeaiEoqtP90DsGctc43A=;\n        b=kAPEZ39c2wEMVlyqtOvKg8edMQQ9O2PQ84CMzNxc42gXY6+WouFtfgR2nzYRrUgPuc\n         gWNU4XynW+Aqi9BAIAaulHlcLpaZwDkOM/8/jdXQOx/DTbwarUGJsFrBO0ziVUnu1GCp\n         pyEyyK3rjqI6aOibm6wxm+Hu5BSLJyyhE5fiGeLFp8ZcoyvDGkxG7PQZNcwo7aMh5vJN\n         JqvP1gD9FmPbPucl1YeCAteDBwRLRh8igQxv9ZxGiGy2SWuL4Nwp4FAA79dWm4PoXQvm\n         x27qLaC05H7netIj8W47fDfubtrSo/1mIOGpzwR+3nRRQ7sLifYQClOjSCXXau43RFWt\n         QYuQ==",
        "X-Forwarded-Encrypted": "i=1;\n AJvYcCVusuQbb8Ca5RlnLylSM5Vot8aITU/DLxDWXLCo1N2FLbhz0P3ADXvZMcqs40SoNvUFnJ6DV8HhBTv17zs=@lists.ozlabs.org",
        "X-Gm-Message-State": "AOJu0YxWuStMTbm1atLlutf/oagKk/oEtd70deOs69BkSRL/2+s4iEcR\n\t2TXyt7OlewItBWcsnsIVLvFWcsg/7iUo+Tp/rEI9Brhr2DvE6OxGXm9K1DlqAmq+DAM=",
        "X-Gm-Gg": "AeBDiesoRwzjuUyY5NRyfmbBW1gTkRCHlhGkvWeiexfkqRNYb2E+FFiCbAIoLoIvBUx\n\t7arzYSjonb115XcSTwHxFMFshGL91d5NqO3xClZIIj0kln2PfLfjcvXg4lf8dWZTvcPst81uXSe\n\tBwem4pWV9rOHm9NSIp4AspkNotO2lgP0d3O4udluSHg+HHFiBrG/UW93vy9Vrbnt3DSOExbRSQ9\n\t740/Qisyu75nOLO7ZFXz+ujrRt7wZIO1PgAHEISnOM1I1XvLM93/drLqHFKBLo2oisUt9uoQ9U8\n\tErWT+p+nKgBnoRuswNyCG/a/9WuFMyMPmX9uHSGgy4mgJqXyakUmTWgzn/PKao542mPu2PUzoWr\n\tgMefbz+tYEIucgqf05+8xiZN9DW2yA1Hvb1sRsLQuzbUxUOuWHWi0Xv6xZDlWYhhAvNFCmxjUTL\n\tqU3/K8PNY3PTwBvxFtzxVD2wHjKb1QDlFyQr8s2DzkvupHwIU5ct0c0g==",
        "X-Received": "by 2002:a17:90b:3811:b0:359:1130:1047 with SMTP id\n 98e67ed59e1d1-35de68ebf53mr9391600a91.17.1775393786359;\n        Sun, 05 Apr 2026 05:56:26 -0700 (PDT)",
        "From": "Muchun Song <songmuchun@bytedance.com>",
        "To": "Andrew Morton <akpm@linux-foundation.org>,\n\tDavid Hildenbrand <david@kernel.org>,\n\tMuchun Song <muchun.song@linux.dev>,\n\tOscar Salvador <osalvador@suse.de>,\n\tMichael Ellerman <mpe@ellerman.id.au>,\n\tMadhavan Srinivasan <maddy@linux.ibm.com>",
        "Cc": "Lorenzo Stoakes <ljs@kernel.org>,\n\t\"Liam R . Howlett\" <Liam.Howlett@oracle.com>,\n\tVlastimil Babka <vbabka@kernel.org>,\n\tMike Rapoport <rppt@kernel.org>,\n\tSuren Baghdasaryan <surenb@google.com>,\n\tMichal Hocko <mhocko@suse.com>,\n\tNicholas Piggin <npiggin@gmail.com>,\n\tChristophe Leroy <chleroy@kernel.org>,\n\taneesh.kumar@linux.ibm.com,\n\tjoao.m.martins@oracle.com,\n\tlinux-mm@kvack.org,\n\tlinuxppc-dev@lists.ozlabs.org,\n\tlinux-kernel@vger.kernel.org,\n\tMuchun Song <songmuchun@bytedance.com>",
        "Subject": "[PATCH 28/49] mm/hugetlb: switch HugeTLB to use generic vmemmap\n optimization",
        "Date": "Sun,  5 Apr 2026 20:52:19 +0800",
        "Message-Id": "<20260405125240.2558577-29-songmuchun@bytedance.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20260405125240.2558577-1-songmuchun@bytedance.com>",
        "References": "<20260405125240.2558577-1-songmuchun@bytedance.com>",
        "X-Mailing-List": "linuxppc-dev@lists.ozlabs.org",
        "List-Id": "<linuxppc-dev.lists.ozlabs.org>",
        "List-Help": "<mailto:linuxppc-dev+help@lists.ozlabs.org>",
        "List-Owner": "<mailto:linuxppc-dev+owner@lists.ozlabs.org>",
        "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>",
        "List-Archive": "<https://lore.kernel.org/linuxppc-dev/>,\n  <https://lists.ozlabs.org/pipermail/linuxppc-dev/>",
        "List-Subscribe": "<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>",
        "List-Unsubscribe": "<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>",
        "Precedence": "list",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Spam-Status": "No, score=-0.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID,\n\tDKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS\n\tautolearn=disabled version=4.0.1 OzLabs 8",
        "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"
    },
    "content": "Switch the HugeTLB vmemmap optimization to use the new infrastructure\nintroduced in the previous patches (specifically, the compound page\nsupport in sparse-vmemmap).\n\nPreviously, optimizing bootmem HugeTLB pages required dedicated and\ncomplex pre-initialization logic, such as hugetlb_vmemmap_init_early()\nand vmemmap_populate_hvo(). This approach manually handled page mapping\nand initialization at a very early stage.\n\nThis patch removes all those special-cased functions and simply calls\nhugetlb_vmemmap_optimize_bootmem_page() directly from alloc_bootmem().\nBy explicitly setting the compound page order in the mem_section\n(via section_set_order), the generic sparse-vmemmap initialization code\nwill now automatically handle the shared tail page mapping for these\nbootmem pages.\n\nThis significantly simplifies the code, eliminates duplicate logic, and\nseamlessly integrates bootmem vmemmap optimization with the generic\nvmemmap optimization flow.\n\nSigned-off-by: Muchun Song <songmuchun@bytedance.com>\n---\n include/linux/mm.h     |   3 -\n include/linux/mmzone.h |  13 +++++\n mm/bootmem_info.c      |   5 +-\n mm/hugetlb.c           |   8 ++-\n mm/hugetlb_vmemmap.c   | 121 +++--------------------------------------\n mm/hugetlb_vmemmap.h   |  11 ++--\n mm/sparse-vmemmap.c    |  29 ----------\n 7 files changed, 32 insertions(+), 158 deletions(-)",
    "diff": "diff --git a/include/linux/mm.h b/include/linux/mm.h\nindex aa8c05de7585..93e447468131 100644\n--- a/include/linux/mm.h\n+++ b/include/linux/mm.h\n@@ -4877,9 +4877,6 @@ int vmemmap_populate_hugepages(unsigned long start, unsigned long end,\n \t\t\t       struct dev_pagemap *pgmap);\n int vmemmap_populate(unsigned long start, unsigned long end, int node,\n \t\tstruct vmem_altmap *altmap, struct dev_pagemap *pgmap);\n-int vmemmap_populate_hvo(unsigned long start, unsigned long end,\n-\t\t\t unsigned int order, struct zone *zone,\n-\t\t\t unsigned long headsize);\n void vmemmap_wrprotect_hvo(unsigned long start, unsigned long end, int node,\n \t\t\t  unsigned long headsize);\n void vmemmap_populate_print_last(void);\ndiff --git a/include/linux/mmzone.h b/include/linux/mmzone.h\nindex e4d37492ca63..0bd20efac427 100644\n--- a/include/linux/mmzone.h\n+++ b/include/linux/mmzone.h\n@@ -2250,6 +2250,19 @@ static inline unsigned int section_order(const struct mem_section *section)\n }\n #endif\n \n+static inline void section_set_order_pfn_range(unsigned long pfn,\n+\t\t\t\t\t       unsigned long nr_pages,\n+\t\t\t\t\t       unsigned int order)\n+{\n+\tunsigned long section_nr = pfn_to_section_nr(pfn);\n+\n+\tif (!IS_ALIGNED(pfn | nr_pages, PAGES_PER_SECTION))\n+\t\treturn;\n+\n+\tfor (int i = 0; i < nr_pages / PAGES_PER_SECTION; i++)\n+\t\tsection_set_order(__nr_to_section(section_nr + i), order);\n+}\n+\n static inline bool section_vmemmap_optimizable(const struct mem_section *section)\n {\n \treturn is_power_of_2(sizeof(struct page)) &&\ndiff --git a/mm/bootmem_info.c b/mm/bootmem_info.c\nindex 3d7675a3ae04..24f45d86ffb3 100644\n--- a/mm/bootmem_info.c\n+++ b/mm/bootmem_info.c\n@@ -51,9 +51,8 @@ static void __init register_page_bootmem_info_section(unsigned long start_pfn)\n \tsection_nr = pfn_to_section_nr(start_pfn);\n \tms = __nr_to_section(section_nr);\n \n-\tif (!preinited_vmemmap_section(ms))\n-\t\tregister_page_bootmem_memmap(section_nr, pfn_to_page(start_pfn),\n-\t\t\t\t\t     PAGES_PER_SECTION);\n+\tregister_page_bootmem_memmap(section_nr, pfn_to_page(start_pfn),\n+\t\t\t\t     PAGES_PER_SECTION);\n \n \tusage = ms->usage;\n \tpage = virt_to_page(usage);\ndiff --git a/mm/hugetlb.c b/mm/hugetlb.c\nindex a7e0599802cb..dff94ab7040a 100644\n--- a/mm/hugetlb.c\n+++ b/mm/hugetlb.c\n@@ -3096,6 +3096,7 @@ static __init void *alloc_bootmem(struct hstate *h, int nid, bool node_exact)\n \t\t * is not up yet.\n \t\t */\n \t\tINIT_LIST_HEAD(&m->list);\n+\t\tm->hstate = h;\n \t\tif (pfn_range_intersects_zones(listnode, PHYS_PFN(virt_to_phys(m)),\n \t\t\t\t\t       pages_per_huge_page(h))) {\n \t\t\tVM_BUG_ON(hugetlb_bootmem_page_earlycma(m));\n@@ -3103,8 +3104,8 @@ static __init void *alloc_bootmem(struct hstate *h, int nid, bool node_exact)\n \t\t} else {\n \t\t\tlist_add_tail(&m->list, &huge_boot_pages[listnode]);\n \t\t\tm->flags |= HUGE_BOOTMEM_ZONES_VALID;\n+\t\t\thugetlb_vmemmap_optimize_bootmem_page(m);\n \t\t}\n-\t\tm->hstate = h;\n \t}\n \n \treturn m;\n@@ -3283,13 +3284,16 @@ static void __init gather_bootmem_prealloc_node(unsigned long nid)\n \t\t\t\t\t   OPTIMIZED_FOLIO_VMEMMAP_PAGE_STRUCTS);\n \t\tinit_new_hugetlb_folio(folio);\n \n-\t\tif (hugetlb_bootmem_page_prehvo(m))\n+\t\tif (hugetlb_bootmem_page_prehvo(m)) {\n \t\t\t/*\n \t\t\t * If pre-HVO was done, just set the\n \t\t\t * flag, the HVO code will then skip\n \t\t\t * this folio.\n \t\t\t */\n \t\t\tfolio_set_hugetlb_vmemmap_optimized(folio);\n+\t\t\tsection_set_order_pfn_range(folio_pfn(folio),\n+\t\t\t\t\t\t    pages_per_huge_page(h), 0);\n+\t\t}\n \n \t\tif (hugetlb_bootmem_page_earlycma(m))\n \t\t\tfolio_set_hugetlb_cma(folio);\ndiff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c\nindex 0af528c0e229..8c567b8c67cc 100644\n--- a/mm/hugetlb_vmemmap.c\n+++ b/mm/hugetlb_vmemmap.c\n@@ -638,9 +638,6 @@ static void __hugetlb_vmemmap_optimize_folios(struct hstate *h,\n \t\t\tepfn = spfn + pages_per_huge_page(h);\n \t\t\tvmemmap_wrprotect_hvo(spfn, epfn, folio_nid(folio),\n \t\t\t\t\tOPTIMIZED_FOLIO_VMEMMAP_SIZE);\n-\t\t\tregister_page_bootmem_memmap(pfn_to_section_nr(spfn),\n-\t\t\t\t\t&folio->page,\n-\t\t\t\t\tOPTIMIZED_FOLIO_VMEMMAP_SIZE);\n \t\t\tcontinue;\n \t\t}\n \n@@ -706,108 +703,21 @@ void hugetlb_vmemmap_optimize_bootmem_folios(struct hstate *h, struct list_head\n \t__hugetlb_vmemmap_optimize_folios(h, folio_list, true);\n }\n \n-#ifdef CONFIG_SPARSEMEM_VMEMMAP_PREINIT\n-\n-/* Return true of a bootmem allocated HugeTLB page should be pre-HVO-ed */\n-static bool vmemmap_should_optimize_bootmem_page(struct huge_bootmem_page *m)\n-{\n-\tunsigned long section_size, psize, pmd_vmemmap_size;\n-\tphys_addr_t paddr;\n-\n-\tif (!READ_ONCE(vmemmap_optimize_enabled))\n-\t\treturn false;\n-\n-\tif (!hugetlb_vmemmap_optimizable(m->hstate))\n-\t\treturn false;\n-\n-\tpsize = huge_page_size(m->hstate);\n-\tpaddr = virt_to_phys(m);\n-\n-\t/*\n-\t * Pre-HVO only works if the bootmem huge page\n-\t * is aligned to the section size.\n-\t */\n-\tsection_size = (1UL << PA_SECTION_SHIFT);\n-\tif (!IS_ALIGNED(paddr, section_size) ||\n-\t    !IS_ALIGNED(psize, section_size))\n-\t\treturn false;\n-\n-\t/*\n-\t * The pre-HVO code does not deal with splitting PMDS,\n-\t * so the bootmem page must be aligned to the number\n-\t * of base pages that can be mapped with one vmemmap PMD.\n-\t */\n-\tpmd_vmemmap_size = (PMD_SIZE / (sizeof(struct page))) << PAGE_SHIFT;\n-\tif (!IS_ALIGNED(paddr, pmd_vmemmap_size) ||\n-\t    !IS_ALIGNED(psize, pmd_vmemmap_size))\n-\t\treturn false;\n-\n-\treturn true;\n-}\n-\n-static struct zone *pfn_to_zone(unsigned nid, unsigned long pfn)\n+void __init hugetlb_vmemmap_optimize_bootmem_page(struct huge_bootmem_page *m)\n {\n-\tstruct zone *zone;\n-\tenum zone_type zone_type;\n-\n-\tfor (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++) {\n-\t\tzone = &NODE_DATA(nid)->node_zones[zone_type];\n-\t\tif (zone_spans_pfn(zone, pfn))\n-\t\t\treturn zone;\n-\t}\n-\n-\treturn NULL;\n-}\n-\n-/*\n- * Initialize memmap section for a gigantic page, HVO-style.\n- */\n-void __init hugetlb_vmemmap_init_early(int nid)\n-{\n-\tunsigned long psize, paddr, section_size;\n-\tunsigned long ns, i, pnum, pfn, nr_pages;\n-\tunsigned long start, end;\n-\tstruct huge_bootmem_page *m = NULL;\n-\tvoid *map;\n+\tstruct hstate *h = m->hstate;\n+\tunsigned long pfn = PHYS_PFN(virt_to_phys(m));\n \n \tif (!READ_ONCE(vmemmap_optimize_enabled))\n \t\treturn;\n \n-\tsection_size = (1UL << PA_SECTION_SHIFT);\n-\n-\tlist_for_each_entry(m, &huge_boot_pages[nid], list) {\n-\t\tstruct zone *zone;\n-\n-\t\tif (!vmemmap_should_optimize_bootmem_page(m))\n-\t\t\tcontinue;\n-\n-\t\tnr_pages = pages_per_huge_page(m->hstate);\n-\t\tpsize = nr_pages << PAGE_SHIFT;\n-\t\tpaddr = virt_to_phys(m);\n-\t\tpfn = PHYS_PFN(paddr);\n-\t\tmap = pfn_to_page(pfn);\n-\t\tstart = (unsigned long)map;\n-\t\tend = start + nr_pages * sizeof(struct page);\n-\t\tzone = pfn_to_zone(nid, pfn);\n-\n-\t\tBUG_ON(vmemmap_populate_hvo(start, end, huge_page_order(m->hstate),\n-\t\t\t\t\t    zone, OPTIMIZED_FOLIO_VMEMMAP_SIZE));\n-\t\tmemmap_boot_pages_add(OPTIMIZED_FOLIO_VMEMMAP_PAGES);\n-\n-\t\tpnum = pfn_to_section_nr(pfn);\n-\t\tns = psize / section_size;\n-\n-\t\tfor (i = 0; i < ns; i++) {\n-\t\t\tsparse_init_early_section(nid, map, pnum,\n-\t\t\t\t\tSECTION_IS_VMEMMAP_PREINIT);\n-\t\t\tmap += section_map_size();\n-\t\t\tpnum++;\n-\t\t}\n+\tif (!hugetlb_vmemmap_optimizable(h))\n+\t\treturn;\n \n+\tsection_set_order_pfn_range(pfn, pages_per_huge_page(h), huge_page_order(h));\n+\tif (section_vmemmap_optimizable(__pfn_to_section(pfn)))\n \t\tm->flags |= HUGE_BOOTMEM_HVO;\n-\t}\n }\n-#endif\n \n static const struct ctl_table hugetlb_vmemmap_sysctls[] = {\n \t{\n@@ -822,27 +732,10 @@ static const struct ctl_table hugetlb_vmemmap_sysctls[] = {\n static int __init hugetlb_vmemmap_init(void)\n {\n \tconst struct hstate *h;\n-\tstruct zone *zone;\n \n \t/* OPTIMIZED_FOLIO_VMEMMAP_SIZE should cover all used struct pages */\n \tBUILD_BUG_ON(__NR_USED_SUBPAGE > OPTIMIZED_FOLIO_VMEMMAP_PAGE_STRUCTS);\n \n-\tfor_each_zone(zone) {\n-\t\tfor (int i = 0; i < NR_OPTIMIZABLE_FOLIO_SIZES; i++) {\n-\t\t\tstruct page *tail, *p;\n-\t\t\tunsigned int order;\n-\n-\t\t\ttail = zone->vmemmap_tails[i];\n-\t\t\tif (!tail)\n-\t\t\t\tcontinue;\n-\n-\t\t\torder = i + OPTIMIZABLE_FOLIO_MIN_ORDER;\n-\t\t\tp = page_to_virt(tail);\n-\t\t\tfor (int j = 0; j < PAGE_SIZE / sizeof(struct page); j++)\n-\t\t\t\tinit_compound_tail(p + j, NULL, order, zone);\n-\t\t}\n-\t}\n-\n \tfor_each_hstate(h) {\n \t\tif (hugetlb_vmemmap_optimizable(h)) {\n \t\t\tregister_sysctl_init(\"vm\", hugetlb_vmemmap_sysctls);\ndiff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h\nindex 66e11893d076..ff8e4c6e9833 100644\n--- a/mm/hugetlb_vmemmap.h\n+++ b/mm/hugetlb_vmemmap.h\n@@ -20,10 +20,7 @@ long hugetlb_vmemmap_restore_folios(const struct hstate *h,\n void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct folio *folio);\n void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_list);\n void hugetlb_vmemmap_optimize_bootmem_folios(struct hstate *h, struct list_head *folio_list);\n-#ifdef CONFIG_SPARSEMEM_VMEMMAP_PREINIT\n-void hugetlb_vmemmap_init_early(int nid);\n-#endif\n-\n+void hugetlb_vmemmap_optimize_bootmem_page(struct huge_bootmem_page *m);\n \n static inline unsigned int hugetlb_vmemmap_size(const struct hstate *h)\n {\n@@ -69,13 +66,13 @@ static inline void hugetlb_vmemmap_optimize_bootmem_folios(struct hstate *h,\n {\n }\n \n-static inline void hugetlb_vmemmap_init_early(int nid)\n+static inline unsigned int hugetlb_vmemmap_optimizable_size(const struct hstate *h)\n {\n+\treturn 0;\n }\n \n-static inline unsigned int hugetlb_vmemmap_optimizable_size(const struct hstate *h)\n+static inline void hugetlb_vmemmap_optimize_bootmem_page(struct huge_bootmem_page *m)\n {\n-\treturn 0;\n }\n #endif /* CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP */\n \ndiff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c\nindex 6522c36aac20..d266bcf45b5c 100644\n--- a/mm/sparse-vmemmap.c\n+++ b/mm/sparse-vmemmap.c\n@@ -32,7 +32,6 @@\n #include <asm/dma.h>\n #include <asm/tlbflush.h>\n \n-#include \"hugetlb_vmemmap.h\"\n #include \"internal.h\"\n \n /*\n@@ -381,33 +380,6 @@ static __meminit struct page *vmemmap_get_tail(unsigned int order, struct zone *\n \treturn tail;\n }\n \n-#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP\n-int __meminit vmemmap_populate_hvo(unsigned long addr, unsigned long end,\n-\t\t\t\t       unsigned int order, struct zone *zone,\n-\t\t\t\t       unsigned long headsize)\n-{\n-\tunsigned long maddr;\n-\tstruct page *tail;\n-\tpte_t *pte;\n-\tint node = zone_to_nid(zone);\n-\n-\ttail = vmemmap_get_tail(order, zone);\n-\tif (!tail)\n-\t\treturn -ENOMEM;\n-\n-\tfor (maddr = addr; maddr < addr + headsize; maddr += PAGE_SIZE) {\n-\t\tpte = vmemmap_populate_address(maddr, node, NULL, -1);\n-\t\tif (!pte)\n-\t\t\treturn -ENOMEM;\n-\t}\n-\n-\t/*\n-\t * Reuse the last page struct page mapped above for the rest.\n-\t */\n-\treturn vmemmap_populate_range(maddr, end, node, NULL, page_to_pfn(tail));\n-}\n-#endif\n-\n void __weak __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node,\n \t\t\t\t      unsigned long addr, unsigned long next)\n {\n@@ -595,7 +567,6 @@ struct page * __meminit __populate_section_memmap(unsigned long pfn,\n  */\n void __init sparse_vmemmap_init_nid_early(int nid)\n {\n-\thugetlb_vmemmap_init_early(nid);\n }\n #endif\n \n",
    "prefixes": [
        "28/49"
    ]
}