Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Pratyush Yadav <pratyush@kernel.org>
To: Chris Down <chris@chrisdown.name>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>,
	 Mike Rapoport <rppt@kernel.org>,
	 Pratyush Yadav <pratyush@kernel.org>,
	 Alexander Graf <graf@amazon.com>,
	 Baoquan He <baoquan.he@linux.dev>,
	 Jonathan Corbet <corbet@lwn.net>,
	 Shuah Khan <skhan@linuxfoundation.org>,
	kexec@lists.infradead.org,  linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,  linux-doc@vger.kernel.org,
	linux-kselftest@vger.kernel.org,  kernel-team@meta.com
Subject: Re: [PATCH 2/9] kho: Make bootmem reservations visible to fleet monitoring
Date: Thu, 26 Nov 2026 19:08:48 +0000	[thread overview]
Message-ID: <2vxz4id3wgu7.fsf@kernel.org> (raw)
In-Reply-To: <20261113003059.056dd036a6546756@chrisdown.name> (Chris Down's message of "Fri, 13 Nov 2026 00:30:59 -0800")

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

  parent reply	other threads:[~2026-11-26 19:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  7:52 [PATCH 0/9] kho, liveupdate: KHO/LUO observability Chris Down
2026-11-11  7:52 ` [PATCH 1/9] kho: Reclaim the metadata page left reserved after kexec Chris Down
2026-11-11 11:08   ` Breno Leitao
2026-11-11 22:29   ` Pasha Tatashin
2026-11-13  8:30     ` Chris Down
2026-11-19 14:54   ` Pasha Tatashin
2026-11-11  7:53 ` [PATCH 2/9] kho: Make bootmem reservations visible to fleet monitoring Chris Down
2026-11-11 23:14   ` Pasha Tatashin
2026-11-13  8:30     ` Chris Down
2026-11-15 19:11       ` Mike Rapoport
2026-11-26 19:08       ` Pratyush Yadav [this message]
2026-11-11  7:53 ` [PATCH 3/9] liveupdate: Make failed retrieves distinguishable from dropped files Chris Down
2026-11-11  7:53 ` [PATCH 4/9] selftests/liveupdate: Catch incorrect file accounting across kexec Chris Down
2026-11-11  7:53 ` [PATCH 5/9] selftests/kho: Catch missing or zero bootmem reports before kexec Chris Down
2026-11-11  7:53 ` [PATCH 6/9] kho: Expose rejected handovers that look like cold boots Chris Down
2026-11-11  7:53 ` [PATCH 7/9] kho: Report how much handover memory is preserved and restored Chris Down
2026-11-11  7:53 ` [PATCH 8/9] liveupdate: Expose the sequence number for consecutive live updates Chris Down
2026-11-11  7:53 ` [PATCH 9/9] selftests/liveupdate: Check handover revival, sequence and memory stats Chris Down

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=2vxz4id3wgu7.fsf@kernel.org \
    --to=pratyush@kernel.org \
    --cc=baoquan.he@linux.dev \
    --cc=chris@chrisdown.name \
    --cc=corbet@lwn.net \
    --cc=graf@amazon.com \
    --cc=kernel-team@meta.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=rppt@kernel.org \
    --cc=skhan@linuxfoundation.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