* Re: [PATCH v2] x86/mm: fix freeing of PMD-sized vmemmap pages [not found] <20260429-vmemmap-v2-1-8dfcacffd877@kernel.org> @ 2026-05-08 9:19 ` David Hildenbrand (Arm) 2026-05-08 9:23 ` Peter Zijlstra 0 siblings, 1 reply; 3+ messages in thread From: David Hildenbrand (Arm) @ 2026-05-08 9:19 UTC (permalink / raw) To: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin, Mike Rapoport (Microsoft), Jason Gunthorpe, Lu Baolu, Andrew Morton, Lance Yang Cc: linux-kernel, linux-mm, stable On 4/29/26 12:49, David Hildenbrand (Arm) wrote: > In commit bf9e4e30f353 ("x86/mm: use pagetable_free()"), we switched > from freeing non-boot page tables through __free_pages() to > pagetable_free(). > > However, the function is also called to free vmemmap pages. > > Given that vmemmap pages are not page tables, already the page_ptdesc(page) > is wrong. But worse, pagetable_free() calls > > __free_pages(page, compound_order(page)); > > As vmemmap pages are not compound pages (see vmemmap_alloc_block()) -- > except for HVO, which doesn't apply here -- we will only free the first > page when freeing a PMD-sized vmemmap page, leaking the other ones. > > Fix it by properly decoupling pagetable and vmemmap freeing. > free_pagetable() no longer has to mess with SECTION_INFO, as only the > vmemmap is marked like that in register_page_bootmem_memmap(). > > The indentation in remove_pmd_table() is messed up, let's fix that > while touching it. > > Note that we'll try to get rid of that bootmem info handling soon. For > now, we'll handle it similar to free_pagetable(), just avoiding the > ifdef. > > Tested-by: Lance Yang <lance.yang@linux.dev> > Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > Fixes: bf9e4e30f353 ("x86/mm: use pagetable_free()") > Cc: stable@vger.kernel.org > Signed-off-by: David Hildenbrand (Arm) <david@kernel.org> > --- > Reproduced and tested with a simple VM with a virtio-mem device, > repeatedly adding and removing memory. > > Found by code inspection while working on bootmem_info removal. > --- @x86 maintainers, do you want to take this through your tree or should we merge this through the MM tree? I have another MM series coming up that will touch this code (no fixes, though). -- Cheers, David ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] x86/mm: fix freeing of PMD-sized vmemmap pages 2026-05-08 9:19 ` [PATCH v2] x86/mm: fix freeing of PMD-sized vmemmap pages David Hildenbrand (Arm) @ 2026-05-08 9:23 ` Peter Zijlstra 2026-05-08 10:51 ` David Hildenbrand (Arm) 0 siblings, 1 reply; 3+ messages in thread From: Peter Zijlstra @ 2026-05-08 9:23 UTC (permalink / raw) To: David Hildenbrand (Arm) Cc: Dave Hansen, Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin, Mike Rapoport (Microsoft), Jason Gunthorpe, Lu Baolu, Andrew Morton, Lance Yang, linux-kernel, linux-mm, stable On Fri, May 08, 2026 at 11:19:26AM +0200, David Hildenbrand (Arm) wrote: > On 4/29/26 12:49, David Hildenbrand (Arm) wrote: > > In commit bf9e4e30f353 ("x86/mm: use pagetable_free()"), we switched > > from freeing non-boot page tables through __free_pages() to > > pagetable_free(). > > > > However, the function is also called to free vmemmap pages. > > > > Given that vmemmap pages are not page tables, already the page_ptdesc(page) > > is wrong. But worse, pagetable_free() calls > > > > __free_pages(page, compound_order(page)); > > > > As vmemmap pages are not compound pages (see vmemmap_alloc_block()) -- > > except for HVO, which doesn't apply here -- we will only free the first > > page when freeing a PMD-sized vmemmap page, leaking the other ones. > > > > Fix it by properly decoupling pagetable and vmemmap freeing. > > free_pagetable() no longer has to mess with SECTION_INFO, as only the > > vmemmap is marked like that in register_page_bootmem_memmap(). > > > > The indentation in remove_pmd_table() is messed up, let's fix that > > while touching it. > > > > Note that we'll try to get rid of that bootmem info handling soon. For > > now, we'll handle it similar to free_pagetable(), just avoiding the > > ifdef. > > > > Tested-by: Lance Yang <lance.yang@linux.dev> > > Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > > Fixes: bf9e4e30f353 ("x86/mm: use pagetable_free()") > > Cc: stable@vger.kernel.org > > Signed-off-by: David Hildenbrand (Arm) <david@kernel.org> > > --- > > Reproduced and tested with a simple VM with a virtio-mem device, > > repeatedly adding and removing memory. > > > > Found by code inspection while working on bootmem_info removal. > > --- > > @x86 maintainers, do you want to take this through your tree or should we merge > this through the MM tree? > > I have another MM series coming up that will touch this code (no fixes, though). I'm thinking this should go in rather more urgent, yes? It looks good to me, Dave you want to stick this in x86/urgent? ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] x86/mm: fix freeing of PMD-sized vmemmap pages 2026-05-08 9:23 ` Peter Zijlstra @ 2026-05-08 10:51 ` David Hildenbrand (Arm) 0 siblings, 0 replies; 3+ messages in thread From: David Hildenbrand (Arm) @ 2026-05-08 10:51 UTC (permalink / raw) To: Peter Zijlstra Cc: Dave Hansen, Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin, Mike Rapoport (Microsoft), Jason Gunthorpe, Lu Baolu, Andrew Morton, Lance Yang, linux-kernel, linux-mm, stable On 5/8/26 11:23, Peter Zijlstra wrote: > On Fri, May 08, 2026 at 11:19:26AM +0200, David Hildenbrand (Arm) wrote: >> On 4/29/26 12:49, David Hildenbrand (Arm) wrote: >>> In commit bf9e4e30f353 ("x86/mm: use pagetable_free()"), we switched >>> from freeing non-boot page tables through __free_pages() to >>> pagetable_free(). >>> >>> However, the function is also called to free vmemmap pages. >>> >>> Given that vmemmap pages are not page tables, already the page_ptdesc(page) >>> is wrong. But worse, pagetable_free() calls >>> >>> __free_pages(page, compound_order(page)); >>> >>> As vmemmap pages are not compound pages (see vmemmap_alloc_block()) -- >>> except for HVO, which doesn't apply here -- we will only free the first >>> page when freeing a PMD-sized vmemmap page, leaking the other ones. >>> >>> Fix it by properly decoupling pagetable and vmemmap freeing. >>> free_pagetable() no longer has to mess with SECTION_INFO, as only the >>> vmemmap is marked like that in register_page_bootmem_memmap(). >>> >>> The indentation in remove_pmd_table() is messed up, let's fix that >>> while touching it. >>> >>> Note that we'll try to get rid of that bootmem info handling soon. For >>> now, we'll handle it similar to free_pagetable(), just avoiding the >>> ifdef. >>> >>> Tested-by: Lance Yang <lance.yang@linux.dev> >>> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> >>> Fixes: bf9e4e30f353 ("x86/mm: use pagetable_free()") >>> Cc: stable@vger.kernel.org >>> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org> >>> --- >>> Reproduced and tested with a simple VM with a virtio-mem device, >>> repeatedly adding and removing memory. >>> >>> Found by code inspection while working on bootmem_info removal. >>> --- >> >> @x86 maintainers, do you want to take this through your tree or should we merge >> this through the MM tree? >> >> I have another MM series coming up that will touch this code (no fixes, though). > > I'm thinking this should go in rather more urgent, yes? Yes, please :) -- Cheers, David ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-08 10:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260429-vmemmap-v2-1-8dfcacffd877@kernel.org>
2026-05-08 9:19 ` [PATCH v2] x86/mm: fix freeing of PMD-sized vmemmap pages David Hildenbrand (Arm)
2026-05-08 9:23 ` Peter Zijlstra
2026-05-08 10:51 ` David Hildenbrand (Arm)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox