Re: [PATCH 2/9] kho: Make bootmem reservations visible to fleet monitoring
From: Pratyush Yadav
Date: Thu Nov 26 2026 - 14:08:59 EST
On Fri, Nov 13 2026, Chris Down wrote:
> Pasha Tatashin writes:
[...]
>>> Today the collector would have to sum kho/out/bootmem_len in debugfs,
>>> which isn't a userspace ABI. In /proc/meminfo, free bootmem contributes
>>> to CmaFree, but the reservation doesn't contribute to CmaTotal. The cma
>>
>>Is this a different bug?
>
> I think so, yes. Bootmem pageblocks are MIGRATE_CMA, so their free pages are
> counted in NR_FREE_CMA_PAGES, but totalcma_pages only counts the areas that
> mm/cma.c knows about.
>
> zone->cma_pages is a separate problem. It only gets bootmem added by
> init_cma_reserved_pageblock() in kho_init(), and on a KHO boot we return before
> we get there.
>
> I can send patches for those separately if you agree that bootmem should be
> counted in both. It wouldn't give us the bootmem size though, because CmaTotal
> would still include any other CMA areas.
I have a internal bug assigned to me to fix this. It would be great if
you could fix it for me. I'd owe you a beer ;-)
On cold boot it is pretty easy. Call cma_init_reserved_mem() on each
bootmem region.
On a KHO boot it gets tricky. Not all of bootmem is CMA, since some of
it is given out to early boot allocators like memmap. So we need to
count the pageblocks that we mark as MIGRATE_CMA during MM init. And
then update totalcma_pages directly, which already sounds kinda iffy.
Plugging the accounting directly into kho_bootmem_migratetype() might
work, but I don't like giving it a side effect. Maybe we do it directly
in pageblock_migratetype_init_range() and __init_deferred_page()?
None of it is super elegant and I never got around to figuring out
something good.
>
>>I have some concerns about exposing this as a stable API. What if we get
>>rid of bootmem or make it resizable? We only recently renamed it from
>>scratch to bootmem, and we have been exploring for way to optimize it.
>>
>>I would keep this exposed under /sys/kernel/debug/kho/bootmem_size for
>>now, and not worry about it being stable.
>
> That's fair. I'll move it to /sys/kernel/debug/kho/bootmem_size in v2, and we
> can look at sysfs again once bootmem has settled down.
Is it really that hard for your collector to sum up the areas. I don't
mind this change since it is in debugfs and very simple, but I'm curious
if you really need it.
[...]
--
Regards,
Pratyush Yadav