Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2228367/?format=api
{ "id": 2228367, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2228367/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260426092640.375967-4-songmuchun@bytedance.com/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/1.1/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/" }, "msgid": "<20260426092640.375967-4-songmuchun@bytedance.com>", "date": "2026-04-26T09:26:37", "name": "[v7,3/6] mm/sparse-vmemmap: Pass @pgmap argument to memory deactivation paths", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "bec948ceaffea03408ec643d6dc246a7f803bbb9", "submitter": { "id": 78930, "url": "http://patchwork.ozlabs.org/api/1.1/people/78930/?format=api", "name": "Muchun Song", "email": "songmuchun@bytedance.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260426092640.375967-4-songmuchun@bytedance.com/mbox/", "series": [ { "id": 501518, "url": "http://patchwork.ozlabs.org/api/1.1/series/501518/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=501518", "date": "2026-04-26T09:26:34", "name": "mm: Fix vmemmap optimization accounting and initialization", "version": 7, "mbox": "http://patchwork.ozlabs.org/series/501518/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2228367/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2228367/checks/", "tags": {}, "headers": { "Return-Path": "\n <linuxppc-dev+bounces-20116-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=ao2tShjL;\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-20116-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::631\"", "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=ao2tShjL;\n\tdkim-atps=neutral", "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=bytedance.com\n (client-ip=2607:f8b0:4864:20::631; helo=mail-pl1-x631.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 4g3LvR2Bjzz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Apr 2026 19:27:31 +1000 (AEST)", "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4g3LvL3s9gz2ySV;\n\tSun, 26 Apr 2026 19:27:26 +1000 (AEST)", "from mail-pl1-x631.google.com (mail-pl1-x631.google.com\n [IPv6:2607:f8b0:4864:20::631])\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 4g3LvK2kgqz2xlK\n\tfor <linuxppc-dev@lists.ozlabs.org>; Sun, 26 Apr 2026 19:27:25 +1000 (AEST)", "by mail-pl1-x631.google.com with SMTP id\n d9443c01a7336-2b24fdac394so89720415ad.3\n for <linuxppc-dev@lists.ozlabs.org>;\n Sun, 26 Apr 2026 02:27:25 -0700 (PDT)", "from n232-176-004.byted.org ([240e:83:200::34a])\n by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b5fab0caa9sm270352885ad.40.2026.04.26.02.27.18\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sun, 26 Apr 2026 02:27:22 -0700 (PDT)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1777195646;\n\tcv=none;\n b=dMd8iblJ7gni0I26Hx6FtR3228acsvs5NWWK4cGvBOo+3xtAGFpXgxMVY/6vi3sDHjccgjoRVi2tJwvYo6q9YNKH0D58Ivg91/PInmg0dAe0lBAnAtz+LNZp3exv8AFSngHAjFmyIYmDpajqMmlcRi06roPvxKqO+GzVNvdHunifeGMW3W+dBaoo3VpI4DkC4Ak/Ca+JBEH+jsdMW5o0LViFy4eJWy6DTHYunS7PZW1uRGiiqu/uhcIGl7LfQkF+8kss+ASNyABzvjdHc7DC2ChG3X0wZYf9nuIEYawvhOGFNTAsDvNFTDi7+ddNj5hKIk1J61MSkyGbrKvwF8loUg==", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1777195646; c=relaxed/relaxed;\n\tbh=Zr+2FRsXkOuluyT7nhch5RLSTRKRMggfn+zHryGzliY=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=gqc1YVyPsn7rbEn3+Iy65nI+MnmRrhVzM35drZQuWXnTF1jKUbh26gXRpUayvCIuDbhsLM6z7S8iEQz1uTuq1rb40VKW2z8cyP2H0buHF+is8zZZte6Xbx4FSscUJ+5LQDsvF4hArXlsBNyDuJkNYHgDdchXLWq1fv3v29z72BFIk5Qc2pvd5CB8nRTiqnhmfmcgWMmR0sbhHp5wgUMBDAh5AEbdIyAHMCufSB78lGqsgpnPcDiB3uRx66LF5LnBWcCD3Iy/IXLSMghkLF96BAtSWQ5NiNZfdQi4uFOGja3uztXkG7Subkoc2HtgsJDXXaKOXKTiUQZ3tAVcIHEc8Q==", "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=ao2tShjL; dkim-atps=neutral;\n spf=pass (client-ip=2607:f8b0:4864:20::631; helo=mail-pl1-x631.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=1777195643; x=1777800443;\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=Zr+2FRsXkOuluyT7nhch5RLSTRKRMggfn+zHryGzliY=;\n b=ao2tShjLVXD4EYYnYtuo/aeUc/PgjO5KlmZi+MZGsWWgBjn07j4EDrmowV4lLcMJJO\n fLWExxLJunVCvLlDLt1zPBluDjB87JdQz7lZ3Js7YVIr9sAfxqzAhnbIhp7paV1kyG7c\n iSHvCw/x6fMzrD3afqVzM1spiEbHg/qOyoohQCxXyzWchQQywxyDCsjH97rrboiyxhss\n h9U1C+5/kfZk/oKS3kZiZnWyFNouYIVKwSpTKUPm75V3vE7Pm0tLy/4/cJtuHO4CNT8i\n 7/K/CqAxAlzLQp4L39fMSPPPS8/d/uRgzcfpeDy0hp+noUZLbzgp0E8YT54U9mQbCVOu\n pDbw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777195643; x=1777800443;\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=Zr+2FRsXkOuluyT7nhch5RLSTRKRMggfn+zHryGzliY=;\n b=O7itQJ+BsggjSj11hutl/kHVCZiU7u+wytv1Z4dU8q1vtceU3VTWimXDADn3qURoMs\n +/QS6hyM48nUHoCT7yVJiIwpORkBeIB3SZwJ5tF7M/iZO8F8kEa3IYPBuvL0Knz1DCm3\n vNQJFA6g0jKBbGDdmGrvtVLOpz9fBQ65Adzmn1jY8lwgVELLFe3tSloDEphObguW4wge\n WKouA/mB7ZYRbOdkKjxI8YA3gc6zKxhilRIkHN1xLunipCuoMG2/i4CLFmlSL+2Czdhv\n p/99gnvfxU0/Soa2a47gkRWBPw4fEHnElcu9XsXgPOC6Exdl5aYM+uYCAJjISC1DnXMC\n oNsw==", "X-Forwarded-Encrypted": "i=1;\n AFNElJ88R/pA1pKgv7kdu2f09/Q8exZyoNxutlopTF3Lz237q92BHpPuIpHqwggM+ZbofT4UMTB9cID/MmiR0jg=@lists.ozlabs.org", "X-Gm-Message-State": "AOJu0YzGGe4R/S0JC8Kp6hHtDUCB9Y+In2GKYVl2uWvMMIKgXXZO7F+m\n\tR9DbGGc/kS0vIrKvUobuVSxUHiWLInCp1h+896bDxGpyAgXyfSpf4M0pPfuX5vAYguw=", "X-Gm-Gg": "AeBDieuUJXN/UugswxDYvhU8puFJ8ru1Sai54Me4SDSIKALsZQqhZ3VlfkMw1gYHQe5\n\t6C80BfSUsMw4MA8epgMNuXq/hHh1scjGHod9nmp7HuiCfUGzDOM1cIOf1j8rDoLmjszZqnNBpeB\n\tswL0F3GxXL+KHu8HACGLotOD4MO6yUkMjR6UOKh7QX697RHTyP6KNkH0xXhKG6g/JwDWIe2X55R\n\tRwF36PcEWTtzvAa+sEHQGWXluUGzfhmigFs+pIEIT5ANlxQ+nOXW3Y00Y9uEpA4/jlWOWObF41E\n\t8bv/QINjhcUdUAL0hHPbZNCCf74bK12XT6gae0QQaMsyVzo4OXuEZqYohYDXKBX9pgjHlxtpM4W\n\tJ31mPElAVwEbcuy1Xxty6CNlwL1EC1J9bepP2hE/Dfr2wRJMmxlWq91m+RnWWJgjz6fW4IwZzS0\n\tuK0JkRB7p5vBg7tLVFZdV1JLKoDHI1", "X-Received": "by 2002:a17:902:9696:b0:2b0:4fb6:85ce with SMTP id\n d9443c01a7336-2b5f9f7cec4mr281168935ad.21.1777195643190;\n Sun, 26 Apr 2026 02:27:23 -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 v7 3/6] mm/sparse-vmemmap: Pass @pgmap argument to memory\n deactivation paths", "Date": "Sun, 26 Apr 2026 17:26:37 +0800", "Message-Id": "<20260426092640.375967-4-songmuchun@bytedance.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20260426092640.375967-1-songmuchun@bytedance.com>", "References": "<20260426092640.375967-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": "Currently, the memory hot-remove call chain -- arch_remove_memory(),\n__remove_pages(), sparse_remove_section() and section_deactivate() --\ndoes not carry the struct dev_pagemap pointer. This prevents the lower\nlevels from knowing whether the section was originally populated with\nvmemmap optimizations (e.g., DAX with vmemmap optimization enabled).\n\nWithout this information, we cannot call vmemmap_can_optimize() to\ndetermine if the vmemmap pages were optimized. As a result, the vmemmap\npage accounting during teardown will mistakenly assume a non-optimized\nallocation, leading to incorrect memmap statistics.\n\nTo lay the groundwork for fixing the vmemmap page accounting, we need\nto pass the @pgmap pointer down to the deactivation location. Plumb the\n@pgmap argument through the APIs of arch_remove_memory(), __remove_pages()\nand sparse_remove_section(), mirroring the corresponding *_activate()\npaths.\n\nSigned-off-by: Muchun Song <songmuchun@bytedance.com>\nAcked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>\nReviewed-by: Oscar Salvador <osalvador@suse.de>\nAcked-by: David Hildenbrand (Arm) <david@kernel.org>\n---\n arch/arm64/mm/mmu.c | 5 +++--\n arch/loongarch/mm/init.c | 5 +++--\n arch/powerpc/mm/mem.c | 5 +++--\n arch/riscv/mm/init.c | 5 +++--\n arch/s390/mm/init.c | 5 +++--\n arch/x86/mm/init_64.c | 5 +++--\n include/linux/memory_hotplug.h | 8 +++++---\n mm/memory_hotplug.c | 13 +++++++------\n mm/memremap.c | 4 ++--\n mm/sparse-vmemmap.c | 12 ++++++------\n 10 files changed, 38 insertions(+), 29 deletions(-)", "diff": "diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c\nindex dd85e093ffdb..e5a42b7a0160 100644\n--- a/arch/arm64/mm/mmu.c\n+++ b/arch/arm64/mm/mmu.c\n@@ -2024,12 +2024,13 @@ int arch_add_memory(int nid, u64 start, u64 size,\n \treturn ret;\n }\n \n-void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)\n+void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap,\n+\t\t\tstruct dev_pagemap *pgmap)\n {\n \tunsigned long start_pfn = start >> PAGE_SHIFT;\n \tunsigned long nr_pages = size >> PAGE_SHIFT;\n \n-\t__remove_pages(start_pfn, nr_pages, altmap);\n+\t__remove_pages(start_pfn, nr_pages, altmap, pgmap);\n \t__remove_pgd_mapping(swapper_pg_dir, __phys_to_virt(start), size);\n }\n \ndiff --git a/arch/loongarch/mm/init.c b/arch/loongarch/mm/init.c\nindex 3f9ab54114c5..055ecd2c8fd9 100644\n--- a/arch/loongarch/mm/init.c\n+++ b/arch/loongarch/mm/init.c\n@@ -119,7 +119,8 @@ int arch_add_memory(int nid, u64 start, u64 size, struct mhp_params *params)\n \treturn ret;\n }\n \n-void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)\n+void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap,\n+\t\t\tstruct dev_pagemap *pgmap)\n {\n \tunsigned long start_pfn = start >> PAGE_SHIFT;\n \tunsigned long nr_pages = size >> PAGE_SHIFT;\n@@ -128,7 +129,7 @@ void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)\n \t/* With altmap the first mapped page is offset from @start */\n \tif (altmap)\n \t\tpage += vmem_altmap_offset(altmap);\n-\t__remove_pages(start_pfn, nr_pages, altmap);\n+\t__remove_pages(start_pfn, nr_pages, altmap, pgmap);\n }\n #endif\n \ndiff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c\nindex 648d0c5602ec..4c1afab91996 100644\n--- a/arch/powerpc/mm/mem.c\n+++ b/arch/powerpc/mm/mem.c\n@@ -158,12 +158,13 @@ int __ref arch_add_memory(int nid, u64 start, u64 size,\n \treturn rc;\n }\n \n-void __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)\n+void __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap,\n+\t\t\t struct dev_pagemap *pgmap)\n {\n \tunsigned long start_pfn = start >> PAGE_SHIFT;\n \tunsigned long nr_pages = size >> PAGE_SHIFT;\n \n-\t__remove_pages(start_pfn, nr_pages, altmap);\n+\t__remove_pages(start_pfn, nr_pages, altmap, pgmap);\n \tarch_remove_linear_mapping(start, size);\n }\n #endif\ndiff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c\nindex decd7df40fa4..b0092fb842a3 100644\n--- a/arch/riscv/mm/init.c\n+++ b/arch/riscv/mm/init.c\n@@ -1717,9 +1717,10 @@ int __ref arch_add_memory(int nid, u64 start, u64 size, struct mhp_params *param\n \treturn ret;\n }\n \n-void __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)\n+void __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap,\n+\t\t\t struct dev_pagemap *pgmap)\n {\n-\t__remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT, altmap);\n+\t__remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT, altmap, pgmap);\n \tremove_linear_mapping(start, size);\n \tflush_tlb_all();\n }\ndiff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c\nindex 1f72efc2a579..11a689423440 100644\n--- a/arch/s390/mm/init.c\n+++ b/arch/s390/mm/init.c\n@@ -276,12 +276,13 @@ int arch_add_memory(int nid, u64 start, u64 size,\n \treturn rc;\n }\n \n-void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)\n+void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap,\n+\t\t\tstruct dev_pagemap *pgmap)\n {\n \tunsigned long start_pfn = start >> PAGE_SHIFT;\n \tunsigned long nr_pages = size >> PAGE_SHIFT;\n \n-\t__remove_pages(start_pfn, nr_pages, altmap);\n+\t__remove_pages(start_pfn, nr_pages, altmap, pgmap);\n \tvmem_remove_mapping(start, size);\n }\n #endif /* CONFIG_MEMORY_HOTPLUG */\ndiff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c\nindex df2261fa4f98..77b889b71cf3 100644\n--- a/arch/x86/mm/init_64.c\n+++ b/arch/x86/mm/init_64.c\n@@ -1288,12 +1288,13 @@ kernel_physical_mapping_remove(unsigned long start, unsigned long end)\n \tremove_pagetable(start, end, true, NULL);\n }\n \n-void __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)\n+void __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap,\n+\t\t\t struct dev_pagemap *pgmap)\n {\n \tunsigned long start_pfn = start >> PAGE_SHIFT;\n \tunsigned long nr_pages = size >> PAGE_SHIFT;\n \n-\t__remove_pages(start_pfn, nr_pages, altmap);\n+\t__remove_pages(start_pfn, nr_pages, altmap, pgmap);\n \tkernel_physical_mapping_remove(start, start + size);\n }\n #endif /* CONFIG_MEMORY_HOTPLUG */\ndiff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h\nindex 815e908c4135..7c9d66729c60 100644\n--- a/include/linux/memory_hotplug.h\n+++ b/include/linux/memory_hotplug.h\n@@ -135,9 +135,10 @@ static inline bool movable_node_is_enabled(void)\n \treturn movable_node_enabled;\n }\n \n-extern void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap);\n+extern void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap,\n+\t\t\t struct dev_pagemap *pgmap);\n extern void __remove_pages(unsigned long start_pfn, unsigned long nr_pages,\n-\t\t\t struct vmem_altmap *altmap);\n+\t\t\t struct vmem_altmap *altmap, struct dev_pagemap *pgmap);\n \n /* reasonably generic interface to expand the physical pages */\n extern int __add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,\n@@ -307,7 +308,8 @@ extern int sparse_add_section(int nid, unsigned long pfn,\n \t\tunsigned long nr_pages, struct vmem_altmap *altmap,\n \t\tstruct dev_pagemap *pgmap);\n extern void sparse_remove_section(unsigned long pfn, unsigned long nr_pages,\n-\t\t\t\t struct vmem_altmap *altmap);\n+\t\t\t\t struct vmem_altmap *altmap,\n+\t\t\t\t struct dev_pagemap *pgmap);\n extern struct zone *zone_for_pfn_range(enum mmop online_type,\n \t\tint nid, struct memory_group *group, unsigned long start_pfn,\n \t\tunsigned long nr_pages);\ndiff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c\nindex 0bad2aed2bde..7bfdc3a99688 100644\n--- a/mm/memory_hotplug.c\n+++ b/mm/memory_hotplug.c\n@@ -576,6 +576,7 @@ void remove_pfn_range_from_zone(struct zone *zone,\n * @pfn: starting pageframe (must be aligned to start of a section)\n * @nr_pages: number of pages to remove (must be multiple of section size)\n * @altmap: alternative device page map or %NULL if default memmap is used\n+ * @pgmap: device page map or %NULL if not ZONE_DEVICE\n *\n * Generic helper function to remove section mappings and sysfs entries\n * for the section of the memory we are removing. Caller needs to make\n@@ -583,7 +584,7 @@ void remove_pfn_range_from_zone(struct zone *zone,\n * calling offline_pages().\n */\n void __remove_pages(unsigned long pfn, unsigned long nr_pages,\n-\t\t struct vmem_altmap *altmap)\n+\t\t struct vmem_altmap *altmap, struct dev_pagemap *pgmap)\n {\n \tconst unsigned long end_pfn = pfn + nr_pages;\n \tunsigned long cur_nr_pages;\n@@ -598,7 +599,7 @@ void __remove_pages(unsigned long pfn, unsigned long nr_pages,\n \t\t/* Select all remaining pages up to the next section boundary */\n \t\tcur_nr_pages = min(end_pfn - pfn,\n \t\t\t\t SECTION_ALIGN_UP(pfn + 1) - pfn);\n-\t\tsparse_remove_section(pfn, cur_nr_pages, altmap);\n+\t\tsparse_remove_section(pfn, cur_nr_pages, altmap, pgmap);\n \t}\n }\n \n@@ -1425,7 +1426,7 @@ static void remove_memory_blocks_and_altmaps(u64 start, u64 size)\n \n \t\tremove_memory_block_devices(cur_start, memblock_size);\n \n-\t\tarch_remove_memory(cur_start, memblock_size, altmap);\n+\t\tarch_remove_memory(cur_start, memblock_size, altmap, NULL);\n \n \t\t/* Verify that all vmemmap pages have actually been freed. */\n \t\tWARN(altmap->alloc, \"Altmap not fully unmapped\");\n@@ -1468,7 +1469,7 @@ static int create_altmaps_and_memory_blocks(int nid, struct memory_group *group,\n \t\tret = create_memory_block_devices(cur_start, memblock_size, nid,\n \t\t\t\t\t\t params.altmap, group);\n \t\tif (ret) {\n-\t\t\tarch_remove_memory(cur_start, memblock_size, params.altmap);\n+\t\t\tarch_remove_memory(cur_start, memblock_size, params.altmap, NULL);\n \t\t\tkfree(params.altmap);\n \t\t\tgoto out;\n \t\t}\n@@ -1554,7 +1555,7 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)\n \t\t/* create memory block devices after memory was added */\n \t\tret = create_memory_block_devices(start, size, nid, NULL, group);\n \t\tif (ret) {\n-\t\t\tarch_remove_memory(start, size, params.altmap);\n+\t\t\tarch_remove_memory(start, size, params.altmap, NULL);\n \t\t\tgoto error;\n \t\t}\n \t}\n@@ -2266,7 +2267,7 @@ static int try_remove_memory(u64 start, u64 size)\n \t\t * No altmaps present, do the removal directly\n \t\t */\n \t\tremove_memory_block_devices(start, size);\n-\t\tarch_remove_memory(start, size, NULL);\n+\t\tarch_remove_memory(start, size, NULL, NULL);\n \t} else {\n \t\t/* all memblocks in the range have altmaps */\n \t\tremove_memory_blocks_and_altmaps(start, size);\ndiff --git a/mm/memremap.c b/mm/memremap.c\nindex 053842d45cb1..81766d822400 100644\n--- a/mm/memremap.c\n+++ b/mm/memremap.c\n@@ -97,10 +97,10 @@ static void pageunmap_range(struct dev_pagemap *pgmap, int range_id)\n \t\t\t\t PHYS_PFN(range_len(range)));\n \tif (pgmap->type == MEMORY_DEVICE_PRIVATE) {\n \t\t__remove_pages(PHYS_PFN(range->start),\n-\t\t\t PHYS_PFN(range_len(range)), NULL);\n+\t\t\t PHYS_PFN(range_len(range)), NULL, pgmap);\n \t} else {\n \t\tarch_remove_memory(range->start, range_len(range),\n-\t\t\t\tpgmap_altmap(pgmap));\n+\t\t\t\tpgmap_altmap(pgmap), pgmap);\n \t\tkasan_remove_zero_shadow(__va(range->start), range_len(range));\n \t}\n \tmem_hotplug_done();\ndiff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c\nindex a7b11248b989..3340f6d30b01 100644\n--- a/mm/sparse-vmemmap.c\n+++ b/mm/sparse-vmemmap.c\n@@ -665,7 +665,7 @@ static struct page * __meminit populate_section_memmap(unsigned long pfn,\n }\n \n static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages,\n-\t\tstruct vmem_altmap *altmap)\n+\t\tstruct vmem_altmap *altmap, struct dev_pagemap *pgmap)\n {\n \tunsigned long start = (unsigned long) pfn_to_page(pfn);\n \tunsigned long end = start + nr_pages * sizeof(struct page);\n@@ -746,7 +746,7 @@ static int fill_subsection_map(unsigned long pfn, unsigned long nr_pages)\n * usage map, but still need to free the vmemmap range.\n */\n static void section_deactivate(unsigned long pfn, unsigned long nr_pages,\n-\t\tstruct vmem_altmap *altmap)\n+\t\tstruct vmem_altmap *altmap, struct dev_pagemap *pgmap)\n {\n \tstruct mem_section *ms = __pfn_to_section(pfn);\n \tbool section_is_early = early_section(ms);\n@@ -784,7 +784,7 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages,\n \t * section_activate() and pfn_valid() .\n \t */\n \tif (!section_is_early)\n-\t\tdepopulate_section_memmap(pfn, nr_pages, altmap);\n+\t\tdepopulate_section_memmap(pfn, nr_pages, altmap, pgmap);\n \telse if (memmap)\n \t\tfree_map_bootmem(memmap);\n \n@@ -828,7 +828,7 @@ static struct page * __meminit section_activate(int nid, unsigned long pfn,\n \n \tmemmap = populate_section_memmap(pfn, nr_pages, nid, altmap, pgmap);\n \tif (!memmap) {\n-\t\tsection_deactivate(pfn, nr_pages, altmap);\n+\t\tsection_deactivate(pfn, nr_pages, altmap, pgmap);\n \t\treturn ERR_PTR(-ENOMEM);\n \t}\n \n@@ -889,13 +889,13 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn,\n }\n \n void sparse_remove_section(unsigned long pfn, unsigned long nr_pages,\n-\t\t\t struct vmem_altmap *altmap)\n+\t\tstruct vmem_altmap *altmap, struct dev_pagemap *pgmap)\n {\n \tstruct mem_section *ms = __pfn_to_section(pfn);\n \n \tif (WARN_ON_ONCE(!valid_section(ms)))\n \t\treturn;\n \n-\tsection_deactivate(pfn, nr_pages, altmap);\n+\tsection_deactivate(pfn, nr_pages, altmap, pgmap);\n }\n #endif /* CONFIG_MEMORY_HOTPLUG */\n", "prefixes": [ "v7", "3/6" ] }