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>,
sashiko-bot@kernel.org
Subject: [PATCH v2 2/2] kho: count bootmem in CmaTotal
Date: Sun, 29 Nov 2026 20:19:27 -0800 [thread overview]
Message-ID: <938471ed890adef632dba597bbbfb22f070b85e2.1796006500.git.chris@chrisdown.name> (raw)
In-Reply-To: <cover.1796006500.git.chris@chrisdown.name>
/proc/meminfo shows totalcma_pages as CmaTotal, but cma_new_area(),
cma_drop_area() and cma_activate_area() only update it for their own
areas. As such, bootmem is never in CmaTotal. Bootmem pageblocks are
MIGRATE_CMA though, so their free pages are in CmaFree, and without any
other CMA areas CmaFree ends up larger than CmaTotal. For example, with
4 GiB over two nodes and kho_bootmem=32M,512M,256M, which is 1056 MiB of
bootmem:
cold boot after KHO kexec
CmaTotal 0 kB 0 kB
CmaFree 1070844 kB 998984 kB
Let's add bootmem to totalcma_pages wherever kho_init() adds it to
zone->cma_pages, that is, after init_cma_reserved_pageblock() on a cold
boot, and in kho_account_incoming_bootmem() on a KHO boot. This happens
long after mem_init_print_info(), so the "Memory:" boot line doesn't
change.
With this applied, CmaTotal has bootmem accounted correctly after both
boots:
cold boot after KHO kexec
CmaTotal 1081344 kB 1081344 kB
CmaFree 1063116 kB 983884 kB
Fixes: 3dc92c311498 ("kexec: add Kexec HandOver (KHO) generation helpers")
Signed-off-by: Chris Down <chris@chrisdown.name>
---
kernel/liveupdate/kho_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/liveupdate/kho_core.c b/kernel/liveupdate/kho_core.c
index ac9f101b00b8..15fb892a4412 100644
--- a/kernel/liveupdate/kho_core.c
+++ b/kernel/liveupdate/kho_core.c
@@ -1890,6 +1890,7 @@ static void __init kho_account_incoming_bootmem(void)
continue;
page_zone(page)->cma_pages += pageblock_nr_pages;
+ totalcma_pages += pageblock_nr_pages;
}
}
}
@@ -1949,6 +1950,7 @@ static __init int kho_init(void)
for (pfn = base_pfn; pfn < base_pfn + count;
pfn += pageblock_nr_pages)
init_cma_reserved_pageblock(pfn_to_page(pfn));
+ totalcma_pages += count;
}
WARN_ON_ONCE(kho_debugfs_blob_add(&kho_out.dbg, "fdt",
--
2.56.1
next prev parent reply other threads:[~2026-11-30 4:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 4:19 [PATCH v2 0/2] mm, kho: count KHO bootmem in CmaTotal and in zoneinfo's cma Chris Down
2026-11-30 4:19 ` [PATCH v2 1/2] kho: count bootmem in zoneinfo's cma after a KHO kexec Chris Down
2026-11-30 4:19 ` Chris Down [this message]
2026-11-30 7:49 ` [PATCH v2 0/2] mm, kho: count KHO bootmem in CmaTotal and in zoneinfo's cma Mike Rapoport
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=938471ed890adef632dba597bbbfb22f070b85e2.1796006500.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 \
--cc=sashiko-bot@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
all inboxes | Powered by JetHome®