]> Pileus Git - ~andy/linux/commit
KVM: MMU: Make kvm_handle_hva() handle range of addresses
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Mon, 2 Jul 2012 08:55:48 +0000 (17:55 +0900)
committerMarcelo Tosatti <mtosatti@redhat.com>
Wed, 18 Jul 2012 19:55:04 +0000 (16:55 -0300)
commit84504ef38673fa021b3d8f3da2b79cf878b33315
tree55c6238ebfa17790dad0136493b7b0f375828ace
parentd19a748b1c42b133e9263e9023c1d162efa6f4ad
KVM: MMU: Make kvm_handle_hva() handle range of addresses

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 page
    for each memslot
      if page is in memslot
        unmap using rmap

This means although every page in that range is expected to be found in
the same memslot, we are forced to check unrelated memslots many times.
If the guest has more memslots, the situation will become worse.

Furthermore, if the range does not include any pages in the guest's
memory, the loop over the pages will just consume extra time.

This patch, together with the following patches, solves this problem by
introducing kvm_handle_hva_range() which makes the loop look like this:

  for each memslot
    for each page in memslot
      unmap using rmap

In this new processing, the actual work is converted to a loop over rmap
which is much more cache friendly than before.

Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: Alexander Graf <agraf@suse.de>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/powerpc/kvm/book3s_64_mmu_hv.c
arch/x86/kvm/mmu.c