From patchwork Tue Jun 22 09:09:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 107357 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o5M98W75000936 for ; Tue, 22 Jun 2010 09:08:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759048Ab0FVJI3 (ORCPT ); Tue, 22 Jun 2010 05:08:29 -0400 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:41633 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753299Ab0FVJI2 (ORCPT ); Tue, 22 Jun 2010 05:08:28 -0400 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 3E767248194; Tue, 22 Jun 2010 18:08:28 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 2D83A248188; Tue, 22 Jun 2010 18:08:28 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.73]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id 07B3313C2FF; Tue, 22 Jun 2010 18:08:28 +0900 (JST) Date: Tue, 22 Jun 2010 18:09:08 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com, agraf@suse.de Cc: kvm@vger.kernel.org, kvm-ia64@vger.kernel.org, kvm-ppc@vger.kernel.org, takuya.yoshikawa@gmail.com Subject: [PATCH 2/4] KVM: ia64: cleanup kvm_ia64_sync_dirty_log() Message-Id: <20100622180908.b931771a.yoshikawa.takuya@oss.ntt.co.jp> In-Reply-To: <20100622180358.be8fd912.yoshikawa.takuya@oss.ntt.co.jp> References: <20100622180358.be8fd912.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 22 Jun 2010 09:08:42 +0000 (UTC) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index c838671..25ef888 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -1795,25 +1795,15 @@ void kvm_arch_exit(void) kvm_vmm_info = NULL; } -static int kvm_ia64_sync_dirty_log(struct kvm *kvm, - struct kvm_dirty_log *log) +static void kvm_ia64_sync_dirty_log(struct kvm *kvm, + struct kvm_memory_slot *memslot) { - struct kvm_memory_slot *memslot; - int r, i; + int i; long base; unsigned long n; unsigned long *dirty_bitmap = (unsigned long *)(kvm->arch.vm_base + offsetof(struct kvm_vm_data, kvm_mem_dirty_log)); - r = -EINVAL; - if (log->slot >= KVM_MEMORY_SLOTS) - goto out; - - memslot = &kvm->memslots->memslots[log->slot]; - r = -ENOENT; - if (!memslot->dirty_bitmap) - goto out; - n = kvm_dirty_bitmap_bytes(memslot); base = memslot->base_gfn / BITS_PER_LONG; @@ -1823,9 +1813,6 @@ static int kvm_ia64_sync_dirty_log(struct kvm *kvm, dirty_bitmap[base + i] = 0; } spin_unlock(&kvm->arch.dirty_log_lock); - r = 0; -out: - return r; } int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, @@ -1838,10 +1825,16 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, mutex_lock(&kvm->slots_lock); - r = kvm_ia64_sync_dirty_log(kvm, log); - if (r) + r = -EINVAL; + if (log->slot >= KVM_MEMORY_SLOTS) + goto out; + + memslot = &kvm->memslots->memslots[log->slot]; + r = -ENOENT; + if (!memslot->dirty_bitmap) goto out; + kvm_ia64_sync_dirty_log(kvm, memslot); r = kvm_get_dirty_log(kvm, log, &is_dirty); if (r) goto out; @@ -1849,7 +1842,6 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, /* If nothing is dirty, don't bother messing with page tables. */ if (is_dirty) { kvm_flush_remote_tlbs(kvm); - memslot = &kvm->memslots->memslots[log->slot]; n = kvm_dirty_bitmap_bytes(memslot); memset(memslot->dirty_bitmap, 0, n); }