]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: MMU: Fix mmu_shrink() so that it can free mmu pages as intended
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Mon, 20 Aug 2012 09:35:39 +0000 (18:35 +0900)
committerAvi Kivity <avi@redhat.com>
Wed, 22 Aug 2012 12:27:13 +0000 (15:27 +0300)
commit9a1cb1bd3701090247b53d0d16cf8b64caca4891
tree763610b668cb62664b55a838488e96dad829a9b0
parent86834e8f3bf23dde346046c89db5cffe3bf7d949
KVM: MMU: Fix mmu_shrink() so that it can free mmu pages as intended

Although the possible race described in

  commit 3059bd33b0a3196ef8b5bb369887d926c279c868
  KVM: MMU: fix shrinking page from the empty mmu

was correct, the real cause of that issue was a more trivial bug of
mmu_shrink() introduced by

  commit a5bd78f1d9804feaaf7f6ed2fc6181d86dd0751b
  KVM: MMU: do not iterate over all VMs in mmu_shrink()

Here is the bug:

if (kvm->arch.n_used_mmu_pages > 0) {
if (!nr_to_scan--)
break;
continue;
}

We skip VMs whose n_used_mmu_pages is not zero and try to shrink others:
in other words we try to shrink empty ones by mistake.

This patch reverses the logic so that mmu_shrink() can free pages from
the first VM whose n_used_mmu_pages is not zero.  Note that we also add
comments explaining the role of nr_to_scan which is not practically
important now, hoping this will be improved in the future.

Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/mmu.c