All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Emilio G. Cota" <cota@braap.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] translate-all: use bitmap helpers for PageDesc's bitmap
Date: Wed, 22 Apr 2015 15:13:05 +0200	[thread overview]
Message-ID: <55379E61.5080104@redhat.com> (raw)
In-Reply-To: <1426919142-20770-1-git-send-email-cota@braap.org>



On 21/03/2015 07:25, Emilio G. Cota wrote:
> Note that this test
> 	if (b & ((1 << len) - 1))
> can be simplified to
> 	if (b & 1)
> , since we know that iff the first bit of a tb is set,
> all other bits from that tb are set too.

I don't think this optimization is valid, unfortunately.  It is possible
that say a tb starts at 0x12340001 and tb_invalidate_phys_page_fast is
called for the range starting at 0x12340000 and ending at 0x12340003.

In this case you need the full test that was used before.

Therefore, I am unqueuing this patch.  Sorry. :)

Paolo

> Signed-off-by: Emilio G. Cota <cota@braap.org>
> ---
>  translate-all.c | 39 +++++----------------------------------
>  1 file changed, 5 insertions(+), 34 deletions(-)
> 
> diff --git a/translate-all.c b/translate-all.c
> index 11763c6..749d0f6 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
> @@ -978,39 +979,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) {
> @@ -1029,7 +1003,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];
>      }
>  }
> @@ -1219,7 +1193,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) {
> @@ -1235,9 +1208,7 @@ 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);
> -        if (b & ((1 << len) - 1)) {
> +        if (test_bit(start & ~TARGET_PAGE_MASK, p->code_bitmap)) {
>              goto do_invalidate;
>          }
>      } else {
> 

  parent reply	other threads:[~2015-04-22 13:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-21  6:25 [Qemu-devel] [PATCH] translate-all: use bitmap helpers for PageDesc's bitmap Emilio G. Cota
2015-04-03  0:08 ` Emilio G. Cota
2015-04-03 14:18   ` Paolo Bonzini
2015-04-22 13:13 ` Paolo Bonzini [this message]
2015-04-22 16:47   ` Emilio G. Cota
2015-04-22 16:53     ` [Qemu-devel] [PATCH v2] " Emilio G. Cota
2015-04-22 20:30       ` Paolo Bonzini
2015-04-22 21:47         ` Emilio G. Cota
2015-04-22 21:50           ` [Qemu-devel] [PATCH v3] " Emilio G. Cota

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55379E61.5080104@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=cota@braap.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.