-
Notifications
You must be signed in to change notification settings - Fork 128
KVM Dirty log ring interface #344
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
base: main
Are you sure you want to change the base?
Conversation
roypat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please squash your commits so that we do not have later commits be fixups for previous commits.
|
Also, do we need to do anything about KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP? |
As for this, Now, whether Send and Sync will actually be useful is a different matter, because I'm assuming you want them to be able to harvest the dirty ring while the vcpu is still running, but with the current API in this PR, you can only get a &mut reference to the ring buffer structure, which you cannot send to another thread anyway. So in this case, you'd need some API that lets you take ownership of the KvmDirtyRingLog structure (maybe store the one that gets created at vcpu creation time in an option, and then have a function that just wraps .take() on that option, keeping in mind that we must never allow safe code to get two owned versions of it for the same vcpu). |
|
Also sorry for the late response, we were all preparing for / traveling to KVM Forum last week! |
Turns out we do, and if it is supported, we also need to enable KVM_CAP_DIRTY_LOG_RING_ACQ_REL prior to enabling _WITH_BITMAP. Correct me if I'm wrong. |
66f0d63 to
362f0f5
Compare
|
Why is enable_cap not available in aarch64? |
11c85a5 to
ec0da8b
Compare
|
b00ead3 to
483342a
Compare
|
The enable_cap doctest uses KVM_CAP_SPLIT_IRQCHIP as an example, which is x86 only. This breaks the test and I disabled the enable_cap call in the test on other arches. |
I needed Send and Sync to move the Vcpus to separate threads, but I only implemented what the rust compiler suggested and am still looking for a better solution for this unrelated problem. |
6ccb6da to
1d09123
Compare
|
Hi @davidkleymann , thanks for your work on this feature! I was testing it out and noticed that no VcpuExit is currently defined for |
that is a good catch, thanks! This should definitely be added in this PR :) |
eae7a7a to
e2d2c1f
Compare
|
thanks! could you rebased on main again? it seems like you accidentally picked up some commits from somewhere that shouldn't be on this branch. @ShadowCurse could you also have a look at this PR please? |
b5ef686 to
c735f3b
Compare
|
Thanks, rebased. |
95ad381 to
7695bf7
Compare
a7fcd12 to
c07248c
Compare
f9cf849 to
85f01fe
Compare
Implement dirty log ring interface with `enable_dirty_log_ring` and `dirty_log_ring_iter` methods. Enable `VmFd` `enable_cap` and ioctl imports on all architectures. Add memory fences in iterator for proper synchronization on weak memory consistency architectures. Signed-off-by: David Kleymann <[email protected]>
Summary of the PR
Add support for dirty page tracking via the Dirty ring interface. Adds KvmDirtyLogRing structure for keeping track of the indices and the base pointer to the shared memory buffer. Implements iterating over dirty pages, thereby harvesting them. Implements reset_dirty_rings on VmFd to trigger recycling of dirty ring buffer elements by the kernel after processing. Adds the dirty_log_ring field to VcpuFd.
This is a draft that needs some review and improvements, I'm hereby asking for suggestions for improving the following remaining weaknesses:
More info on the interface:
https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-cap-dirty-log-ring-kvm-cap-dirty-log-ring-acq-rel
Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s), and the commit message has max 60 characters for thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafecode is properly documented.