On Thu, Oct 30, 2014 at 07:31:48PM +0800, zhanghailiang wrote:
On 2014/10/30 1:46, Andrea Arcangeli wrote:
On Mon, Oct 27, 2014 at 05:32:51PM +0800, zhanghailiang wrote:
I want to confirm a question:Mail is going to be long enough already so I'll just assume tracking
Can we support distinguishing between writing and reading memory for userfault?
That is, we can decide whether writing a page, reading a page or both trigger userfault.
dirty memory in userland (instead of doing it in kernel) is worthy
feature to have here.
I'll open that can of worms :-)
[...]
Er, maybe i didn't describe clearly. What i really need for live memory snapshot
is only wrprotect fault, like kvm's dirty tracing mechanism, *only tracing write action*.
So, what i need for userfault is supporting only wrprotect fault. i don't
want to get notification for non present reading faults, it will influence
VM's performance and the efficiency of doing snapshot.
Given that you do care about performance Zhanghailiang, I don't think that a
userfault handler is a good place to track dirty memory. Every dirtying write
will block on the userfault handler, which is an expensively slow proposition
compared to an in-kernel approach.
Also, i think this feature will benefit for migration of ivshmem and vhost-scsi
which have no dirty-page-tracing now.
I do agree wholeheartedly with you here. Manually tracking non-guest writes
adds to the complexity of device emulation code. A central fault-driven means
for dirty tracking writes from the guest and host would be a welcome
simplification to implementing pre-copy migration. Indeed, that's exactly what
I'm working on! I'm using the softdirty bit, which was introduced recently for
CRIU migration, to replace the use of KVM's dirty logging and manual dirty
tracking by the VMM during pre-copy migration. See
Documentation/vm/soft-dirty.txt and pagemap.txt in case you aren't familiar. To
make softdirty usable for live migration, I've added an API to atomically
test-and-clear the bit and write protect the page.