Skip to content

zram: enable zram swap for the vms to reduce pressure#1770

Merged
brianmcgillion merged 1 commit intotiiuae:mainfrom
brianmcgillion:add-zram-swap
Feb 19, 2026
Merged

zram: enable zram swap for the vms to reduce pressure#1770
brianmcgillion merged 1 commit intotiiuae:mainfrom
brianmcgillion:add-zram-swap

Conversation

@brianmcgillion
Copy link
Copy Markdown
Collaborator

The vms, have limited memory in some cases and when performing tasks such as a resume, it can be seen that some drivers are failing to aquire enough memory to reinitialize. This is likely gonna bite in other situations, adding compressed zram can absorbe some of those pressures and allow the system to continue normally.

Description of Changes

Type of Change

  • New Feature
  • Bug Fix
  • Improvement / Refactor

Related Issues / Tickets

Checklist

  • Clear summary in PR description
  • Detailed and meaningful commit message(s)
  • Commits are logically organized and squashed if appropriate
  • Contribution guidelines followed
  • Ghaf documentation updated with the commit - https://tiiuae.github.io/ghaf/
  • Author has run make-checks and it passes
  • All automatic GitHub Action checks pass - see actions
  • Author has added reviewers and removed PR draft status

Testing Instructions

Applicable Targets

  • Orin AGX aarch64
  • Orin NX aarch64
  • Lenovo X1 x86_64
  • Dell Latitude x86_64
  • System 76 x86_64

Installation Method

  • Requires full re-installation
  • Can be updated with nixos-rebuild ... switch
  • Other:

Test Steps To Verify:

  1. ...

@brianmcgillion
Copy link
Copy Markdown
Collaborator Author

@vunnyso, @kajusnau - in testing I could see that already 54 mb of the zram was used on reboot of the audio vm. This is not on the store disk images, but the normal ones, so I think that answers the question about whether we need the swap or not. It should be cheaper, in terms of performance hit and impact on the system enabling the zram, than deflating the baloon for the guests. however, the system vms do not have baloon and it was turned off in the app vms.

I am not sure why balooning is not available at all in the sysvms? maybe @slakkala you might remember?

I am also thinking about increasing the swap size on the host, to provide even more flexability, if we are deflating.

The vms, have limited memory in some cases and when performing tasks
such as a resume, it can be seen that some drivers are failing to aquire
enough memory to reinitialize. This is likely gonna bite in other
situations, adding compressed zram can absorbe some of those pressures
and allow the system to continue normally.

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
@brianmcgillion brianmcgillion merged commit e9e3cde into tiiuae:main Feb 19, 2026
31 of 32 checks passed
@brianmcgillion brianmcgillion deleted the add-zram-swap branch February 19, 2026 22:48
@vunnyso
Copy link
Copy Markdown
Collaborator

vunnyso commented Feb 20, 2026

@vunnyso, @kajusnau - in testing I could see that already 54 mb of the zram was used on reboot of the audio vm. This is not on the store disk images, but the normal ones, so I think that answers the question about whether we need the swap or not. It should be cheaper, in terms of performance hit and impact on the system enabling the zram, than deflating the baloon for the guests. however, the system vms do not have baloon and it was turned off in the app vms.

I am not sure why balooning is not available at all in the sysvms? maybe @slakkala you might remember?

I am also thinking about increasing the swap size on the host, to provide even more flexability, if we are deflating.

Its nice addition @brianmcgillion, it will be interesting to compare the results if we run some performance tests.

And if we want to increase the swap size on the host, is there a specific test case we should target?

@milva-unikie
Copy link
Copy Markdown

Its nice addition @brianmcgillion, it will be interesting to compare the results if we run some performance tests.

We do, but at least our ballooning tests are now failing because there is too much memory available at the beginning of the test. We will have to adjust the tests.

@leivos-unikie
Copy link
Copy Markdown
Contributor

Its nice addition @brianmcgillion, it will be interesting to compare the results if we run some performance tests.

We do, but at least our ballooning tests are now failing because there is too much memory available at the beginning of the test. We will have to adjust the tests.

Seems that ballooning is not working at all. Total memory is at maximum on all vms and does not deflate.

@vunnyso
Copy link
Copy Markdown
Collaborator

vunnyso commented Feb 25, 2026

Seems that ballooning is not working at all. Total memory is at maximum on all vms and does not deflate.

Tested on Lenovo Gen12 with zram enabled, Total memory doesn't deflate.

Below data captured from chrome-vm using cat /proc/meminfo after 1 minute of system boot.

Metric Zram Enabled Zram Disabled
MemTotal 18,419,736 5,836,828
MemFree 4,957,128 4,963,776
MemAvailable 5,213,516 5,290,108
Buffers 8,452 8,356
Cached 521,624 542,424
SwapCached 0 0
Active 609,592 629,608
Inactive 42,272 41,956
Active(anon) 135,500 134,336
Inactive(anon) 0 0
Active(file) 474,092 495,272
Inactive(file) 42,272 41,956
Unevictable 12 12
Mlocked 0 0
SwapTotal 4,604,924 0
SwapFree 4,604,924 0
Zswap 0 0
Zswapped 0 0

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.

5 participants