Thanks to visit codestin.com
Credit goes to github.com

Skip to content

vmm: add per-zone mergeable option to --memory-zone - #7983

Merged
rbradford merged 1 commit into
cloud-hypervisor:mainfrom
inwardvessel:zone_specific_mergeable_flag
Apr 11, 2026
Merged

rbradford merged 1 commit into
cloud-hypervisor:mainfrom
inwardvessel:zone_specific_mergeable_flag

Conversation

@inwardvessel

Copy link
Copy Markdown
Contributor

Add a mergeable field to MemoryZoneConfig so that KSM page merging can be enabled selectively per memory zone rather than globally for all guest RAM.

Previously, MADV_MERGEABLE was only controllable via the top-level --memory mergeable=on flag, which applied uniformly to all regions. With this change, users can leave boot memory unmerged while enabling KSM only on hotplug zones:

--memory size=0,hotplug_method=virtio-mem
--memory-zone id=boot,size=512M,shared=on,mergeable=off
--memory-zone id=hotplug,size=256M,hotplug_size=1G,shared=off,mergeable=on

The MemoryZone runtime struct now carries the mergeable flag so that both allocate_address_space and add_ram_region can apply per-zone MADV_MERGEABLE instead of the global self.mergeable. The top-level --memory mergeable=on path continues to work unchanged: the default zone is synthesised from MemoryConfig and inherits its mergeable value.

AI/LLM disclosure: this patch was co-authored with GitHub Copilot and Claude Code (Opus 4.6).

@inwardvessel
inwardvessel requested a review from a team as a code owner April 9, 2026 16:59
@inwardvessel

Copy link
Copy Markdown
Contributor Author

aside from the test coverage, manual vm runs were performed under strace -f -e trace=madvise. it was verified that zones with mergeable=off did not receive MADV_MERGEABLE, while zones with mergeable=on did. zones were identified by matching the region sizes in the madvise calls to the configured zone sizes.

likebreath
likebreath previously approved these changes Apr 11, 2026

@likebreath likebreath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the contribution with clear documentation and disclosure of the use of LLMs.

@likebreath

Copy link
Copy Markdown
Member

You will need to fix the clippy issue and also rebase, so that we can land it.

@likebreath
likebreath self-requested a review April 11, 2026 01:25
@likebreath
likebreath dismissed their stale review April 11, 2026 01:25

Clippy issue and rebase needed

Add a `mergeable` field to `MemoryZoneConfig` so that KSM page merging
can be enabled selectively per memory zone rather than globally for all
guest RAM.

Previously, `MADV_MERGEABLE` was only controllable via the top-level
`--memory mergeable=on` flag, which applied uniformly to all regions.
With this change, users can leave boot memory unmerged while enabling
KSM only on hotplug zones:

  --memory size=0,hotplug_method=virtio-mem
  --memory-zone id=boot,size=512M,shared=on,mergeable=off
  --memory-zone id=hotplug,size=256M,hotplug_size=1G,shared=off,mergeable=on

The `MemoryZone` runtime struct now carries the `mergeable` flag so
that both `allocate_address_space` and `add_ram_region` can apply
per-zone `MADV_MERGEABLE` instead of the global `self.mergeable`.
The top-level `--memory mergeable=on` path continues to work unchanged:
the default zone is synthesised from `MemoryConfig` and inherits its
`mergeable` value.

AI/LLM disclosure: this patch was co-authored with
GitHub Copilot and Claude Code (Opus 4.6).

Signed-off-by: JP Kobryn <[email protected]>
@inwardvessel
inwardvessel force-pushed the zone_specific_mergeable_flag branch from d6c9462 to 5dc7d61 Compare April 11, 2026 07:22
@inwardvessel

Copy link
Copy Markdown
Contributor Author

rebased and fixed formatting.

@rbradford rbradford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you! I was going to ask you to add mergeable to the OpenAPI definition file however it was already in there despite the struct missing it!

@rbradford
rbradford added this pull request to the merge queue Apr 11, 2026
Merged via the queue into cloud-hypervisor:main with commit bdc7a69 Apr 11, 2026
36 of 38 checks passed
@rbradford rbradford moved this to ✅ Done in Cloud Hypervisor Roadmap Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants