{"id":2219969,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2219969/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260405125240.2558577-45-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-45-songmuchun@bytedance.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20260405125240.2558577-45-songmuchun@bytedance.com/","date":"2026-04-05T12:52:35","name":"[44/49] mm/sparse-vmemmap: drop ARCH_WANT_OPTIMIZE_DAX_VMEMMAP and simplify checks","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"eee71551afde54b6962368bdb5a1d74e4cd944b4","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-45-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/2219969/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219969/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linuxppc-dev+bounces-19374-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=aWKW18h0;\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-19374-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=aWKW18h0;\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 4fpXZZ4Jbbz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 22:58:30 +1000 (AEST)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fpXZQ3dv4z3fC2;\n\tSun, 05 Apr 2026 22:58:22 +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 4fpXZP4snxz2ypV\n\tfor <linuxppc-dev@lists.ozlabs.org>; Sun, 05 Apr 2026 22:58:21 +1000 (AEST)","by mail-pj1-x102d.google.com with SMTP id\n 98e67ed59e1d1-35d94f4ee36so1734939a91.3\n        for <linuxppc-dev@lists.ozlabs.org>;\n Sun, 05 Apr 2026 05:58:21 -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.14\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Sun, 05 Apr 2026 05:58:19 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775393902;\n\tcv=none;\n b=I81xrhPYjVqyzAGEZMKhrTRZi/fCEc727WfD3x4tsvrL1xMv0Rz8KYx5IzYeu1+5AZU4iG0c2eHs+3poqtD5irjOVaiIPEPcpQz1DrSC3sUfUY6hztSkTfrlKch64iTUV7snnQlnouijbKXKQBQ3SgVeBWFcIAtLlkxw74f2rxVHHmFQ+ryDKCsQN3nCRSu1gmV0Dx3IO8c32i1eu/RvN4jRy/OdHMVrphBwsLpjkbsIcfiJTAkt8ct4MD6i8D8x+1YVMc/cx+Mh3AOc7iAxa7m4aCNmDF8/QDSylR3WgDT0tt0IDpyiSXDkLTB586VyaAoc4Mvi4FKA3fAPhfke2w==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1775393902; c=relaxed/relaxed;\n\tbh=tR6tFFSAYX0KQImZ49bGZfXfFcdkBNLOh7cRjPEro20=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=NroK2oKxvWeJhV5LujxBgstiV/97LEJ3dmtibxKEL34FFKyXijp/G0AqXJwnXuU+0MJOUgrundUeJonK1AWAQrd/zekibB66AXJgKI3wGsCuVtJXiyDbNstbdaUMXTrM+y9hW7zINuSh94KwfWoUMt5KY3oHeSfvl7BwVwC85TnoUEM39CQeg01Xn+LoHyYDfeg0lKHudB/KmgoN6XMchPlcOBibhpmiKGNIDtuLV+Ys3I3OyV/GJ48G9N9Hf1z9gO2SUYmGQKNf6ZzcCyEvLuXqtt7ZeEs6lsWyJgxCzm1rmL36bwR9ADXQvuArnWfivqbegDGkGsxg5A7jjr/PTg==","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=aWKW18h0; 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=1775393900; x=1775998700;\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=tR6tFFSAYX0KQImZ49bGZfXfFcdkBNLOh7cRjPEro20=;\n        b=aWKW18h07qO34AnWHC6E/yX3vl6jOG2vkZBzteFhVasbYyIjl6pT890hKFZRUEvs7B\n         ijT0Qj0ajEYQ+Sfrp1DACPFug45ERWq30PjZtfPhw8MIQVjatHHnf4yL57aSyxGF8wF3\n         hjCGSqxzHpfNrG1+TsK7PTHCtU2KUv9X/CdhxdmVpSEiBB0FJ+OWs9k1Hiy2nUBiaaWp\n         Mv2u79kWBPl8kz7n71CB4WRxmn0SkOKO7XzDX8IHzys6vrx3HdH3JRvgzcJg4lciKjLH\n         u0Ro12ChImlLOtjia/NuwDhfD1Om6lR7y2nyl444IF3aNW3/8DHptlQJ26FQZG+DTMfy\n         MYgQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1775393900; x=1775998700;\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=tR6tFFSAYX0KQImZ49bGZfXfFcdkBNLOh7cRjPEro20=;\n        b=dz5uRGh6PrzH63ZCYfaxX/4tnkZLycOAFW+C9t6wbiKzZYEnH1nBBxifg7TveqX+7j\n         DrDRI9ENNANLab8iMpQw4Tb8CYO2y9lyn6OHGCSOFO1dEbNtBwrML4u8WETMnU0l5iXl\n         VYRFXEAzMgLdg/YjAM/qLCHN82jpDO7M7ZGWKh7P6cRvOzxlARoO2D8iSPhlsrjRlixh\n         FFGLmK/EbgqlEgK+BVjqeImc0ZwONtRhY7cqDyo0RzbTiLzJ3KMa4ITykI/c/B+VPJSe\n         cKLUi2sGuzTWwW5s7dXCcHF3PaTKVnPKkFDFZLGhfSQUxb0i8Ui8bLBbktmOek4ZVo5m\n         oAVA==","X-Forwarded-Encrypted":"i=1;\n AJvYcCUq0eReJtShWAxIOOQbYgKNtJi9pnHfzQ18dV9joWhRRKFgabb0sVKXiyTP+1WvOLivL1Ub2JK/eFdtXyA=@lists.ozlabs.org","X-Gm-Message-State":"AOJu0YwnT736AshFuXMLUP38gi65qYwU9so1KUegl2CBF4N+Lgl3zHgU\n\t/dU9LsX0YjNZAssNwE4wrc8yA8eCAQbrBud39RKc1JK/gqnDcDHYWPupZiWA9Y+UgY4=","X-Gm-Gg":"AeBDietHoRsU3PDtnPNVr6ljiRclsUG4jcUmZ0UPMZ5vraa5qoB3bFIpNeBvmFWl/aD\n\tkYbrCgGhtBbUmTAzmBkV96DjFVKytzLfCnmHabTKhgSShdu3zf4qkOzHvclWzt79J4j8KV0uFkG\n\tj2kZcnn8zb9yB/NN8ws9e1h2Z+JO+Qrp+seDauyWPiSMcuDOrdWExipKEWgGG2ZP8CnoxPwQrvL\n\tvdsdGxw2pTLXFfQ+ZmGxfWjMkOYVWBOBpSvqjlQjcO68wBa8M3Jhz41IHSf4skEhpM816aLZqDd\n\tABe8qi3LbTVI2Sbx13C2lIL2P3ORcj0lajP1UBJ6E3Pk2eRR5IHME3SEQQngp6ri/Qr2zwGaGO0\n\tOCkzH3bMvPxp6K2T2O18sJjYJpiGWJS89BZO1NmnF8JYHNh1+4aKldPh6CnGQY/9NFPukKmY2la\n\t8w8lCJRiSLsqvHM9AR0PsvQRc/ZyF2z06T84z+j+Nf0MY=","X-Received":"by 2002:a17:90b:224e:b0:35b:e51b:1935 with SMTP id\n 98e67ed59e1d1-35de68cfba8mr8245353a91.17.1775393899744;\n        Sun, 05 Apr 2026 05:58:19 -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 44/49] mm/sparse-vmemmap: drop ARCH_WANT_OPTIMIZE_DAX_VMEMMAP\n and simplify checks","Date":"Sun,  5 Apr 2026 20:52:35 +0800","Message-Id":"<20260405125240.2558577-45-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":"Historically, when device DAX vmemmap optimization was introduced, it was\ninitially implemented as a generic feature within sparse-vmemmap.c. However,\nit was later discovered that architectures with specific page table formats\n(such as PowerPC with hash translation) would crash because the generic\nvmemmap_populate_compound_pages() was unaware of their specific page table\nsetup (e.g., bolted table entries).\n\nTo address this, commit 87a7ae75d738 (\"mm/vmemmap/devdax: fix kernel crash\nwhen probing devdax devices\") introduced a restrictive config option,\nwhich eventually evolved into ARCH_WANT_OPTIMIZE_DAX_VMEMMAP (via commits\n0b376f1e0ff5 and 0b6f15824cc7). This effectively turned a generic\noptimization into an opt-in architectural feature.\n\nHowever, the architecture landscape has evolved. The decision of whether\nto apply DAX vmemmap optimization techniques for specific page table formats\nis now fully delegated to the architecture-specific implementations (e.g.,\nwithin vmemmap_populate()). The upper-level Kconfig restrictions and the\nrigid generic wrapper functions are no longer necessary to prevent crashes,\nas the architectures themselves handle the viability of the mappings. If an\narchitecture does not support DAX vmemmap optimization, it can simply\nimplement fallback logic similar to what PowerPC does in its\nvmemmap_populate() routines.\n\nIf the architecture supports neither HugeTLB vmemmap optimization nor DAX\nvmemmap optimization, but still wants to reduce code size and disable this\nfeature entirely, it is now possible to turn off SPARSEMEM_VMEMMAP_OPTIMIZATION.\nIt is no longer a hidden option, but rather a user-configurable boolean under\nthe SPARSEMEM_VMEMMAP umbrella.\n\nTherefore, this patch removes the redundant ARCH_WANT_OPTIMIZE_DAX_VMEMMAP\nand drops the complicated vmemmap_can_optimize() helper. Instead, we\nunify SPARSEMEM_VMEMMAP_OPTIMIZATION as a fundamental core capability that\nis enabled by default whenever SPARSEMEM_VMEMMAP is selected.\n\nThe check in sparse_add_section() is safely simplified to:\nif (!altmap && pgmap && nr_pages == PAGES_PER_SECTION)\nwhich succinctly reflects the prerequisites for the optimization without\nunnecessary boilerplate.\n\nSigned-off-by: Muchun Song <songmuchun@bytedance.com>\n---\n arch/powerpc/Kconfig |  1 -\n arch/riscv/Kconfig   |  1 -\n arch/x86/Kconfig     |  1 -\n include/linux/mm.h   | 34 ----------------------------------\n mm/Kconfig           | 14 ++++++++------\n mm/sparse-vmemmap.c  |  2 +-\n 6 files changed, 9 insertions(+), 44 deletions(-)","diff":"diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig\nindex da4e2ec2af20..8158d5d0c226 100644\n--- a/arch/powerpc/Kconfig\n+++ b/arch/powerpc/Kconfig\n@@ -184,7 +184,6 @@ config PPC\n \tselect ARCH_WANT_IPC_PARSE_VERSION\n \tselect ARCH_WANT_IRQS_OFF_ACTIVATE_MM\n \tselect ARCH_WANT_LD_ORPHAN_WARN\n-\tselect ARCH_WANT_OPTIMIZE_DAX_VMEMMAP\tif PPC_RADIX_MMU\n \tselect ARCH_WANTS_MODULES_DATA_IN_VMALLOC\tif PPC_BOOK3S_32 || PPC_8xx\n \tselect ARCH_WEAK_RELEASE_ACQUIRE\n \tselect BINFMT_ELF\ndiff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig\nindex 61a9d8d3ea64..a8eccb828e7b 100644\n--- a/arch/riscv/Kconfig\n+++ b/arch/riscv/Kconfig\n@@ -85,7 +85,6 @@ config RISCV\n \tselect ARCH_WANT_GENERAL_HUGETLB if !RISCV_ISA_SVNAPOT\n \tselect ARCH_WANT_HUGE_PMD_SHARE if 64BIT\n \tselect ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL\n-\tselect ARCH_WANT_OPTIMIZE_DAX_VMEMMAP\n \tselect ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP\n \tselect ARCH_WANTS_NO_INSTR\n \tselect ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE\ndiff --git a/arch/x86/Kconfig b/arch/x86/Kconfig\nindex f19625648f0f..83c55e286b40 100644\n--- a/arch/x86/Kconfig\n+++ b/arch/x86/Kconfig\n@@ -146,7 +146,6 @@ config X86\n \tselect ARCH_WANT_GENERAL_HUGETLB\n \tselect ARCH_WANT_HUGE_PMD_SHARE\t\tif X86_64\n \tselect ARCH_WANT_LD_ORPHAN_WARN\n-\tselect ARCH_WANT_OPTIMIZE_DAX_VMEMMAP\tif X86_64\n \tselect ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP\tif X86_64\n \tselect ARCH_WANTS_THP_SWAP\t\tif X86_64\n \tselect ARCH_HAS_PARANOID_L1D_FLUSH\ndiff --git a/include/linux/mm.h b/include/linux/mm.h\nindex c36001c9d571..8baa224444be 100644\n--- a/include/linux/mm.h\n+++ b/include/linux/mm.h\n@@ -4910,40 +4910,6 @@ static inline void vmem_altmap_free(struct vmem_altmap *altmap,\n }\n #endif\n \n-#define VMEMMAP_RESERVE_NR\tOPTIMIZED_FOLIO_VMEMMAP_PAGES\n-#ifdef CONFIG_ARCH_WANT_OPTIMIZE_DAX_VMEMMAP\n-static inline bool __vmemmap_can_optimize(struct vmem_altmap *altmap,\n-\t\t\t\t\t  struct dev_pagemap *pgmap)\n-{\n-\tunsigned long nr_pages;\n-\tunsigned long nr_vmemmap_pages;\n-\n-\tif (!pgmap || !is_power_of_2(sizeof(struct page)))\n-\t\treturn false;\n-\n-\tnr_pages = pgmap_vmemmap_nr(pgmap);\n-\tnr_vmemmap_pages = ((nr_pages * sizeof(struct page)) >> PAGE_SHIFT);\n-\t/*\n-\t * For vmemmap optimization with DAX we need minimum 2 vmemmap\n-\t * pages. See layout diagram in Documentation/mm/vmemmap_dedup.rst\n-\t */\n-\treturn !altmap && (nr_vmemmap_pages > VMEMMAP_RESERVE_NR);\n-}\n-/*\n- * If we don't have an architecture override, use the generic rule\n- */\n-#ifndef vmemmap_can_optimize\n-#define vmemmap_can_optimize __vmemmap_can_optimize\n-#endif\n-\n-#else\n-static inline bool vmemmap_can_optimize(struct vmem_altmap *altmap,\n-\t\t\t\t\t   struct dev_pagemap *pgmap)\n-{\n-\treturn false;\n-}\n-#endif\n-\n enum mf_flags {\n \tMF_COUNT_INCREASED = 1 << 0,\n \tMF_ACTION_REQUIRED = 1 << 1,\ndiff --git a/mm/Kconfig b/mm/Kconfig\nindex e81aa77182b2..166552d5d69a 100644\n--- a/mm/Kconfig\n+++ b/mm/Kconfig\n@@ -411,17 +411,19 @@ config SPARSEMEM_VMEMMAP\n \t  efficient option when sufficient kernel resources are available.\n \n config SPARSEMEM_VMEMMAP_OPTIMIZATION\n-\tbool\n+\tbool \"Enable Vmemmap Optimization Infrastructure\"\n+\tdefault y\n \tdepends on SPARSEMEM_VMEMMAP\n+\thelp\n+\t  This allows features like HugeTLB and DAX to map multiple contiguous\n+\t  vmemmap pages to a single underlying physical page to save memory.\n+\n+\t  If unsure, say Y.\n \n #\n # Select this config option from the architecture Kconfig, if it is preferred\n-# to enable the feature of HugeTLB/dev_dax vmemmap optimization.\n+# to enable the feature of HugeTLB vmemmap optimization.\n #\n-config ARCH_WANT_OPTIMIZE_DAX_VMEMMAP\n-\tbool\n-\tselect SPARSEMEM_VMEMMAP_OPTIMIZATION if SPARSEMEM_VMEMMAP\n-\n config ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP\n \tbool\n \ndiff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c\nindex ac2efba9ef92..752a48112504 100644\n--- a/mm/sparse-vmemmap.c\n+++ b/mm/sparse-vmemmap.c\n@@ -698,7 +698,7 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn,\n \t\treturn ret;\n \n \tms = __nr_to_section(section_nr);\n-\tif (vmemmap_can_optimize(altmap, pgmap) && nr_pages == PAGES_PER_SECTION) {\n+\tif (!altmap && pgmap && nr_pages == PAGES_PER_SECTION) {\n \t\tsection_set_order(ms, pgmap->vmemmap_shift);\n #ifdef CONFIG_ZONE_DEVICE\n \t\tsection_set_zone(ms, ZONE_DEVICE);\n","prefixes":["44/49"]}