@@ -273,8 +273,8 @@ static int kvm_spapr_tce_release(struct inode *inode, struct file *filp)
}
}
- account_locked_vm(kvm->mm,
- kvmppc_stt_pages(kvmppc_tce_pages(stt->size)), false);
+ vm_unaccount_pinned(&kvm->vm_account,
+ kvmppc_stt_pages(kvmppc_tce_pages(stt->size)));
kvm_put_kvm(stt->kvm);
@@ -301,8 +301,8 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
(args->offset + args->size > (ULLONG_MAX >> args->page_shift)))
return -EINVAL;
- npages = kvmppc_tce_pages(args->size);
- ret = account_locked_vm(mm, kvmppc_stt_pages(npages), true);
+ npages = kvmppc_tce_pages(size);
+ ret = vm_account_pinned(&kvm->vm_account, kvmppc_stt_pages(npages));
if (ret)
return ret;
@@ -347,7 +347,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
kfree(stt);
fail_acct:
- account_locked_vm(mm, kvmppc_stt_pages(npages), false);
+ vm_unaccount_pinned(&kvm->vm_account, kvmppc_stt_pages(npages));
return ret;
}
@@ -717,6 +717,7 @@ struct kvm {
*/
struct mutex slots_arch_lock;
struct mm_struct *mm; /* userspace tied to this vm */
+ struct vm_account vm_account;
unsigned long nr_memslot_pages;
/* The two memslot sets - active and inactive (per address space) */
struct kvm_memslots __memslots[KVM_ADDRESS_SPACE_NUM][2];
@@ -1142,6 +1142,7 @@ static struct kvm *kvm_create_vm(unsigned long type, const char *fdname)
KVM_MMU_LOCK_INIT(kvm);
mmgrab(current->mm);
kvm->mm = current->mm;
+ vm_account_init_current(&kvm->vm_account);
kvm_eventfd_init(kvm);
mutex_init(&kvm->lock);
mutex_init(&kvm->irq_lock);
@@ -1258,6 +1259,7 @@ static struct kvm *kvm_create_vm(unsigned long type, const char *fdname)
out_err_no_srcu:
kvm_arch_free_vm(kvm);
mmdrop(current->mm);
+ vm_account_release(&kvm->vm_account);
module_put(kvm_chardev_ops.owner);
return ERR_PTR(r);
}
@@ -1327,6 +1329,7 @@ static void kvm_destroy_vm(struct kvm *kvm)
preempt_notifier_dec();
hardware_disable_all();
mmdrop(mm);
+ vm_account_release(&kvm->vm_account);
module_put(kvm_chardev_ops.owner);
}
book3s_64_vio currently accounts for pinned pages with account_locked_vm() which charges the pages to mm->locked_vm. To make this consistent with other drivers switch to using vm_account_pinned(). Signed-off-by: Alistair Popple <apopple@nvidia.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Alexey Kardashevskiy <aik@ozlabs.ru> Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org --- arch/powerpc/kvm/book3s_64_vio.c | 10 +++++----- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 3 +++ 3 files changed, 9 insertions(+), 5 deletions(-)