From: "Emilio G. Cota" <cota@braap.org>
To: Pavel Dovgalyuk <dovgaluk@ispras.ru>
Cc: Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PULL, 14/18] translate-all: discard TB when tb_link_page returns an existing matching TB
Date: Wed, 4 Jul 2018 15:38:08 -0400 [thread overview]
Message-ID: <20180704193808.GA32390@flamenco> (raw)
In-Reply-To: <000601d41290$205c56a0$611503e0$@ru>
On Tue, Jul 03, 2018 at 08:38:52 +0300, Pavel Dovgalyuk wrote:
> > From: Emilio G. Cota [mailto:cota@braap.org]
> > On Mon, Jul 02, 2018 at 08:52:14 +0300, Pavel Dovgalyuk wrote:
> > > The same failure can be reproduced with linux-0.2.img, which was
> > > downloaded from QEMU site.
> > > I can't find it now, but I can upload this file if needed.
> >
> > Please upload it somewhere and share the full QEMU invocation
> > needed to replicate.
>
> https://github.com/Dovgalyuk/qemu-images/blob/master/linux-0.2.img
>
> qemu-system-i386 -drive file=images/linux-0.2.img,if=none,snapshot,id=img -drive
> driver=blkreplay,if=none,id=rr,image=img -device ide-hd,drive=rr -net none -icount
> shift=5,rr=record,rrfile=linux02.rr
The appended patch fixes it for me. Can you please test on your
windows image?
The rationale is to honour CF_NOCACHE, so that we always return
a new TB from tb_gen_code.
Thanks,
Emilio
---
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 170b957..49d77fa 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -1446,7 +1446,8 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)
phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb_cflags(tb) & CF_HASH_MASK,
tb->trace_vcpu_dstate);
- if (!qht_remove(&tb_ctx.htable, tb, h)) {
+ if (!(tb->cflags & CF_NOCACHE) &&
+ !qht_remove(&tb_ctx.htable, tb, h)) {
return;
}
@@ -1604,8 +1605,6 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,
{
PageDesc *p;
PageDesc *p2 = NULL;
- void *existing_tb = NULL;
- uint32_t h;
assert_memory_lock();
@@ -1625,20 +1624,25 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,
tb->page_addr[1] = -1;
}
- /* add in the hash table */
- h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK,
- tb->trace_vcpu_dstate);
- qht_insert(&tb_ctx.htable, tb, h, &existing_tb);
+ if (!(tb->cflags & CF_NOCACHE)) {
+ void *existing_tb = NULL;
+ uint32_t h;
- /* remove TB from the page(s) if we couldn't insert it */
- if (unlikely(existing_tb)) {
- tb_page_remove(p, tb);
- invalidate_page_bitmap(p);
- if (p2) {
- tb_page_remove(p2, tb);
- invalidate_page_bitmap(p2);
+ /* add in the hash table */
+ h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK,
+ tb->trace_vcpu_dstate);
+ qht_insert(&tb_ctx.htable, tb, h, &existing_tb);
+
+ /* remove TB from the page(s) if we couldn't insert it */
+ if (unlikely(existing_tb)) {
+ tb_page_remove(p, tb);
+ invalidate_page_bitmap(p);
+ if (p2) {
+ tb_page_remove(p2, tb);
+ invalidate_page_bitmap(p2);
+ }
+ tb = existing_tb;
}
- tb = existing_tb;
}
if (p2 && p2 != p) {
next prev parent reply other threads:[~2018-07-04 19:38 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-14 19:31 [Qemu-devel] [PULL 00/18] tcg queued patches Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 01/18] tcg/i386: Use byte form of xgetbv instruction Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 02/18] qht: require a default comparison function Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 03/18] qht: return existing entry when qht_insert fails Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 04/18] tcg: track TBs with per-region BST's Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 05/18] tcg: move tb_ctx.tb_phys_invalidate_count to tcg_ctx Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 06/18] translate-all: iterate over TBs in a page with PAGE_FOR_EACH_TB Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 07/18] translate-all: make l1_map lockless Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 08/18] translate-all: remove hole in PageDesc Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 09/18] translate-all: work page-by-page in tb_invalidate_phys_range_1 Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 10/18] translate-all: move tb_invalidate_phys_page_range up in the file Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 11/18] translate-all: use per-page locking in !user-mode Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 12/18] translate-all: add page_locked assertions Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 13/18] translate-all: introduce assert_no_pages_locked Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 14/18] translate-all: discard TB when tb_link_page returns an existing matching TB Richard Henderson
2018-06-29 7:25 ` [Qemu-devel] [PULL, " Pavel Dovgalyuk
2018-06-29 18:48 ` Emilio G. Cota
2018-07-02 5:52 ` Pavel Dovgalyuk
2018-07-02 19:52 ` Emilio G. Cota
2018-07-03 5:38 ` Pavel Dovgalyuk
2018-07-04 19:38 ` Emilio G. Cota [this message]
2018-07-05 5:51 ` Pavel Dovgalyuk
2018-06-14 19:31 ` [Qemu-devel] [PULL 15/18] translate-all: protect TB jumps with a per-destination-TB lock Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 16/18] cputlb: remove tb_lock from tlb_flush functions Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 17/18] translate-all: remove tb_lock mention from cpu_restore_state_from_tb Richard Henderson
2018-06-14 19:31 ` [Qemu-devel] [PULL 18/18] tcg: remove tb_lock Richard Henderson
2018-06-15 10:41 ` [Qemu-devel] [PULL 00/18] tcg queued patches Peter Maydell
2018-06-15 14:01 ` Emilio G. Cota
2018-06-15 17:54 ` Richard Henderson
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=20180704193808.GA32390@flamenco \
--to=cota@braap.org \
--cc=dovgaluk@ispras.ru \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).