From patchwork Tue Apr 28 14:40:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 465598 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 187351400B7 for ; Wed, 29 Apr 2015 00:53:59 +1000 (AEST) Received: from localhost ([::1]:33923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn6tZ-0000G4-59 for incoming@patchwork.ozlabs.org; Tue, 28 Apr 2015 10:53:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn6hK-000849-Uq for qemu-devel@nongnu.org; Tue, 28 Apr 2015 10:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yn6hI-0001FC-DC for qemu-devel@nongnu.org; Tue, 28 Apr 2015 10:41:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49681) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn6hI-0001F8-6Q for qemu-devel@nongnu.org; Tue, 28 Apr 2015 10:41:16 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id CF3F5A0E73; Tue, 28 Apr 2015 14:41:15 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-80.ams2.redhat.com [10.36.112.80]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3SEeTdO013668; Tue, 28 Apr 2015 10:41:14 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 28 Apr 2015 16:40:28 +0200 Message-Id: <1430232029-9457-22-git-send-email-pbonzini@redhat.com> In-Reply-To: <1430232029-9457-1-git-send-email-pbonzini@redhat.com> References: <1430232029-9457-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: "Emilio G. Cota" Subject: [Qemu-devel] [PULL 21/22] translate-all: use bitmap helpers for PageDesc's bitmap X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Emilio G. Cota" Here we have an open-coded byte-based bitmap implementation. Get rid of it since there's a ulong-based implementation to be used by all code. Signed-off-by: Emilio G. Cota Signed-off-by: Paolo Bonzini --- translate-all.c | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/translate-all.c b/translate-all.c index 85f0346..65a76c5 100644 --- a/translate-all.c +++ b/translate-all.c @@ -59,6 +59,7 @@ #include "exec/cputlb.h" #include "translate-all.h" +#include "qemu/bitmap.h" #include "qemu/timer.h" //#define DEBUG_TB_INVALIDATE @@ -79,7 +80,7 @@ typedef struct PageDesc { /* in order to optimize self modifying code, we count the number of lookups we do to a given page to use a bitmap */ unsigned int code_write_count; - uint8_t *code_bitmap; + unsigned long *code_bitmap; #if defined(CONFIG_USER_ONLY) unsigned long flags; #endif @@ -964,39 +965,12 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) tcg_ctx.tb_ctx.tb_phys_invalidate_count++; } -static inline void set_bits(uint8_t *tab, int start, int len) -{ - int end, mask, end1; - - end = start + len; - tab += start >> 3; - mask = 0xff << (start & 7); - if ((start & ~7) == (end & ~7)) { - if (start < end) { - mask &= ~(0xff << (end & 7)); - *tab |= mask; - } - } else { - *tab++ |= mask; - start = (start + 8) & ~7; - end1 = end & ~7; - while (start < end1) { - *tab++ = 0xff; - start += 8; - } - if (start < end) { - mask = ~(0xff << (end & 7)); - *tab |= mask; - } - } -} - static void build_page_bitmap(PageDesc *p) { int n, tb_start, tb_end; TranslationBlock *tb; - p->code_bitmap = g_malloc0(TARGET_PAGE_SIZE / 8); + p->code_bitmap = bitmap_new(TARGET_PAGE_SIZE); tb = p->first_tb; while (tb != NULL) { @@ -1015,7 +989,7 @@ static void build_page_bitmap(PageDesc *p) tb_start = 0; tb_end = ((tb->pc + tb->size) & ~TARGET_PAGE_MASK); } - set_bits(p->code_bitmap, tb_start, tb_end - tb_start); + bitmap_set(p->code_bitmap, tb_start, tb_end - tb_start); tb = tb->page_next[n]; } } @@ -1205,7 +1179,6 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, void tb_invalidate_phys_page_fast(tb_page_addr_t start, int len) { PageDesc *p; - int offset, b; #if 0 if (1) { @@ -1221,8 +1194,11 @@ void tb_invalidate_phys_page_fast(tb_page_addr_t start, int len) return; } if (p->code_bitmap) { - offset = start & ~TARGET_PAGE_MASK; - b = p->code_bitmap[offset >> 3] >> (offset & 7); + unsigned int nr; + unsigned long b; + + nr = start & ~TARGET_PAGE_MASK; + b = p->code_bitmap[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG - 1)); if (b & ((1 << len) - 1)) { goto do_invalidate; }