Skip to content

Commit da8827a

Browse files
committed
uffd: unconditionally enable UFFD_FEATURE_EVENT_REMOVE
Only enabling it when a balloon device is present doesn't really gain us anything, because the only time this feature is checked in the kernel is as part of madvise handling - but without balloon devices we wont ever call madvise, so it makes no difference whether we enabled the feature or not (it is unconditionally available since linux 4.10). Signed-off-by: Patrick Roy <[email protected]>
1 parent 63db769 commit da8827a

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/vmm/src/persist.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,6 @@ pub fn restore_from_snapshot(
393393
mem_backend_path,
394394
mem_state,
395395
track_dirty_pages,
396-
// We enable the UFFD_FEATURE_EVENT_REMOVE feature only if a balloon device
397-
// is present in the microVM state.
398-
microvm_state.device_states.balloon_device.is_some(),
399396
vm_resources.machine_config.huge_pages,
400397
)
401398
.map_err(RestoreFromSnapshotGuestMemoryError::Uffd)?,
@@ -479,19 +476,14 @@ fn guest_memory_from_uffd(
479476
mem_uds_path: &Path,
480477
mem_state: &GuestMemoryState,
481478
track_dirty_pages: bool,
482-
enable_balloon: bool,
483479
huge_pages: HugePageConfig,
484480
) -> Result<(Vec<GuestRegionMmap>, Option<Uffd>), GuestMemoryFromUffdError> {
485481
let (guest_memory, backend_mappings) =
486482
create_guest_memory(mem_state, track_dirty_pages, huge_pages)?;
487483

488484
let mut uffd_builder = UffdBuilder::new();
489485

490-
if enable_balloon {
491-
// We enable this so that the page fault handler can add logic
492-
// for treating madvise(MADV_DONTNEED) events triggerd by balloon inflation.
493-
uffd_builder.require_features(FeatureFlags::EVENT_REMOVE);
494-
}
486+
uffd_builder.require_features(FeatureFlags::EVENT_REMOVE);
495487

496488
let uffd = uffd_builder
497489
.close_on_exec(true)

0 commit comments

Comments
 (0)