Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lance Yang <lance.yang@linux.dev>
To: david@kernel.org
Cc: osalvador@suse.de, davem@davemloft.net, andreas@gaisler.com,
	rppt@kernel.org, akpm@linux-foundation.org,
	agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com,
	hca@linux.ibm.com, gor@linux.ibm.com, borntraeger@linux.ibm.com,
	svens@linux.ibm.com, maddy@linux.ibm.com, mpe@ellerman.id.au,
	npiggin@gmail.com, chleroy@kernel.org, ljs@kernel.org,
	liam@infradead.org, vbabka@kernel.org, surenb@google.com,
	mhocko@suse.com, sparclinux@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	Lance Yang <lance.yang@linux.dev>
Subject: Re: [PATCH 4/8] mm/bootmem_info: remove call to kmemleak_free_part_phys()
Date: Wed, 20 May 2026 20:15:05 +0800	[thread overview]
Message-ID: <20260520121505.60854-1-lance.yang@linux.dev> (raw)
In-Reply-To: <b2a8e918-7ed2-46b4-bf59-e65dc9359310@kernel.org>


On Tue, May 12, 2026 at 10:45:03AM +0200, David Hildenbrand (Arm) wrote:
>On 5/12/26 10:34, Oscar Salvador wrote:
[...]
>>> diff --git a/mm/bootmem_info.c b/mm/bootmem_info.c
>>> index 6e2aaab3dca9..74c1116626c8 100644
>>> --- a/mm/bootmem_info.c
>>> +++ b/mm/bootmem_info.c
>>> @@ -32,7 +32,6 @@ void put_page_bootmem(struct page *page)
>>>  
>>>  	if (page_ref_dec_return(page) == 1) {
>>>  		set_page_private(page, 0);
>>> -		kmemleak_free_part_phys(PFN_PHYS(page_to_pfn(page)), PAGE_SIZE);
>> 
>> A bit odd that kmemleak_free_part_phys() did not complain if we never
>> did kmemleak_alloc_phys() for these pages?
>
>delete_object_part() calls __find_and_remove_object() and essentially just skips
>if it didn't find anything.
>
>Maybe the kmemleak_warn() would trigger, but it's guarded by "#ifdef DEBUG" ...

Right! With kmemleak DEBUG enabled, kmemleak_free_part_phys() does warns
whenever delete_object_part() cannot find the corresponding physical
object ...

Before this patch, booting with:

"kmemleak=on hugetlb_free_vmemmap=on default_hugepagesz=2M hugepagesz=2M hugepages=512"

I got a lot of warnings, something like:

[   44.481883] kmemleak: Partially freeing unknown object at 0x2acc59000 (size 4096)
[   44.482754] CPU: 2 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.1.0-rc3 #206 PREEMPT(full)
[   44.482758] Hardware name: Red Hat KVM, BIOS 1.11.0-2.el7 04/01/2014
[   44.482760] Call Trace:
[   44.482762]  <TASK>
[   44.482764]  dump_stack_lvl+0x60/0x90
[   44.482769]  dump_stack+0x14/0x1a
[   44.482774]  delete_object_part.cold+0x28/0x2d
[   44.482779]  kmemleak_free_part_phys+0x67/0x80
[   44.482783]  put_page_bootmem+0xc0/0x100
[   44.482787]  free_vmemmap_page_list+0x13e/0x230
[   44.482791]  __hugetlb_vmemmap_optimize_folios+0x351/0x430
[...]

So, yeah, looks like these calls are trying to free physical kmemleak
objects that are no longer tracked after memmap_alloc() started using
MEMBLOCK_ALLOC_NOLEAKTRACE :)

With this patch applied, those stale calls are gone, and so are the
warnings :P

Tested-by: Lance Yang <lance.yang@linux.dev>


  reply	other threads:[~2026-05-20 12:15 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 14:05 [PATCH 0/8] mm: remove CONFIG_HAVE_BOOTMEM_INFO_NODE (Part 1) David Hildenbrand (Arm)
2026-05-11 14:05 ` [PATCH 1/8] sparc/mm: remove register_page_bootmem_info() David Hildenbrand (Arm)
2026-05-12  8:28   ` Oscar Salvador
2026-05-13  8:25   ` Mike Rapoport
2026-05-18  6:55   ` Lance Yang
2026-05-11 14:05 ` [PATCH 2/8] mm/bootmem_info: drop initialization of page->lru David Hildenbrand (Arm)
2026-05-12  8:28   ` Oscar Salvador
2026-05-13  8:27   ` Mike Rapoport
2026-05-18  7:49   ` Lance Yang
2026-05-11 14:05 ` [PATCH 3/8] mm/bootmem_info: stop using PG_private David Hildenbrand (Arm)
2026-05-12  8:30   ` Oscar Salvador
2026-05-13  8:29   ` Mike Rapoport
2026-05-19  2:56   ` Lance Yang
2026-05-11 14:05 ` [PATCH 4/8] mm/bootmem_info: remove call to kmemleak_free_part_phys() David Hildenbrand (Arm)
2026-05-12  8:34   ` Oscar Salvador
2026-05-12  8:45     ` David Hildenbrand (Arm)
2026-05-20 12:15       ` Lance Yang [this message]
2026-05-13  8:31   ` Mike Rapoport
2026-05-11 14:05 ` [PATCH 5/8] mm/bootmem_info: stop marking the pgdat as NODE_INFO David Hildenbrand (Arm)
2026-05-12  7:45   ` Michal Hocko
2026-05-12  7:47     ` David Hildenbrand (Arm)
2026-05-12  8:36   ` Oscar Salvador
2026-05-13  8:35   ` Mike Rapoport
2026-05-20 15:30   ` Lance Yang
2026-05-11 14:05 ` [PATCH 6/8] mm/bootmem_info: stop marking mem_section_usage as MIX_SECTION_INFO David Hildenbrand (Arm)
2026-05-12  8:37   ` Oscar Salvador
2026-05-13  8:38   ` Mike Rapoport
2026-05-21  5:03   ` Lance Yang
2026-05-11 14:05 ` [PATCH 7/8] s390/mm: use free_reserved_page() in vmem_free_pages() David Hildenbrand (Arm)
2026-05-11 14:21   ` Heiko Carstens
2026-05-11 14:24     ` David Hildenbrand (Arm)
2026-05-11 15:22       ` Heiko Carstens
2026-05-11 15:28         ` David Hildenbrand (Arm)
2026-05-12  8:38   ` Oscar Salvador
2026-05-13  8:40   ` Mike Rapoport
2026-05-21  8:39   ` Lance Yang
2026-05-11 14:05 ` [PATCH 8/8] powerpc/mm: remove CONFIG_HAVE_BOOTMEM_INFO_NODE David Hildenbrand (Arm)
2026-05-12  8:43   ` Oscar Salvador
2026-05-13  3:25   ` Ritesh Harjani
2026-05-13  8:41   ` Mike Rapoport
2026-05-21  8:47   ` Lance Yang
2026-05-12  7:46 ` [PATCH 0/8] mm: remove CONFIG_HAVE_BOOTMEM_INFO_NODE (Part 1) Michal Hocko
2026-05-12  7:48   ` David Hildenbrand (Arm)
2026-05-12  8:45 ` Oscar Salvador
2026-05-12  8:51   ` David Hildenbrand (Arm)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260520121505.60854-1-lance.yang@linux.dev \
    --to=lance.yang@linux.dev \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreas@gaisler.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=davem@davemloft.net \
    --cc=david@kernel.org \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=ljs@kernel.org \
    --cc=maddy@linux.ibm.com \
    --cc=mhocko@suse.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=osalvador@suse.de \
    --cc=rppt@kernel.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=svens@linux.ibm.com \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox