* Re: [PATCH 00/13] KVM: MMU: fast page fault [not found] ` <4F8A95CB.9070104@redhat.com> @ 2012-04-16 15:49 ` Takuya Yoshikawa 2012-04-16 16:02 ` Avi Kivity 2012-04-17 6:26 ` Xiao Guangrong 0 siblings, 2 replies; 9+ messages in thread From: Takuya Yoshikawa @ 2012-04-16 15:49 UTC (permalink / raw) To: Avi Kivity, kvm-ppc Cc: Xiao Guangrong, Marcelo Tosatti, Xiao Guangrong, LKML, KVM On Sun, 15 Apr 2012 12:32:59 +0300 Avi Kivity <avi@redhat.com> wrote: > Just to throw another idea into the mix - we can have write-protect-less > dirty logging, too. Instead of write protection, drop the dirty bit, > and check it again when reading the dirty log. It might look like we're > accessing the spte twice here, but it's actually just once - when we > check it to report for GET_DIRTY_LOG call N, we also prepare it for call > N+1. kvm-ppc's dirty tracking, implemented by Paul, is using information supplied by hardware and seems to be similar to what you described here. We may be able to get feedback from kvm-ppc developers. > This doesn't work for EPT, which lacks a dirty bit. But we can emulate > it: take a free bit and call it spte.NOTDIRTY, when it is set, we also > clear spte.WRITE, and teach the mmu that if it sees spte.NOTDIRTY and > can just set spte.WRITE and clear spte.NOTDIRTY. Now that looks exactly > like Xiao's lockless write enabling. How do we sync with dirty_bitmap? > Another note: O(1) write protection is not mutually exclusive with rmap > based write protection. In GET_DIRTY_LOG, you write protect everything, > and proceed to write enable on faults. When you reach the page table > level, you perform the rmap check to see if you should write protect or > not. With role.direct=1 the check is very cheap (and sometimes you can > drop the entire page table and replace it with a large spte). I understand that there are many possible combinations. But the question is whether the complexity is really worth it. Once, when we were searching a way to find atomic bitmap switch, you said to me that we should do our best not to add overheads to VCPU threads. From then, I tried my best to mitigate the latency problem without adding code to VCPU thread paths: if we add cond_resched patch, we will get a simple solution to the current known problem -- probably 64GB guests will work well without big latencies, once QEMU gets improved. I also surveyed other known hypervisors internally. We can easily see hundreds of ms latency during migration. But people rarely complain about that if they are stable and usable in most situations. Although O(1) is actually O(1) for GET_DIRTY_LOG thread, it adds some overheads to page fault handling. We may need to hold mmu_lock for properly handling O(1)'s write protection and ~500 write protections will not be so cheap. And there is no answer to the question how to achive slot-wise write protection. Of course, we may need such a tree-wide write protection when we want to support guests with hundreds of GB, or TB, of memory. Sadly it's not now. Well, if you need the best answer now, we should discuss the whole design: KVM Forum may be a good place for that. Thanks, Takuya ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 00/13] KVM: MMU: fast page fault 2012-04-16 15:49 ` [PATCH 00/13] KVM: MMU: fast page fault Takuya Yoshikawa @ 2012-04-16 16:02 ` Avi Kivity 2012-04-17 6:26 ` Xiao Guangrong 1 sibling, 0 replies; 9+ messages in thread From: Avi Kivity @ 2012-04-16 16:02 UTC (permalink / raw) To: Takuya Yoshikawa Cc: kvm-ppc, Xiao Guangrong, Marcelo Tosatti, Xiao Guangrong, LKML, KVM On 04/16/2012 06:49 PM, Takuya Yoshikawa wrote: > > This doesn't work for EPT, which lacks a dirty bit. But we can emulate > > it: take a free bit and call it spte.NOTDIRTY, when it is set, we also > > clear spte.WRITE, and teach the mmu that if it sees spte.NOTDIRTY and > > can just set spte.WRITE and clear spte.NOTDIRTY. Now that looks exactly > > like Xiao's lockless write enabling. > > How do we sync with dirty_bitmap? In Xiao's patch we call mark_page_dirty() at fault time. With the write-protect-less approach, we look at spte.DIRTY (or spte.NOTDIRTY) during GET_DIRTY_LOG, or when the spte is torn down. > > Another note: O(1) write protection is not mutually exclusive with rmap > > based write protection. In GET_DIRTY_LOG, you write protect everything, > > and proceed to write enable on faults. When you reach the page table > > level, you perform the rmap check to see if you should write protect or > > not. With role.direct=1 the check is very cheap (and sometimes you can > > drop the entire page table and replace it with a large spte). > > I understand that there are many possible combinations. > > But the question is whether the complexity is really worth it. We don't know yet. I'm just throwing ideas around. > Once, when we were searching a way to find atomic bitmap switch, you said > to me that we should do our best not to add overheads to VCPU threads. > > From then, I tried my best to mitigate the latency problem without adding > code to VCPU thread paths: if we add cond_resched patch, we will get a simple > solution to the current known problem -- probably 64GB guests will work well > without big latencies, once QEMU gets improved. Sure, I'm not advocating doing the most nifty idea. After all I'm the one that suffers most from it. Everything should be proven to improve, and the improvement should be material, not just a random measurement that doesn't matter to anyone. > > I also surveyed other known hypervisors internally. We can easily see > hundreds of ms latency during migration. But people rarely complain > about that if they are stable and usable in most situations. There is also the unavoidable latency during the final stop-and-copy phase, at least without post-copy. And the migration thread (when we have one) is hardly latency sensitive. > Although O(1) is actually O(1) for GET_DIRTY_LOG thread, it adds some > overheads to page fault handling. We may need to hold mmu_lock for properly > handling O(1)'s write protection and ~500 write protections will not be so > cheap. And there is no answer to the question how to achive slot-wise write > protection. > > Of course, we may need such a tree-wide write protection when we want to > support guests with hundreds of GB, or TB, of memory. Sadly it's not now. > > > Well, if you need the best answer now, we should discuss the whole design: > KVM Forum may be a good place for that. We don't need the best answer now, I'm satisfied with incremental improvements. But it's good to have the ideas out in the open, maybe some of them will be adopted, or maybe they'll trigger a better idea. (btw O(1) write protection is equally applicable to ordinary fork()) -- error compiling committee.c: too many arguments to function ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 00/13] KVM: MMU: fast page fault 2012-04-16 15:49 ` [PATCH 00/13] KVM: MMU: fast page fault Takuya Yoshikawa 2012-04-16 16:02 ` Avi Kivity @ 2012-04-17 6:26 ` Xiao Guangrong 2012-04-17 7:51 ` Avi Kivity 1 sibling, 1 reply; 9+ messages in thread From: Xiao Guangrong @ 2012-04-17 6:26 UTC (permalink / raw) To: Takuya Yoshikawa Cc: Avi Kivity, kvm-ppc, Marcelo Tosatti, Xiao Guangrong, LKML, KVM On 04/16/2012 11:49 PM, Takuya Yoshikawa wrote: > Although O(1) is actually O(1) for GET_DIRTY_LOG thread, it adds some > overheads to page fault handling. We may need to hold mmu_lock for properly > handling O(1)'s write protection and ~500 write protections will not be so > cheap. And there is no answer to the question how to achive slot-wise write > protection. > Actually no. We do not increase the overload on page fault for migration. The number of page fault of O(1) is the same as write-protect all spte. And, we can also avoid to hold mmu_lock to write-protect PML4s, we can use a generation number, and notify mmu to update its page table when dirty-log is enabled. Anyway, no performance data, no truth. Let me implement it first. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 00/13] KVM: MMU: fast page fault 2012-04-17 6:26 ` Xiao Guangrong @ 2012-04-17 7:51 ` Avi Kivity 2012-04-17 12:37 ` Takuya Yoshikawa 0 siblings, 1 reply; 9+ messages in thread From: Avi Kivity @ 2012-04-17 7:51 UTC (permalink / raw) To: Xiao Guangrong Cc: Takuya Yoshikawa, kvm-ppc, Marcelo Tosatti, Xiao Guangrong, LKML, KVM On 04/17/2012 09:26 AM, Xiao Guangrong wrote: > On 04/16/2012 11:49 PM, Takuya Yoshikawa wrote: > > > > Although O(1) is actually O(1) for GET_DIRTY_LOG thread, it adds some > > overheads to page fault handling. We may need to hold mmu_lock for properly > > handling O(1)'s write protection and ~500 write protections will not be so > > cheap. And there is no answer to the question how to achive slot-wise write > > protection. > > > > > Actually no. > > We do not increase the overload on page fault for migration. The number of > page fault of O(1) is the same as write-protect all spte. That's true with the write protect everything approach we use now. But it's not true with range-based write protection, where you issue GET_DIRTY_LOG on a range of pages and only need to re-write-protect them. (the motivation for that is to decrease the time between GET_DIRTY_LOG and sending the page; as the time increases, the chances that the page got re-dirtied go up). That doesn't mean O(1) is unusable for this, just that it requires more thought. Especially with direct maps, we can write-enable pages very quickly. > And, we can also avoid to hold mmu_lock to write-protect PML4s, we can use > a generation number, and notify mmu to update its page table when dirty-log > is enabled. Generation numbers are also useful for o(1) invalidation. > > Anyway, no performance data, no truth. Let me implement it first. > -- error compiling committee.c: too many arguments to function ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 00/13] KVM: MMU: fast page fault 2012-04-17 7:51 ` Avi Kivity @ 2012-04-17 12:37 ` Takuya Yoshikawa 2012-04-17 12:41 ` Avi Kivity 0 siblings, 1 reply; 9+ messages in thread From: Takuya Yoshikawa @ 2012-04-17 12:37 UTC (permalink / raw) To: Avi Kivity Cc: Xiao Guangrong, kvm-ppc, Marcelo Tosatti, Xiao Guangrong, LKML, KVM On Tue, 17 Apr 2012 10:51:40 +0300 Avi Kivity <avi@redhat.com> wrote: > That's true with the write protect everything approach we use now. But > it's not true with range-based write protection, where you issue > GET_DIRTY_LOG on a range of pages and only need to re-write-protect them. > > (the motivation for that is to decrease the time between GET_DIRTY_LOG > and sending the page; as the time increases, the chances that the page > got re-dirtied go up). Thank you for explaining this. I was planning to give the userspace more freedom. Since there are many known algorithms to predict hot memory pages, the userspace will be able to tune the frequency of GET_DIRTY_LOG for such parts not to get too many faults repeatedly, if we can restrict the range of pages to protect. This is the fine-grained control. Thanks, Takuya ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 00/13] KVM: MMU: fast page fault 2012-04-17 12:37 ` Takuya Yoshikawa @ 2012-04-17 12:41 ` Avi Kivity 2012-04-17 14:54 ` Takuya Yoshikawa 0 siblings, 1 reply; 9+ messages in thread From: Avi Kivity @ 2012-04-17 12:41 UTC (permalink / raw) To: Takuya Yoshikawa Cc: Xiao Guangrong, kvm-ppc, Marcelo Tosatti, Xiao Guangrong, LKML, KVM On 04/17/2012 03:37 PM, Takuya Yoshikawa wrote: > On Tue, 17 Apr 2012 10:51:40 +0300 > Avi Kivity <avi@redhat.com> wrote: > > > That's true with the write protect everything approach we use now. But > > it's not true with range-based write protection, where you issue > > GET_DIRTY_LOG on a range of pages and only need to re-write-protect them. > > > > (the motivation for that is to decrease the time between GET_DIRTY_LOG > > and sending the page; as the time increases, the chances that the page > > got re-dirtied go up). > > Thank you for explaining this. > > I was planning to give the userspace more freedom. > > Since there are many known algorithms to predict hot memory pages, > the userspace will be able to tune the frequency of GET_DIRTY_LOG for such > parts not to get too many faults repeatedly, if we can restrict the range > of pages to protect. > > This is the fine-grained control. Do you want per-page control, or just range-based? -- error compiling committee.c: too many arguments to function ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 00/13] KVM: MMU: fast page fault 2012-04-17 12:41 ` Avi Kivity @ 2012-04-17 14:54 ` Takuya Yoshikawa 2012-04-17 14:56 ` Avi Kivity 0 siblings, 1 reply; 9+ messages in thread From: Takuya Yoshikawa @ 2012-04-17 14:54 UTC (permalink / raw) To: Avi Kivity Cc: Xiao Guangrong, kvm-ppc, Marcelo Tosatti, Xiao Guangrong, LKML, KVM On Tue, 17 Apr 2012 15:41:39 +0300 Avi Kivity <avi@redhat.com> wrote: > > Since there are many known algorithms to predict hot memory pages, > > the userspace will be able to tune the frequency of GET_DIRTY_LOG for such > > parts not to get too many faults repeatedly, if we can restrict the range > > of pages to protect. > > > > This is the fine-grained control. > > Do you want per-page control, or just range-based? Difficult question. For live migration, range-based control may be enough duo to the locality of WWS. Thanks, Takuya ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 00/13] KVM: MMU: fast page fault 2012-04-17 14:54 ` Takuya Yoshikawa @ 2012-04-17 14:56 ` Avi Kivity 2012-04-18 13:42 ` Takuya Yoshikawa 0 siblings, 1 reply; 9+ messages in thread From: Avi Kivity @ 2012-04-17 14:56 UTC (permalink / raw) To: Takuya Yoshikawa Cc: Xiao Guangrong, kvm-ppc, Marcelo Tosatti, Xiao Guangrong, LKML, KVM On 04/17/2012 05:54 PM, Takuya Yoshikawa wrote: > On Tue, 17 Apr 2012 15:41:39 +0300 > Avi Kivity <avi@redhat.com> wrote: > > > > Since there are many known algorithms to predict hot memory pages, > > > the userspace will be able to tune the frequency of GET_DIRTY_LOG for such > > > parts not to get too many faults repeatedly, if we can restrict the range > > > of pages to protect. > > > > > > This is the fine-grained control. > > > > Do you want per-page control, or just range-based? > > Difficult question. > > For live migration, range-based control may be enough duo to the locality > of WWS. What's WWS? I don't see a reason to assume locality in gpa space (or in gva space either, for some workloads). -- error compiling committee.c: too many arguments to function ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 00/13] KVM: MMU: fast page fault 2012-04-17 14:56 ` Avi Kivity @ 2012-04-18 13:42 ` Takuya Yoshikawa 0 siblings, 0 replies; 9+ messages in thread From: Takuya Yoshikawa @ 2012-04-18 13:42 UTC (permalink / raw) To: Avi Kivity Cc: Xiao Guangrong, kvm-ppc, Marcelo Tosatti, Xiao Guangrong, LKML, KVM On Tue, 17 Apr 2012 17:56:24 +0300 Avi Kivity <avi@redhat.com> wrote: > > For live migration, range-based control may be enough duo to the locality > > of WWS. > > What's WWS? IIRC it was mentioned in a usenix paper: Writable Working Set. May not be a commonly known concept. Kind of working set, but is written often. > I don't see a reason to assume locality in gpa space (or in gva space > either, for some workloads). Sorry, I may be wrong. I once thought to log dirty_bitmaps during live migration, but didn't. Thanks, Takuya ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-04-18 13:42 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <4F742951.7080003@linux.vnet.ibm.com>
[not found] ` <4F82E04E.6000900@redhat.com>
[not found] ` <20120409175829.GB21894@amt.cnet>
[not found] ` <4F8329D3.7000605@gmail.com>
[not found] ` <20120409194614.GB23053@amt.cnet>
[not found] ` <4F840DD2.3090101@redhat.com>
[not found] ` <20120410204031.ffb5b976225ac9fe6dae474e@gmail.com>
[not found] ` <4F842074.1050108@linux.vnet.ibm.com>
[not found] ` <20120411211514.35db29c11460516e604059b6@gmail.com>
[not found] ` <4F857B61.9080602@linux.vnet.ibm.com>
[not found] ` <20120411231441.9d0984672dd252b806f99128@gmail.com>
[not found] ` <20120413232528.c5ddbddb3cc0870d6e85a332@gmail.com>
[not found] ` <4F8A95CB.9070104@redhat.com>
2012-04-16 15:49 ` [PATCH 00/13] KVM: MMU: fast page fault Takuya Yoshikawa
2012-04-16 16:02 ` Avi Kivity
2012-04-17 6:26 ` Xiao Guangrong
2012-04-17 7:51 ` Avi Kivity
2012-04-17 12:37 ` Takuya Yoshikawa
2012-04-17 12:41 ` Avi Kivity
2012-04-17 14:54 ` Takuya Yoshikawa
2012-04-17 14:56 ` Avi Kivity
2012-04-18 13:42 ` Takuya Yoshikawa
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox