[PATCH 3/4] KVM: MMU: Make kvm_handle_hva() handle range of addresses

2012-06-15 Thread Takuya Yoshikawa
When guest's memory is backed by THP pages, MMU notifier needs to call kvm_unmap_hva(), which in turn leads to kvm_handle_hva(), in a loop to invalidate a range of pages which constitute one huge page: for each guest page for each memslot if page is in memslot unmap using rmap

Re: [PATCH 3/4] KVM: MMU: Make kvm_handle_hva() handle range of addresses

2012-06-18 Thread Avi Kivity
On 06/15/2012 02:32 PM, Takuya Yoshikawa wrote: > When guest's memory is backed by THP pages, MMU notifier needs to call > kvm_unmap_hva(), which in turn leads to kvm_handle_hva(), in a loop to > invalidate a range of pages which constitute one huge page: > > for each guest page > for each m

Re: [PATCH 3/4] KVM: MMU: Make kvm_handle_hva() handle range of addresses

2012-06-18 Thread Takuya Yoshikawa
On Mon, 18 Jun 2012 15:11:42 +0300 Avi Kivity wrote: > > kvm_for_each_memslot(memslot, slots) { > > - gfn_t gfn = hva_to_gfn(hva, memslot); > > + gfn_t gfn = hva_to_gfn(start_hva, memslot); > > + gfn_t end_gfn = hva_to_gfn(end_hva, memslot); > > These will retu

Re: [PATCH 3/4] KVM: MMU: Make kvm_handle_hva() handle range of addresses

2012-06-19 Thread Takuya Yoshikawa
On Mon, 18 Jun 2012 15:11:42 +0300 Avi Kivity wrote: > Potential for improvement: don't do 512 iterations on same large page. > > Something like > > if ((gfn ^ prev_gfn) & mask(level)) > ret |= handler(...) > > with clever selection of the first prev_gfn so it always matches (~gfn

Re: [PATCH 3/4] KVM: MMU: Make kvm_handle_hva() handle range of addresses

2012-06-21 Thread Avi Kivity
On 06/19/2012 04:46 PM, Takuya Yoshikawa wrote: > On Mon, 18 Jun 2012 15:11:42 +0300 > Avi Kivity wrote: > >> Potential for improvement: don't do 512 iterations on same large page. >> >> Something like >> >> if ((gfn ^ prev_gfn) & mask(level)) >> ret |= handler(...) >> >> with clev

Re: [PATCH 3/4] KVM: MMU: Make kvm_handle_hva() handle range of addresses

2012-06-21 Thread Takuya Yoshikawa
I should have read this before sending v2... On Thu, 21 Jun 2012 11:24:59 +0300 Avi Kivity wrote: > > 1. Separate rmap_pde from lpage_info->write_count and > >make this a simple array. (I once tried this.) > > > > This has the potential to increase cache misses, but I don't think it's > a