From: Chris Down <chris@chrisdown.name>
To: Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>,
kexec@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
David Hildenbrand <david@kernel.org>
Subject: [PATCH 0/2] mm, kho: count KHO bootmem in CmaTotal and in zoneinfo's cma
Date: Sat, 28 Nov 2026 21:01:46 -0800 [thread overview]
Message-ID: <cover.1795928397.git.chris@chrisdown.name> (raw)
KHO bootmem is handed to the buddy allocator in MIGRATE_CMA pageblocks,
so its free pages show up in CmaFree, but two of the CMA counters leave
it out. CmaTotal in /proc/meminfo never includes it, and the cma line in
/proc/zoneinfo includes it after a cold boot but goes to 0 after a KHO
kexec.
Patch 1 counts bootmem in zone->cma_pages after a KHO kexec, as
kho_init() already does on a cold boot. Patch 2 then adds bootmem to
totalcma_pages after both kinds of boot.
After a KHO kexec, part of bootmem is still held by early boot, like the
kernel image and initrd that kexec loaded there and some of the memmap.
Those pages are counted too, because they're still in MIGRATE_CMA
pageblocks and some of them come back as free CMA pages later on, such
as the init sections and memmap pages freed by hugetlb vmemmap
optimisation. Leaving them out would let CmaFree overtake CmaTotal
again.
The bootmem added to both counters comes from kho_init(), which runs long
after mem_init_print_info(), so the "Memory:" boot line doesn't change.
This came up in the thread about making bootmem visible to monitoring
[0].
[0]: https://lore.kernel.org/r/2vxz4id3wgu7.fsf@kernel.org
Chris Down (2):
kho: count bootmem in zoneinfo's cma after a KHO kexec
kho: count bootmem in CmaTotal
kernel/liveupdate/kexec_handover.c | 35 ++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
base-commit: a8d435799f3c87231bca0c245fd9e60f31e45135
--
2.56.1
next reply other threads:[~2026-11-29 5:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 5:01 Chris Down [this message]
2026-11-29 5:01 ` [PATCH 1/2] kho: count bootmem in zoneinfo's cma after a KHO kexec Chris Down
2026-11-29 19:48 ` Mike Rapoport
2026-11-29 5:01 ` [PATCH 2/2] kho: count bootmem in CmaTotal Chris Down
2026-11-29 19:50 ` Mike Rapoport
2026-11-29 5:11 ` [PATCH 0/2] mm, kho: count KHO bootmem in CmaTotal and in zoneinfo's cma sashiko-bot
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=cover.1795928397.git.chris@chrisdown.name \
--to=chris@chrisdown.name \
--cc=david@kernel.org \
--cc=graf@amazon.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@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