{"id":2219973,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2219973/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260405125240.2558577-49-songmuchun@bytedance.com/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.2/projects/2/?format=json","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-49-songmuchun@bytedance.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20260405125240.2558577-49-songmuchun@bytedance.com/","date":"2026-04-05T12:52:39","name":"[48/49] Documentation/mm: restructure vmemmap_dedup.rst to reflect generalized HVO","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"a95bffbf90ab234191589c82347bcd96ae5f1833","submitter":{"id":78930,"url":"http://patchwork.ozlabs.org/api/1.2/people/78930/?format=json","name":"Muchun Song","email":"songmuchun@bytedance.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260405125240.2558577-49-songmuchun@bytedance.com/mbox/","series":[{"id":498783,"url":"http://patchwork.ozlabs.org/api/1.2/series/498783/?format=json","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/2219973/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219973/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linuxppc-dev+bounces-19378-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=Yvqf97N0;\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-19378-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::1031\"","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=Yvqf97N0;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=bytedance.com\n (client-ip=2607:f8b0:4864:20::1031; helo=mail-pj1-x1031.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 4fpXb524T2z1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 22:58:57 +1000 (AEST)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fpXb208Kdz307K;\n\tSun, 05 Apr 2026 22:58:54 +1000 (AEST)","from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com\n [IPv6:2607:f8b0:4864:20::1031])\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 4fpXb04l0Rz3069\n\tfor <linuxppc-dev@lists.ozlabs.org>; Sun, 05 Apr 2026 22:58:52 +1000 (AEST)","by mail-pj1-x1031.google.com with SMTP id\n 98e67ed59e1d1-354bc7c2c46so1788327a91.0\n        for <linuxppc-dev@lists.ozlabs.org>;\n Sun, 05 Apr 2026 05:58:52 -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.58.39\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Sun, 05 Apr 2026 05:58:50 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775393933;\n\tcv=none;\n b=ZPMXav+v20psqR68sOj0w4dg75Pk5/Q3Cdt381WWsGSUkLTM/OWgjnru6FZMFG+YFlpNE59zRe1yI9WHYdRtH9jji6PiutHk7M+3NMn2FUfg9+C8TC1wZhNRKg2aJlLxZcCSOAZwcQZUgnq0IMg7JMkLESKcWwiYBInA18xUr/Mx2t46IXL8P/+EtF1vSvWLAgvbKB8xaSii7VlMQK3BWxkSqaT67l1a5GwT4iyiVMnZaAbxaOG4y8WIjtrRTJtBNSlnu53Xr8Zr1Sptzp3Lr5Kpxi6AjrGr6GgJuwUSoz9yIAuX6bD6aPb9X1yYfxNDOOyCeOxIS34T+83kolcvQQ==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1775393933; c=relaxed/relaxed;\n\tbh=ydW451GMW82JpMBYkjDYyQiyHYoh54ssuDXhIqDFdlI=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=U5dK81ITgGzEVwJtaNB9ChA5OCRETxyESX3RLk2vzCsLTt9r9HNjP2VQZBaB/uHcgnoNxFJtGamHBHL8chz34MsFTZ1+mVkr+WDsHmTf9yst1tjRYeCvYY/Mvir/N4hjw9uzE0X2dNkMHZiLjHx4q6WM1DPXf3MYO/4xZM7Idau13AEMSRdVFRGN5RLF+3EE90jp+ux/G+ZbgZ0X2rY1ZHrS27rxvLWvT5Fr5wbYHz0dcIFl3/nT/QtpGqyjfMh/0TnDXLVqfqGjp+9WLjWmi1IVAn3/RrcoMsVL/tkAZJyOHPy3unZEfBRVFqr4UZ66Wjn6Ci5qRr5ZDow72G1UOA==","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=Yvqf97N0; dkim-atps=neutral;\n spf=pass (client-ip=2607:f8b0:4864:20::1031; helo=mail-pj1-x1031.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=1775393931; x=1775998731;\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=ydW451GMW82JpMBYkjDYyQiyHYoh54ssuDXhIqDFdlI=;\n        b=Yvqf97N0XUSW+tXrZxTl0U/aSpUGT/y4kovCZrM6p7RZK/X20iC7GYbyWZzr3LYUDh\n         8cQMjsYXnHd6GFhYPlejVNcVaJWmJWNuUzrMUeuGt9ujnctMYrjPgw4BalUqg/5cWoZa\n         kydgvnSWTfdXlpvnT2c0zo7ngqtkKEPCzF2w5kxmC1RxHtAP3JhGJ1r4V8XxS8Sl+zsC\n         NKAWR/M65NvWg96kgrpG5UZ9uHC8eh3fQhMrBv7JVJM+F6tzQkWfc3kWLGvGhBSRMiCN\n         fIhe50QifPWwgAh6Ka1pSW5lekY42MxbQszPANOnUbMKpDbmLdHXhx+NJJ4rEj16hSJW\n         k3hg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1775393931; x=1775998731;\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=ydW451GMW82JpMBYkjDYyQiyHYoh54ssuDXhIqDFdlI=;\n        b=dKZ35snURPlEwPH7xGeOHAm6jX9UwSi+5GNZ3T/3tL/uU2r0CsGW0uh3Pb00AC5mGZ\n         e9icUWT2vY/f8aUVQ5fDLB7KTBtQNo46XxwlqvXJtcFB256J1R6t+dwTf0BZZFZaXN2M\n         K723CdiP/0SFAuRGbZvrJJ/tFbvofagk+cTlNjzokTDTEKiwKbbuy3Mw29koLdKi165p\n         Lspe/Dc/3oZaQjFQKHpP48uTfTazW0r/gX2vMk2EA/Gd+zCeHrd/Vx4NhOknw8aDy1Zo\n         OZljaWa6Sr1SiMbGRqQ66RQj/xTqbhQdOiJacsX7oN1y7lu9xovBBY9vyiz1Hg+R6Jbb\n         pMdQ==","X-Forwarded-Encrypted":"i=1;\n AJvYcCWudEUGrMhUxFqTCuZzsffuJ12YZaTqYFzYdlKpXiOTTEmNiY/XvGJ7aKLuc7ipDLfvrQ7nh7I4aulUU28=@lists.ozlabs.org","X-Gm-Message-State":"AOJu0YzOY/P4/NI7yUEkV56mKJY4U/C55FVNLbhe3Tvv2Erm3r4E84rE\n\tPUGI5qGQrOF8swkNzYBkmERgS46tBd9ow5EaT34EML8wC1tLcH9yZPQpQRaVTQiviPk=","X-Gm-Gg":"AeBDietPxpr+GmX8Np3tA5bECPtGnbRBvXVWse7FdhvJBCN4KjoI2f1JESJzSJwPQWI\n\tW2ZrWW4ll3RWBzahKMzCNdeRvW2qdDlOxdlNV6QUdPhFMVFGsGtejFVLztNMImqh4bgTw3QHvb7\n\t0LXroTAGtOKiONP0D47klhL60Up3BAOqoBiau4rTMKVqGrXlelbPk1QTF7sv+sNy9yrs0l14cgK\n\tVzz7udaMKe8j2vLl4z/SOIgYLw7fQBejxzSAP3f8X9Y3fovc9JX457sVM0X+aopFVTO+Scqr/jw\n\t/diinq6oaIpxaulvl0fN4Mw/AXB5sPt1LNfwAlQ6G2jIXPt6idSK56V6TfXnyn5GoQyAhgZGYXe\n\tCCkmIqmZghbG/+8E8UEu6CuyzM+s/aF69C4ia4M904d8lAy5J1UHGzGpegUjf/lZjPlxbmXnu8n\n\tRU7q/Ysm/NBYgRq0eEt9d6ZyNlB44NjzvEkc3g8+gqvzo=","X-Received":"by 2002:a17:90b:2688:b0:354:a332:1a61 with SMTP id\n 98e67ed59e1d1-35de678f2b0mr8914364a91.5.1775393930429;\n        Sun, 05 Apr 2026 05:58:50 -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 48/49] Documentation/mm: restructure vmemmap_dedup.rst to\n reflect generalized HVO","Date":"Sun,  5 Apr 2026 20:52:39 +0800","Message-Id":"<20260405125240.2558577-49-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-Type":"text/plain; charset=UTF-8","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":"The documentation Documentation/mm/vmemmap_dedup.rst is slightly\noutdated and poorly structured. The current document primarily focuses\non HugeTLB pages as the main context, which fails to clearly communicate\nthe general principles of Hugepage Vmemmap Optimization (HVO).\n\nTo make it more logical and readable, refine the document. Specifically,\nintroduce the general HVO concepts, principles, and calculations that\nare agnostic to specific subsystems. Remove the outdated and\nsubsystem-specific contexts (like explicit HugeTLB and Device DAX sections)\nto better reflect the universal applicability of HVO to any large compound\npage.\n\nThis reorganization makes the documentation much easier to read and\nunderstand, and aligns with the recent renaming and generalization of\nthe HVO mechanism.\n\nSigned-off-by: Muchun Song <songmuchun@bytedance.com>\n---\n Documentation/mm/vmemmap_dedup.rst | 218 ++++++-----------------------\n 1 file changed, 42 insertions(+), 176 deletions(-)","diff":"diff --git a/Documentation/mm/vmemmap_dedup.rst b/Documentation/mm/vmemmap_dedup.rst\nindex 44e80bd2e398..a21d84fcbe24 100644\n--- a/Documentation/mm/vmemmap_dedup.rst\n+++ b/Documentation/mm/vmemmap_dedup.rst\n@@ -1,107 +1,33 @@\n-\n .. SPDX-License-Identifier: GPL-2.0\n \n-=========================================\n-A vmemmap diet for HugeTLB and Device DAX\n-=========================================\n-\n-HugeTLB\n-=======\n-\n-This section is to explain how Hugepage Vmemmap Optimization (HVO) for HugeTLB works.\n+===================================================\n+Fundamentals of Hugepage Vmemmap Optimization (HVO)\n+===================================================\n \n-The ``struct page`` structures are used to describe a physical page frame. By\n-default, there is a one-to-one mapping from a page frame to its corresponding\n+The ``struct page`` structures are used to describe a physical base page frame.\n+By default, there is a one-to-one mapping from a page frame to its corresponding\n ``struct page``.\n \n-HugeTLB pages consist of multiple base page size pages and is supported by many\n-architectures. See Documentation/admin-guide/mm/hugetlbpage.rst for more\n-details. On the x86-64 architecture, HugeTLB pages of size 2MB and 1GB are\n-currently supported. Since the base page size on x86 is 4KB, a 2MB HugeTLB page\n-consists of 512 base pages and a 1GB HugeTLB page consists of 262144 base pages.\n-For each base page, there is a corresponding ``struct page``.\n-\n-Within the HugeTLB subsystem, only the first 4 ``struct page`` are used to\n-contain unique information about a HugeTLB page. ``__NR_USED_SUBPAGE`` provides\n-this upper limit. The only 'useful' information in the remaining ``struct page``\n-is the compound_info field, and this field is the same for all tail pages.\n-\n-By removing redundant ``struct page`` for HugeTLB pages, memory can be returned\n-to the buddy allocator for other uses.\n-\n-Different architectures support different HugeTLB pages. For example, the\n-following table is the HugeTLB page size supported by x86 and arm64\n-architectures. Because arm64 supports 4k, 16k, and 64k base pages and\n-supports contiguous entries, so it supports many kinds of sizes of HugeTLB\n-page.\n-\n-+--------------+-----------+-----------------------------------------------+\n-| Architecture | Page Size |                HugeTLB Page Size              |\n-+--------------+-----------+-----------+-----------+-----------+-----------+\n-|    x86-64    |    4KB    |    2MB    |    1GB    |           |           |\n-+--------------+-----------+-----------+-----------+-----------+-----------+\n-|              |    4KB    |   64KB    |    2MB    |    32MB   |    1GB    |\n-|              +-----------+-----------+-----------+-----------+-----------+\n-|    arm64     |   16KB    |    2MB    |   32MB    |     1GB   |           |\n-|              +-----------+-----------+-----------+-----------+-----------+\n-|              |   64KB    |    2MB    |  512MB    |    16GB   |           |\n-+--------------+-----------+-----------+-----------+-----------+-----------+\n-\n-When the system boot up, every HugeTLB page has more than one ``struct page``\n-structs which size is (unit: pages)::\n-\n-   struct_size = HugeTLB_Size / PAGE_SIZE * sizeof(struct page) / PAGE_SIZE\n-\n-Where HugeTLB_Size is the size of the HugeTLB page. We know that the size\n-of the HugeTLB page is always n times PAGE_SIZE. So we can get the following\n-relationship::\n-\n-   HugeTLB_Size = n * PAGE_SIZE\n-\n-Then::\n+When huge pages (large compound page) are used, they consist of multiple base\n+page size pages. For each base page, there is a corresponding ``struct page``.\n+However, only a few ``struct page``\n+structures are actually used to contain unique information about the huge page.\n+The only 'useful' information in the remaining tail ``struct page`` structures\n+is the ``->compound_info`` field to get the head page structure, and this field\n+is the same for all tail pages.\n \n-   struct_size = n * PAGE_SIZE / PAGE_SIZE * sizeof(struct page) / PAGE_SIZE\n-               = n * sizeof(struct page) / PAGE_SIZE\n+We can remove redundant ``struct page`` structures for huge pages to save memory.\n+This optimization is referred to as Hugepage Vmemmap Optimization (HVO).\n \n-We can use huge mapping at the pud/pmd level for the HugeTLB page.\n+The optimization is only applied when the size of the ``struct page`` is a\n+power-of-2. In this case, all tail pages of the same order are identical. See\n+``compound_head()``. This allows us to remap the tail pages of the vmemmap to a\n+shared page.\n \n-For the HugeTLB page of the pmd level mapping, then::\n+Let’s take a system with a 2 MB huge page and a base page size of 4 KB as an\n+example for illustration. Here is how things look before optimization::\n \n-   struct_size = n * sizeof(struct page) / PAGE_SIZE\n-               = PAGE_SIZE / sizeof(pte_t) * sizeof(struct page) / PAGE_SIZE\n-               = sizeof(struct page) / sizeof(pte_t)\n-               = 64 / 8\n-               = 8 (pages)\n-\n-Where n is how many pte entries which one page can contains. So the value of\n-n is (PAGE_SIZE / sizeof(pte_t)).\n-\n-This optimization only supports 64-bit system, so the value of sizeof(pte_t)\n-is 8. And this optimization also applicable only when the size of ``struct page``\n-is a power of two. In most cases, the size of ``struct page`` is 64 bytes (e.g.\n-x86-64 and arm64). So if we use pmd level mapping for a HugeTLB page, the\n-size of ``struct page`` structs of it is 8 page frames which size depends on the\n-size of the base page.\n-\n-For the HugeTLB page of the pud level mapping, then::\n-\n-   struct_size = PAGE_SIZE / sizeof(pmd_t) * struct_size(pmd)\n-               = PAGE_SIZE / 8 * 8 (pages)\n-               = PAGE_SIZE (pages)\n-\n-Where the struct_size(pmd) is the size of the ``struct page`` structs of a\n-HugeTLB page of the pmd level mapping.\n-\n-E.g.: A 2MB HugeTLB page on x86_64 consists in 8 page frames while 1GB\n-HugeTLB page consists in 4096.\n-\n-Next, we take the pmd level mapping of the HugeTLB page as an example to\n-show the internal implementation of this optimization. There are 8 pages\n-``struct page`` structs associated with a HugeTLB page which is pmd mapped.\n-\n-Here is how things look before optimization::\n-\n-    HugeTLB                  struct pages(8 pages)         page frame(8 pages)\n+  2MB Hugepage                  struct pages (8 pages)        page frame (8 pages)\n  +-----------+ ---virt_to_page---> +-----------+   mapping to   +-----------+\n  |           |                     |     0     | -------------> |     0     |\n  |           |                     +-----------+                +-----------+\n@@ -112,9 +38,9 @@ Here is how things look before optimization::\n  |           |                     |     3     | -------------> |     3     |\n  |           |                     +-----------+                +-----------+\n  |           |                     |     4     | -------------> |     4     |\n- |    PMD    |                     +-----------+                +-----------+\n- |   level   |                     |     5     | -------------> |     5     |\n- |  mapping  |                     +-----------+                +-----------+\n+ |           |                     +-----------+                +-----------+\n+ |           |                     |     5     | -------------> |     5     |\n+ |           |                     +-----------+                +-----------+\n  |           |                     |     6     | -------------> |     6     |\n  |           |                     +-----------+                +-----------+\n  |           |                     |     7     | -------------> |     7     |\n@@ -124,34 +50,27 @@ Here is how things look before optimization::\n  |           |\n  +-----------+\n \n-The first page of ``struct page`` (page 0) associated with the HugeTLB page\n-contains the 4 ``struct page`` necessary to describe the HugeTLB. The remaining\n-pages of ``struct page`` (page 1 to page 7) are tail pages.\n-\n-The optimization is only applied when the size of the struct page is a power\n-of 2. In this case, all tail pages of the same order are identical. See\n-compound_head(). This allows us to remap the tail pages of the vmemmap to a\n-shared, read-only page. The head page is also remapped to a new page. This\n-allows the original vmemmap pages to be freed.\n+We remap the tail pages (page 1 to page 7) of the vmemmap to a shared, read-only\n+page (per-zone).\n \n Here is how things look after remapping::\n \n-    HugeTLB                  struct pages(8 pages)                 page frame (new)\n+  2MB Hugepage                  struct pages(8 pages)           page frame (1 page)\n  +-----------+ ---virt_to_page---> +-----------+   mapping to   +----------------+\n  |           |                     |     0     | -------------> |       0        |\n  |           |                     +-----------+                +----------------+\n  |           |                     |     1     | ------┐\n  |           |                     +-----------+       |\n- |           |                     |     2     | ------┼        +----------------------------+\n+ |           |                     |     2     | ------┼\n+ |           |                     +-----------+       |\n+ |           |                     |     3     | ------┼        +----------------------------+\n  |           |                     +-----------+       |        | A single, per-zone page    |\n- |           |                     |     3     | ------┼------> | frame shared among all     |\n+ |           |                     |     4     | ------┼------> | frame shared among all     |\n  |           |                     +-----------+       |        | hugepages of the same size |\n- |           |                     |     4     | ------┼        +----------------------------+\n+ |           |                     |     5     | ------┼        +----------------------------+\n+ |           |                     +-----------+       |\n+ |           |                     |     6     | ------┼\n  |           |                     +-----------+       |\n- |           |                     |     5     | ------┼\n- |    PMD    |                     +-----------+       |\n- |   level   |                     |     6     | ------┼\n- |  mapping  |                     +-----------+       |\n  |           |                     |     7     | ------┘\n  |           |                     +-----------+\n  |           |\n@@ -159,65 +78,12 @@ Here is how things look after remapping::\n  |           |\n  +-----------+\n \n-When a HugeTLB is freed to the buddy system, we should allocate 7 pages for\n-vmemmap pages and restore the previous mapping relationship.\n-\n-For the HugeTLB page of the pud level mapping. It is similar to the former.\n-We also can use this approach to free (PAGE_SIZE - 1) vmemmap pages.\n-\n-Apart from the HugeTLB page of the pmd/pud level mapping, some architectures\n-(e.g. aarch64) provides a contiguous bit in the translation table entries\n-that hints to the MMU to indicate that it is one of a contiguous set of\n-entries that can be cached in a single TLB entry.\n-\n-The contiguous bit is used to increase the mapping size at the pmd and pte\n-(last) level. So this type of HugeTLB page can be optimized only when its\n-size of the ``struct page`` structs is greater than **1** page.\n-\n-Device DAX\n-==========\n-\n-The device-dax interface uses the same tail deduplication technique explained\n-in the previous chapter, except when used with the vmemmap in\n-the device (altmap).\n-\n-The following page sizes are supported in DAX: PAGE_SIZE (4K on x86_64),\n-PMD_SIZE (2M on x86_64) and PUD_SIZE (1G on x86_64).\n-For powerpc equivalent details see Documentation/arch/powerpc/vmemmap_dedup.rst\n-\n-The differences with HugeTLB are relatively minor.\n-\n-It only use 3 ``struct page`` for storing all information as opposed\n-to 4 on HugeTLB pages.\n-\n-There's no remapping of vmemmap given that device-dax memory is not part of\n-System RAM ranges initialized at boot. Thus the tail page deduplication\n-happens at a later stage when we populate the sections. HugeTLB reuses the\n-the head vmemmap page representing, whereas device-dax reuses the tail\n-vmemmap page. This results in only half of the savings compared to HugeTLB.\n-\n-Deduplicated tail pages are not mapped read-only.\n+Therefore, for any hugepage, if the total size of its corresponding ``struct pages``\n+is greater than or equal to the size of two base pages, then HVO technology can\n+be applied to this hugepage to save memory. For example, in this case, the\n+smallest hugepage that can apply HVO is 512 KB (its order corresponds to\n+``OPTIMIZABLE_FOLIO_MIN_ORDER``). Therefore, any hugepage with an order greater\n+than or equal to ``OPTIMIZABLE_FOLIO_MIN_ORDER`` can apply HVO technology.\n \n-Here's how things look like on device-dax after the sections are populated::\n-\n- +-----------+ ---virt_to_page---> +-----------+   mapping to   +-----------+\n- |           |                     |     0     | -------------> |     0     |\n- |           |                     +-----------+                +-----------+\n- |           |                     |     1     | -------------> |     1     |\n- |           |                     +-----------+                +-----------+\n- |           |                     |     2     | ----------------^ ^ ^ ^ ^ ^\n- |           |                     +-----------+                   | | | | |\n- |           |                     |     3     | ------------------+ | | | |\n- |           |                     +-----------+                     | | | |\n- |           |                     |     4     | --------------------+ | | |\n- |    PMD    |                     +-----------+                       | | |\n- |   level   |                     |     5     | ----------------------+ | |\n- |  mapping  |                     +-----------+                         | |\n- |           |                     |     6     | ------------------------+ |\n- |           |                     +-----------+                           |\n- |           |                     |     7     | --------------------------+\n- |           |                     +-----------+\n- |           |\n- |           |\n- |           |\n- +-----------+\n+Meanwhile, each HVOed hugepage still has ``OPTIMIZED_FOLIO_VMEMMAP_PAGE_STRUCTS``\n+available ``struct page`` structures.\n","prefixes":["48/49"]}