From patchwork Wed Apr 21 06:07:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 93826 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3L63nqQ006012 for ; Wed, 21 Apr 2010 06:03:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752567Ab0DUGDk (ORCPT ); Wed, 21 Apr 2010 02:03:40 -0400 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:59970 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752441Ab0DUGDj (ORCPT ); Wed, 21 Apr 2010 02:03:39 -0400 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id E708124819E; Wed, 21 Apr 2010 15:03:37 +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 D2E8E248199; Wed, 21 Apr 2010 15:03:37 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.144]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id 96F6811C116; Wed, 21 Apr 2010 15:03:37 +0900 (JST) Date: Wed, 21 Apr 2010 15:07:20 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com, agraf@suse.de Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Subject: [RFC please check] KVM: question about the commit "Use Little Endian for Dirty Bitmap" Message-Id: <20100421150720.16516cb7.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 2.6.0 (GTK+ 2.16.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]); Wed, 21 Apr 2010 06:03:50 +0000 (UTC) === snipet from commit c8240bd6f0b4b1b21ffd36dd44114d05c7afe0c0 === @@ -48,6 +48,7 @@ #include #include #include +#include #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET #include "coalesced_mmio.h" @@ -1665,8 +1666,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn) unsigned long rel_gfn = gfn - memslot->base_gfn; /* avoid RMW */ - if (!test_bit(rel_gfn, memslot->dirty_bitmap)) - set_bit(rel_gfn, memslot->dirty_bitmap); + if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap)) + generic___set_le_bit(rel_gfn, memslot->dirty_bitmap); } } === === not tested === [PATCH sample] KVM: avoid to include an asm-generic bitops header file directly Including asm-generic bitops headers is kind of violation: there is no guarantee that no one will change those functions we are using. Signed-off-by: Takuya Yoshikawa --- virt/kvm/kvm_main.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 3725605..f029760 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -51,7 +51,6 @@ #include #include #include -#include #include "coalesced_mmio.h" @@ -1179,6 +1178,18 @@ int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len) } EXPORT_SYMBOL_GPL(kvm_clear_guest); +/* + * __set_le_bit is defined for ppc only. + */ +static void kvm___set_le_bit(unsigned long nr, unsigned long *addr) +{ +#ifdef __set_le_bit + __set_le_bit(nr, addr); +#else + __set_bit(nr, addr); +#endif +} + void mark_page_dirty(struct kvm *kvm, gfn_t gfn) { struct kvm_memory_slot *memslot; @@ -1188,9 +1199,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn) if (memslot && memslot->dirty_bitmap) { unsigned long rel_gfn = gfn - memslot->base_gfn; - /* avoid RMW */ - if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap)) - generic___set_le_bit(rel_gfn, memslot->dirty_bitmap); + kvm___set_le_bit(rel_gfn, memslot->dirty_bitmap); } }