linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Sumanth Korikkar <sumanthk@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	linux-s390 <linux-s390@vger.kernel.org>
Subject: Re: [PATCH] mm: fix accounting of memmap pages for early sections
Date: Mon, 4 Aug 2025 14:27:20 +0200	[thread overview]
Message-ID: <1e259390-67b1-4d08-8174-a65f1fc9eccc@redhat.com> (raw)
In-Reply-To: <20250804090859.727207-1-sumanthk@linux.ibm.com>

On 04.08.25 11:08, Sumanth Korikkar wrote:
> memmap pages  can be allocated either from the memblock (boot) allocator
> during early boot or from the buddy allocator.
> 
> When these memmap pages are removed via arch_remove_memory(), the
> deallocation path depends on their source:
> 
> * For pages from the buddy allocator, depopulate_section_memmap() is
>    called, which also decrements the count of nr_memmap_pages.
> 
> * For pages from the boot allocator, free_map_bootmem() is called. But
>    it currently does not adjust the nr_memmap_boot_pages.
> 
> To fix this inconsistency, update free_map_bootmem() to also decrement
> the nr_memmap_boot_pages count by invoking memmap_boot_pages_add(),
> mirroring how free_vmemmap_page() handles this for boot-allocated pages.
> 
> This ensures correct tracking of memmap pages regardless of allocation
> source.
> 
> Cc: stable@vger.kernel.org
> Fixes: 15995a352474 ("mm: report per-page metadata information")
> Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
> ---
>   mm/sparse.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 3c012cf83cc2..d7c128015397 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -688,6 +688,7 @@ static void free_map_bootmem(struct page *memmap)
>   	unsigned long start = (unsigned long)memmap;
>   	unsigned long end = (unsigned long)(memmap + PAGES_PER_SECTION);
>   
> +	memmap_boot_pages_add(-1L * (DIV_ROUND_UP(end - start, PAGE_SIZE)));
>   	vmemmap_free(start, end, NULL);
>   }
>   

Looks good to me. But now I wonder about !CONFIG_SPARSEMEM_VMEMMAP, 
where neither depopulate_section_memmap() nor free_map_bootmem() adjust 
anything?

Which makes me wonder whether we should be moving that to 
section_deactivate().

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-08-04 12:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-04  9:08 Sumanth Korikkar
2025-08-04 12:27 ` David Hildenbrand [this message]
2025-08-04 13:39   ` Sumanth Korikkar
  -- strict thread matches above, loose matches on Subject: below --
2025-08-04  8:40 Sumanth Korikkar

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=1e259390-67b1-4d08-8174-a65f1fc9eccc@redhat.com \
    --to=david@redhat.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=sumanthk@linux.ibm.com \
    /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