Skip to content

Conversation

@laushunyu
Copy link

@laushunyu laushunyu commented Nov 19, 2025

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
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.89%. Comparing base (3c10d9c) to head (7af896b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5516      +/-   ##
==========================================
+ Coverage   82.87%   82.89%   +0.01%     
==========================================
  Files         270      270              
  Lines       27780    27798      +18     
==========================================
+ Hits        23024    23042      +18     
  Misses       4756     4756              
Flag Coverage Δ
5.10-m5n.metal 83.07% <100.00%> (+0.01%) ⬆️
5.10-m6a.metal 82.34% <100.00%> (+0.01%) ⬆️
5.10-m6g.metal 79.65% <100.00%> (+0.01%) ⬆️
5.10-m6i.metal 83.07% <100.00%> (+0.01%) ⬆️
5.10-m7a.metal-48xl 82.33% <100.00%> (+0.01%) ⬆️
5.10-m7g.metal 79.65% <100.00%> (+0.01%) ⬆️
5.10-m7i.metal-24xl 83.04% <100.00%> (+0.01%) ⬆️
5.10-m7i.metal-48xl 83.04% <100.00%> (+0.01%) ⬆️
5.10-m8g.metal-24xl 79.65% <100.00%> (+0.01%) ⬆️
5.10-m8g.metal-48xl 79.65% <100.00%> (+0.01%) ⬆️
6.1-m5n.metal 83.10% <100.00%> (+0.01%) ⬆️
6.1-m6a.metal 82.37% <100.00%> (+0.01%) ⬆️
6.1-m6g.metal 79.65% <100.00%> (+0.01%) ⬆️
6.1-m6i.metal 83.09% <100.00%> (+0.01%) ⬆️
6.1-m7a.metal-48xl 82.36% <100.00%> (+0.01%) ⬆️
6.1-m7g.metal 79.65% <100.00%> (+0.01%) ⬆️
6.1-m7i.metal-24xl 83.11% <100.00%> (+0.01%) ⬆️
6.1-m7i.metal-48xl 83.11% <100.00%> (+0.01%) ⬆️
6.1-m8g.metal-24xl 79.65% <100.00%> (+0.01%) ⬆️
6.1-m8g.metal-48xl 79.65% <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
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
Author

Thanks @JackThomson2 for the review! ♥️

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

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: 刘顺钰 <[email protected]>
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.

2 participants