Skip to content

feat: support linux v6.12 balloon stat - #5516

Merged
JackThomson2 merged 2 commits into
firecracker-microvm:mainfrom
laushunyu:feat-balloon-stat
Nov 28, 2025
Merged

feat: support linux v6.12 balloon stat#5516
JackThomson2 merged 2 commits into
firecracker-microvm:mainfrom
laushunyu:feat-balloon-stat

Conversation

@laushunyu

@laushunyu laushunyu commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

Changes

Linux v6.12 add more balloon stat: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/diff/include/uapi/linux/virtio_balloon.h?id=v6.12&id2=v6.11

related commit: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=74c025c5d7e4ac7c7ad269c1ee64da4bdfe4770c

I supported it, when kernel >= v6.12, stat:

# curl --unix-socket firecracker.sock http://localhost/balloon/statistics
{"target_pages":1835008,"actual_pages":1835008,"target_mib":7168,"actual_mib":7168,"swap_in":0,"swap_out":0,"major_faults":1360,"minor_faults":126031,"free_memory":142065664,"total_memory":8351473664,"available_memory":437428224,"disk_caches":470376448,"hugetlb_allocations":0,"hugetlb_failures":0,"oom_kill":0,"alloc_stall":0,"async_scan":524492800,"direct_scan":0,"async_reclaim":413532160,"direct_reclaim":0}

otherwise:

# curl --unix-socket firecracker.sock http://localhost/balloon/statistics
{"target_pages":1806336,"actual_pages":1806336,"target_mib":7056,"actual_mib":7056,"swap_in":0,"swap_out":0,"major_faults":1777,"minor_faults":788590,"free_memory":131616768,"total_memory":8352452608,"available_memory":536666112,"disk_caches":577331200,"hugetlb_allocations":0,"hugetlb_failures":0}

Reason

I run firecrack with vmlinux v6.12, and balloon stat crashed:

stat api show no memory stat.

# curl --unix-socket firecracker.sock http://localhost/balloon/statistics
{"target_pages":1806336,"actual_pages":1806336,"target_mib":7056,"actual_mib":7056}

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

@codecov

codecov Bot commented Nov 19, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.38%. Comparing base (0aa8f6c) to head (2a57348).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5516   +/-   ##
=======================================
  Coverage   83.38%   83.38%           
=======================================
  Files         277      277           
  Lines       29219    29237   +18     
=======================================
+ Hits        24363    24380   +17     
- Misses       4856     4857    +1     
Flag Coverage Δ
5.10-m5n.metal 83.61% <100.00%> (+0.01%) ⬆️
5.10-m6a.metal 82.95% <100.00%> (+0.01%) ⬆️
5.10-m6g.metal 80.36% <100.00%> (+0.01%) ⬆️
5.10-m6i.metal 83.61% <100.00%> (+<0.01%) ⬆️
5.10-m7a.metal-48xl 82.94% <100.00%> (+0.01%) ⬆️
5.10-m7g.metal 80.36% <100.00%> (+0.01%) ⬆️
5.10-m7i.metal-24xl 83.59% <100.00%> (+0.01%) ⬆️
5.10-m7i.metal-48xl 83.59% <100.00%> (+<0.01%) ⬆️
5.10-m8g.metal-24xl 80.36% <100.00%> (+0.01%) ⬆️
5.10-m8g.metal-48xl 80.36% <100.00%> (+0.01%) ⬆️
6.1-m5n.metal 83.64% <100.00%> (+0.01%) ⬆️
6.1-m6a.metal 82.98% <100.00%> (+<0.01%) ⬆️
6.1-m6g.metal 80.36% <100.00%> (+0.01%) ⬆️
6.1-m6i.metal 83.64% <100.00%> (+<0.01%) ⬆️
6.1-m7a.metal-48xl 82.97% <100.00%> (+0.01%) ⬆️
6.1-m7g.metal 80.36% <100.00%> (+0.01%) ⬆️
6.1-m7i.metal-24xl 83.66% <100.00%> (+0.01%) ⬆️
6.1-m7i.metal-48xl 83.65% <100.00%> (+0.01%) ⬆️
6.1-m8g.metal-24xl 80.35% <100.00%> (+0.01%) ⬆️
6.1-m8g.metal-48xl 80.36% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JackThomson2

Copy link
Copy Markdown
Contributor

Thanks @laushunyu for the PR looks good!

The rust style checks seem to be failing, you can run tools/devtool fmt and tools/devtool checkstyle to fix and verify that's been resolved. Also can we have a small description of the changes in the commit message.

@laushunyu
laushunyu force-pushed the feat-balloon-stat branch 2 times, most recently from 667e6ac to 74f510c Compare November 20, 2025 03:14
@laushunyu

Copy link
Copy Markdown
Contributor Author

Thanks @JackThomson2 for the review! ♥️

I've pushed the fixes and updated the commit message. Please take another look.

@laushunyu
laushunyu force-pushed the feat-balloon-stat branch 2 times, most recently from 7af896b to b1b458e Compare November 24, 2025 02:56
@laushunyu

Copy link
Copy Markdown
Contributor Author

hello~ @pb8o @Manciukic @kalyazin @xmarcalx

Could you review this when convenient? Thanks!

@Manciukic Manciukic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change lgtm, just a minor reword on the changelog entry.

Also, I think we should log an issue to do some followup work to not fail close but just log it and add a test to detect new features being added.

Comment thread CHANGELOG.md Outdated
@Manciukic

Copy link
Copy Markdown
Contributor

It'd also be nice to add the new metrics in docs/ballooning.md

@JackThomson2

Copy link
Copy Markdown
Contributor

We could also have these in the swagger definition: https://github.com/firecracker-microvm/firecracker/blob/main/src/firecracker/swagger/firecracker.yaml#L787

@laushunyu

Copy link
Copy Markdown
Contributor Author

hi~ @Manciukic @JackThomson2

I update the balloon doc, changelog and swagger.

@Manciukic Manciukic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more nits on the doc, but we're almost there!
Also, could you squash the commits into a single one?

Update: please, also make sure to run ./tools/devtool checkstyle to verify the CI style checks will pass to avoid back-and-forths for style issues.

Comment thread docs/ballooning.md Outdated
Comment thread docs/ballooning.md Outdated
Comment thread src/firecracker/swagger/firecracker.yaml Outdated
Comment thread docs/ballooning.md Outdated
@laushunyu
laushunyu force-pushed the feat-balloon-stat branch 4 times, most recently from 54a3ec8 to 11ea739 Compare November 27, 2025 06:25
@laushunyu

Copy link
Copy Markdown
Contributor Author

hi, @Manciukic

Thanks for your reviewing🤗, I’ve updated the doc.

Comment thread docs/ballooning.md Outdated
Comment thread docs/ballooning.md Outdated
@JackThomson2

Copy link
Copy Markdown
Contributor

Thanks for updating the docs, we're almost there 😃

When the guest runs a kernel >= v6.12, the balloon stats API
will not crash and will return additional metrics: oom_kill,
alloc_stall, async_scan, direct_scan, async_reclaim, direct_reclaim

these metrics can be found in the related kernel commit:
74c025c5d7e4ac7c7ad269c1ee64da4bdfe4770c

To avoid any misunderstanding, these metrics are omitted when
the guest kernel < v6.12.

Signed-off-by: 刘顺钰 <shunyu.liu@chaitin.com>
@JackThomson2
JackThomson2 enabled auto-merge (rebase) November 28, 2025 10:09
@JackThomson2

Copy link
Copy Markdown
Contributor

Thank you for your contribution!

@JackThomson2
JackThomson2 merged commit 5a3419f into firecracker-microvm:main Nov 28, 2025
7 checks passed
@laushunyu
laushunyu deleted the feat-balloon-stat branch November 30, 2025 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants