-
Notifications
You must be signed in to change notification settings - Fork 2k
Use mincore(2) to create diff snapshots without dirty page tracking #5274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
roypat
wants to merge
12
commits into
firecracker-microvm:main
Choose a base branch
from
roypat:mincore-diff-snapshots
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
028794d
to
56ca763
Compare
Include a sentence about diff snapshots producing sparse files in our snapshot documentation. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
The rebase-snap tool is deprecated and snapshot-editor should be used. Since the two ways of merging snapshot files are completely equivalent, let's remove the rebase-snap instructions and only keep the snapshot-editor ones, to avoid people using deprecated tools. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
0622764
to
7379503
Compare
8000
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5274 +/- ##
==========================================
+ Coverage 82.84% 82.93% +0.08%
==========================================
Files 250 250
Lines 26967 27015 +48
==========================================
+ Hits 22342 22405 +63
+ Misses 4625 4610 -15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1a5e0ae
to
fa57cc6
Compare
Currently, Firecracker only supports creation of diff snapshots if dirty page tracking is explicitly enabled. Allow creation of diff snapshots even if it is not enabled, through the use of mincore(2). The mincore(2) syscalls determines which pages of a VMA are "in core". For anonymous mappings (as used by booted VMs without vhost-user devices), this refers to all pages that are currently faulted in. For memfd (as used by booted vms with vhost-user devices), this means all pages that have been allocated into the memfd, regardless of whether they were allocated through the VMA on which mincore(2) was called (meaning creation of mincore-diff-snapshots will correctly account for pages that were only touched by the vhost-user backend, but not by Firecracker or KVM). For restored VMs, this means all pages of the underlying snapshot file that have been faulted in. Note that this only works if swap has been disabled, as pages currently swapped to disk do not count as "in-core", yet obviously should be included in a diff snapshot. If swap is used, dirty page tracking MUST be enabled for diff snapshots to work correctly. Compared to diff snapshots based on dirty page tracking, mincore-based diff snapshots will be slightly larger. This is because dirty page tracked diff snapshots only include pages that were actually written to, while mincore-based snapshots will contain all pages that were accessed at all, e.g. even if only for reading. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
We have two different API parameters that do the same thing in two different APIs: For booted VMs, we enable KVM dirty page tracking by setting track_dirty_pages to true in /machine-config. For resumed VMs, we enable KVM dirty page tracking by setting enable_diff_snapshots to true in /snapshot/load. Apart from being inconsistent for no reason, one of these is very badly named: With support for diff snapshots without dirty page tracking, enable_diff_snapshots is a misnomer, because setting it to false will still allow us to do diff snapshots, it'll just fall back to mincore. Rename enable_diff_snapshots to track_dirty_pages, so we're consistent and also so that the parameter reflects what is actually happening. Go through the whole deprecation cycle of deprecating enable_diff_snapshots and adding the new track_dirty_pages parameter at the same time. We will need to remove enable_diff_snapshots in 2.0 Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Document that diff snapshots can work even without dirty page tracking, and what the drawbacks of this are (bigger snapshots, no swap support). Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
We were using this property as a proxy for two things: "Does this snapshot rebase rebasing before resumptions?" and "do I need to enable dirty page tracking to create another snapshot of this type?". With mincore-snapshots, these two questions are no longer equivalent (mincore snapshots need rebase, but do _not_ need dirty page tracking), so untangle this property into two properties. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
7e06ee7
to
0f00c29
Compare
With support for "mincore diff snapshots", we'll have two snapshot types that map to "diff" in the firecracker API, so the enum can no longer be string based. Instead just have a property that translates to Firecracker API types. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Just always demand the enum. The internal conversion from str to enum now doesnt work anymore with the enum no longer being str-based. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Have them use the correct needs_rebase/needs_dirty_tracking helpers instead. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
828dd4b
to
68541f7
Compare
Now that the test framework correctly differentiates between the need for rebase and the need for dirty page tracking, start running tests with mincore snapshots. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Just have a single test that is parametrized by snapshot type. This will then automatically also test mincore diff snapshots. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
fb6355d
to
4cb5f51
Compare
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
4cb5f51
to
31dc205
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, Firecracker only supports creation of diff snapshots if dirty
page tracking is explicitly enabled. Allow creation of diff snapshots
even if it is not enabled, through the use of mincore(2). The mincore(2)
syscalls determines which pages of a VMA are "in core". For anonymous
mappings (as used by booted VMs without vhost-user devices), this refers
to all pages that are currently faulted in. For memfd (as used by booted
vms with vhost-user devices), this means all
pages that have been allocated into the memfd, regardless of whether
they were allocated through the VMA on which mincore(2) was called
(meaning creation of mincore-diff-snapshots will correctly account for
pages that were only touched by the vhost-user backend, but not by
Firecracker or KVM). For restored VMs, this means all pages of the
underlying snapshot file that have been faulted in.
Note that this only works if swap has been disabled, as pages currently
swapped to disk do not count as "in-core", yet obviously should be
included in a diff snapshot. If swap is used, dirty page tracking MUST
be enabled for diff snapshots to work correctly.
Compared to diff snapshots based on dirty page tracking, mincore-based
diff snapshots will be slightly larger. This is because dirty page
tracked diff snapshots only include pages that were actually written to,
while mincore-based snapshots will contain all pages that were accessed
at all, e.g. even if only for reading.
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
tools/devtool checkstyle
to verify that the PR passes theautomated style checks.
how they are solving the problem in a clear and encompassing way.
in the PR.
CHANGELOG.md
.Runbook for Firecracker API changes.
integration tests.
TODO
.rust-vmm
.