]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: MMU: Move kvm_mmu_free_some_pages() into kvm_mmu_alloc_page()
authorTakuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Thu, 21 Mar 2013 10:33:43 +0000 (19:33 +0900)
committerMarcelo Tosatti <mtosatti@redhat.com>
Thu, 21 Mar 2013 22:44:56 +0000 (19:44 -0300)
commitc8e389f3e6e448fe31aaf2d2ab7be404cd22f094
treeb1cc5ddac9aa3dae6510309f6c49f8b48e5ab744
parent2c6d2652aacbd8ba8adae204b050363ca66a9b67
KVM: MMU: Move kvm_mmu_free_some_pages() into kvm_mmu_alloc_page()

What this function is doing is to ensure that the number of shadow pages
does not exceed the maximum limit stored in n_max_mmu_pages: so this is
placed at every code path that can reach kvm_mmu_alloc_page().

Although it might have some sense to spread this function in each such
code path when it could be called before taking mmu_lock, the rule was
changed not to do so.

Taking this background into account, this patch moves it into
kvm_mmu_alloc_page() and simplifies the code.

Note: the unlikely hint in kvm_mmu_free_some_pages() guarantees that the
overhead of this function is almost zero except when we actually need to
allocate some shadow pages, so we do not need to care about calling it
multiple times in one path by doing kvm_mmu_get_page() a few times.

Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/mmu.c
arch/x86/kvm/paging_tmpl.h