Re: [Qemu-devel] [PATCH 09/22] monitor: disable "info jit" and "info opcount" if !TCG

2017-07-06 Thread Emilio G. Cota
On Tue, Jul 04, 2017 at 13:12:02 +0200, Paolo Bonzini wrote: > Reviewed-by: Richard Henderson > Signed-off-by: Paolo Bonzini > --- > accel/tcg/translate-all.c | 5 + > hmp-commands-info.hx | 4 > monitor.c | 2 ++ > 3 files changed, 11 insertions(+) > > diff --git

Re: [Qemu-devel] [PATCH v11 24/29] target/arm: [tcg, a64] Port to translate_insn

2017-07-07 Thread Emilio G. Cota
On Fri, Jul 07, 2017 at 05:46:19 -1000, Richard Henderson wrote: > I do wonder if we should provide a generic empty hook, so that a target that > does not need a particular hook need not define an empty function. It could > just put e.g. "translator_noop" into the structure. Ok, maybe a better na

[Qemu-devel] [PATCH 07/22] tcg/i386: constify tcg_target_callee_save_regs

2017-07-09 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- tcg/i386/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 01e3b4e..06df01a 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -2514,7 +2514,7

[Qemu-devel] [PATCH 12/22] translate-all: report correct avg host TB size

2017-07-09 Thread Emilio G. Cota
t size, as well as the expansion ratio. In the future we might want to consider reporting the accurate numbers for the total translated code, together with a "bookkeeping/overhead" field to account for the TB structs. Signed-off-by: Emilio G. Cota ---

[Qemu-devel] [PATCH 17/22] tcg: distribute profiling counters across TCGContext's

2017-07-09 Thread Emilio G. Cota
to them. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 38 accel/tcg/translate-all.c | 23 +- tcg/tcg.c | 108 ++ 3 files changed, 124 insertions(+), 45 deletions(-) diff --git a/tcg/tcg.h b

[Qemu-devel] [PATCH 06/22] translate-all: make have_tb_lock static

2017-07-09 Thread Emilio G. Cota
It is only used by this object, and it's not exported to any other. Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 72ce445..2fa9f65 100644 --- a/acce

[Qemu-devel] [PATCH 01/22] vl: fix breakage of -tb-size

2017-07-09 Thread Emilio G. Cota
h later by configure_accelerator(). Fix it by unconditionally exiting if the flag is passed to a QEMU binary built with !CONFIG_TCG. Signed-off-by: Emilio G. Cota --- vl.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vl.c b/vl.c index d17c863..9ece570 100644 --- a/vl.c +++ b/vl.c @

[Qemu-devel] [PATCH 15/22] gen-icount: fold exitreq_label into TCGContext

2017-07-09 Thread Emilio G. Cota
Before we make TCGContext thread-local. Signed-off-by: Emilio G. Cota --- include/exec/gen-icount.h | 7 +++ tcg/tcg.h | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 9b3cb14..489aff7 100644

[Qemu-devel] [PATCH 08/22] tcg/mips: constify tcg_target_callee_save_regs

2017-07-09 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- tcg/mips/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c index 8cff9a6..790b4fc 100644 --- a/tcg/mips/tcg-target.inc.c +++ b/tcg/mips/tcg-target.inc.c @@ -2323,7 +2323,7

[Qemu-devel] [PATCH 03/22] cputlb: bring back tlb_flush_count under !TLB_DEBUG

2017-07-09 Thread Emilio G. Cota
r not to lose counts we'd either have to use atomic ops or distribute the counter, which is more scalable. This patch does the latter by embedding tlb_flush_count in CPUArchState. The global count is then easily obtained by iterating over the CPU list. Signed-off-by: Emilio G. Cota --- inclu

[Qemu-devel] [PATCH 21/22] tcg: enable per-thread TCG for softmmu

2017-07-09 Thread Emilio G. Cota
get MTTCG working with TCI. Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 4 +++- tcg/tcg.h | 12 +--- accel/tcg/translate-all.c | 20 +--- cpus.c| 3 +++ tcg/optimize.c| 4 ++-- tcg/tcg.c

[Qemu-devel] [PATCH 02/22] translate-all: remove redundant !tcg_enabled check in dump_exec_info

2017-07-09 Thread Emilio G. Cota
e check also returns with tb_lock held. So we can either do the check before tb_lock is acquired, or just get rid of it. Given that it is redundant, I am going for the latter option. Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 5 - 1 file changed, 5 deletions(-) diff --git a/

[Qemu-devel] [PATCH 22/22] translate-all: do not hold tb_lock during code generation in softmmu

2017-07-09 Thread Emilio G. Cota
20% ) (83.26%) 30.340574988 seconds time elapsed ( +- 0.39% ) That is, a speedup of 1.25X. Signed-off-by: Emilio G. Cota --- accel/tcg/cpu-exec.c | 7 ++- accel/tcg/translate-all.c | 22 ++ 2 files changed, 28 insertions(+

[Qemu-devel] [PATCH 00/22] tcg: per-thread TCG

2017-07-09 Thread Emilio G. Cota
Original RFC here: https://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg06874.html I included Richard's feedback (Thanks!) from the original RFC, and added quite a few things. This is now a proper PATCHset since it is a lot more mature. Highlights: - It works! I tested single/multi-threa

[Qemu-devel] [PATCH 04/22] tcg: fix corruption of code_time profiling counter upon tb_flush

2017-07-09 Thread Emilio G. Cota
avg cycles111.0 Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index a936a5f..72ce445 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/trans

[Qemu-devel] [PATCH 14/22] tcg: take .helpers out of TCGContext

2017-07-09 Thread Emilio G. Cota
Before TCGContext is made thread-local. The hash table becomes read-only after it is filled in, so we can save space by keeping just a global pointer to it. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 2 -- tcg/tcg.c | 10 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff

[Qemu-devel] [PATCH 13/22] tcg: take tb_ctx out of TCGContext

2017-07-09 Thread Emilio G. Cota
Before TCGContext is made thread-local. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/tb-context.h | 2 ++ tcg/tcg.h | 2 -- accel/tcg/cpu-exec.c | 2 +- accel/tcg/translate-all.c | 57

[Qemu-devel] [PATCH 10/22] exec-all: move tb->invalid to the end of the struct

2017-07-09 Thread Emilio G. Cota
dicted. Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index a388756..fd20bca 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -327,8 +327,6 @@

[Qemu-devel] [PATCH 18/22] tcg: define TCG_HIGHWATER

2017-07-09 Thread Emilio G. Cota
Will come in handy very soon. Signed-off-by: Emilio G. Cota --- tcg/tcg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index c19c473..2f003a0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -115,6 +115,8 @@ static int tcg_target_const_match

[Qemu-devel] [PATCH 09/22] exec-all: shrink tb->invalid to uint8_t

2017-07-09 Thread Emilio G. Cota
ut in some systems that would take > 1 byte. Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 8326e7d..a388756 100644 --- a/include/exec/exec-all.h +++ b/include/ex

[Qemu-devel] [PATCH 05/22] exec-all: fix typos in TranslationBlock's documentation

2017-07-09 Thread Emilio G. Cota
Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 8096d64..8326e7d 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec

[Qemu-devel] [PATCH 19/22] tcg: introduce tcg_context_clone

2017-07-09 Thread Emilio G. Cota
Before we make TCGContext thread-local. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 1 + tcg/tcg.c | 14 ++ 2 files changed, 15 insertions(+) diff --git a/tcg/tcg.h b/tcg/tcg.h index 2a64ee2..be5f3fd 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -778,6 +778,7 @@ static inline void

[Qemu-devel] [PATCH 16/22] tcg: keep a list of TCGContext's

2017-07-09 Thread Emilio G. Cota
that trivial, because vCPUs are spawned in parallel. So let's just keep it simple and use a list protected by a lock. Note that this lock will soon be used for other purposes, hence the generic "tcg_lock" name. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 3 +++

[Qemu-devel] [PATCH 11/22] translate-all: use a binary search tree to track TBs in TBContext

2017-07-09 Thread Emilio G. Cota
10,803,480,261 branches # 1326.192 M/sec ( +- 1.95% ) 195,601,289 branch-misses #1.81% of all branches ( +- 0.39% ) 8.828660235 seconds time elapsed ( +- 0.38% ) Signed-off-b

[Qemu-devel] [PATCH 20/22] tcg: dynamically allocate from code_gen_buffer using equally-sized regions

2017-07-09 Thread Emilio G. Cota
leading to many unnecessary flushes. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 8 +++ accel/tcg/translate-all.c | 61 bsd-user/main.c | 1 + linux-user/main.c | 1 + tcg/tcg.c | 175

Re: [Qemu-devel] [PATCH 09/22] monitor: disable "info jit" and "info opcount" if !TCG

2017-07-09 Thread Emilio G. Cota
On Thu, Jul 06, 2017 at 16:26:52 -0400, Emilio G. Cota wrote: > On Tue, Jul 04, 2017 at 13:12:02 +0200, Paolo Bonzini wrote: > > Reviewed-by: Richard Henderson > > Signed-off-by: Paolo Bonzini (snip) > > +++ b/accel/tcg/translate-all.c > > @@ -1851,6 +1851,11 @@

Re: [Qemu-devel] [PATCH 00/22] tcg: per-thread TCG

2017-07-09 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 03:49:52 -0400, Emilio G. Cota wrote: > The series applies on top of the current master (b11365867568). It's a lot of patches -- you can fetch them from: https://github.com/cota/qemu/commits/multi-tcg Note that there's a patch in the branch there that is no

Re: [Qemu-devel] [PATCH 03/22] cputlb: bring back tlb_flush_count under !TLB_DEBUG

2017-07-09 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 10:00:01 -1000, Richard Henderson wrote: > On 07/08/2017 09:49 PM, Emilio G. Cota wrote: > >+atomic_set(&env->tlb_flush_count, env->tlb_flush_count + 1); > > Want atomic_read here, so they're all the same. It's not needed. Note th

Re: [Qemu-devel] [PATCH 11/22] translate-all: use a binary search tree to track TBs in TBContext

2017-07-09 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 10:33:41 -1000, Richard Henderson wrote: > On 07/08/2017 09:50 PM, Emilio G. Cota wrote: > > #if defined(DEBUG_TB_FLUSH) > >+nb_tbs = g_tree_nnodes(tcg_ctx.tb_ctx.tb_tree); > > printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n&

Re: [Qemu-devel] [PATCH 19/22] tcg: introduce tcg_context_clone

2017-07-09 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 10:48:27 -1000, Richard Henderson wrote: > On 07/08/2017 09:50 PM, Emilio G. Cota wrote: > >@@ -409,6 +411,18 @@ void tcg_context_init(TCGContext *s) > > } > > /* > >+ * Clone the initial TCGContext. Used by TCG threads to copy the TCGContext &g

Re: [Qemu-devel] [PATCH 17/22] tcg: distribute profiling counters across TCGContext's

2017-07-09 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 10:45:55 -1000, Richard Henderson wrote: > On 07/08/2017 09:50 PM, Emilio G. Cota wrote: > >+/* includes aborted translations because of exceptions */ > >+atomic_set(&prof->tb_count1, prof->tb_count1 + 1); > > Again, atomic_set w

Re: [Qemu-devel] [PATCH 03/22] cputlb: bring back tlb_flush_count under !TLB_DEBUG

2017-07-09 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 16:56:23 -0400, Emilio G. Cota wrote: > On Sun, Jul 09, 2017 at 10:00:01 -1000, Richard Henderson wrote: > > On 07/08/2017 09:49 PM, Emilio G. Cota wrote: > > >+atomic_set(&env->tlb_flush_count, env->tlb_flush_count + 1); > > > &g

Re: [Qemu-devel] [PATCH 21/22] tcg: enable per-thread TCG for softmmu

2017-07-09 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 11:19:37 -1000, Richard Henderson wrote: > On 07/08/2017 09:50 PM, Emilio G. Cota wrote: > >This allows us to generate TCG code in parallel. MTTCG already uses > >it, although the next commit pushes down a lock to actually > >perform parallel generation

Re: [Qemu-devel] [PATCH 22/22] translate-all: do not hold tb_lock during code generation in softmmu

2017-07-09 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 11:38:50 -1000, Richard Henderson wrote: > On 07/08/2017 09:50 PM, Emilio G. Cota wrote: (snip) > I think it would be better to have a tb_htable_lookup_or_insert function, > which performs the insert iff a matching object isn't already there, > returning th

Re: [Qemu-devel] [PATCH 21/22] tcg: enable per-thread TCG for softmmu

2017-07-09 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 11:48:53 -1000, Richard Henderson wrote: > On 07/09/2017 11:29 AM, Emilio G. Cota wrote: (snip) > >Exactly. Also, in user-mode "vCPU threads" (i.e. host threads) come and > >go all the time, so this doesn't work well with having a single >

Re: [Qemu-devel] [PATCH 22/22] translate-all: do not hold tb_lock during code generation in softmmu

2017-07-10 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 19:59:47 -1000, Richard Henderson wrote: > On 07/09/2017 05:51 PM, Emilio G. Cota wrote: > >On Sun, Jul 09, 2017 at 11:38:50 -1000, Richard Henderson wrote: > >>On 07/08/2017 09:50 PM, Emilio G. Cota wrote: > >(snip) > >>I t

Re: [Qemu-devel] [PATCH 17/22] tcg: distribute profiling counters across TCGContext's

2017-07-10 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 11:44:10 -1000, Richard Henderson wrote: > On 07/09/2017 11:14 AM, Emilio G. Cota wrote: > >On Sun, Jul 09, 2017 at 10:45:55 -1000, Richard Henderson wrote: > >>On 07/08/2017 09:50 PM, Emilio G. Cota wrote: > >>>+/* includes aborted tran

Re: [Qemu-devel] [PATCH 21/22] tcg: enable per-thread TCG for softmmu

2017-07-10 Thread Emilio G. Cota
On Mon, Jul 10, 2017 at 14:05:01 +0200, Paolo Bonzini wrote: > On 09/07/2017 09:50, Emilio G. Cota wrote: > > User-mode is kept out of this: contention due to concurrent translation > > is more commonly found in full-system mode. > > Out of curiosity, is it harder or you

Re: [Qemu-devel] [PATCH 21/22] tcg: enable per-thread TCG for softmmu

2017-07-10 Thread Emilio G. Cota
On Mon, Jul 10, 2017 at 17:33:07 -0400, Paolo Bonzini wrote: > > > I agree that it would be nice to have the same mechanism for all. > > > > The main hurdle I see is how to allow for concurrent code generation while > > minimizing flushes of the single, fixed-size[*] code_gen_buffer. > > In user-

Re: [Qemu-devel] [PATCH 09/22] exec-all: shrink tb->invalid to uint8_t

2017-07-10 Thread Emilio G. Cota
On Sun, Jul 09, 2017 at 10:11:21 -1000, Richard Henderson wrote: > On 07/08/2017 09:50 PM, Emilio G. Cota wrote: > >To avoid wasting a byte. I don't have any use in mind for this byte, > >but I think it's good to leave this byte explicitly free for future use. > >

Re: [Qemu-devel] [PATCH 00/22] tcg: tb_lock removal

2017-08-25 Thread Emilio G. Cota
On Mon, Aug 07, 2017 at 19:52:16 -0400, Emilio G. Cota wrote: > This series applies on top of the "multiple TCG contexts" series, v4: > https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06769.html > > Highlights: > > - First, fix a few typos I encountered wh

Re: [Qemu-devel] [PATCH 00/13] instrument: Add basic event instrumentation

2017-08-25 Thread Emilio G. Cota
On Fri, Jul 28, 2017 at 19:05:43 +0300, Lluís Vilanova wrote: > As for the (minimum) requirements I've collected: > > * Peek at register values and guest memory. > * Enumerate guest cpus. > * Control when events are raised to minimize overheads (e.g., avoid generating > TCG code to trace a guest

Re: [Qemu-devel] [PATCH 00/13] instrument: Add basic event instrumentation

2017-08-25 Thread Emilio G. Cota
On Thu, Aug 03, 2017 at 12:54:57 +0100, Stefan Hajnoczi wrote: > > > Please post an example of the API you'd like. > > > > In my opinion, the instrumentation support in this series provides an API > > that > > works in the opposite way you're suggesting (let's ignore the fact that it's > > built

Re: [Qemu-devel] [PATCH v8 0/5] hypertrace: Lightweight guest-to-QEMU trace channel

2017-08-25 Thread Emilio G. Cota
On Sun, Jul 30, 2017 at 17:08:18 +0300, Lluís Vilanova wrote: > The hypertrace channel allows guest code to emit events in QEMU (the host) > using > its tracing infrastructure (see "docs/trace.txt"). This works in both 'system' > and 'user' modes, is architecture-agnostic and introduces minimal no

Re: [Qemu-devel] [RFC PATCH 2/3] cpus-common: Cache allocated work items

2017-08-28 Thread Emilio G. Cota
On Sun, Aug 27, 2017 at 23:53:25 -0400, Pranith Kumar wrote: > Using heaptrack, I found that quite a few of our temporary allocations > are coming from allocating work items. Instead of doing this > continously, we can cache the allocated items and reuse them instead > of freeing them. > > This re

Re: [Qemu-devel] [PATCH v2 43/45] tcg: introduce regions to split code_gen_buffer

2017-07-18 Thread Emilio G. Cota
On Mon, Jul 17, 2017 at 19:09:28 -1000, Richard Henderson wrote: > On 07/16/2017 10:04 AM, Emilio G. Cota wrote: > >+#ifdef CONFIG_SOFTMMU > >+/* > >+ * It is likely that some vCPUs will translate more code than others, so we > >+ * first try to set more regions than s

Re: [Qemu-devel] [PATCH v2 45/45] tcg: enable multiple TCG contexts in softmmu

2017-07-18 Thread Emilio G. Cota
On Mon, Jul 17, 2017 at 19:25:14 -1000, Richard Henderson wrote: > On 07/16/2017 10:04 AM, Emilio G. Cota wrote: > >+ > >+/* claim the first free pointer in tcg_ctxs and increment n_tcg_ctxs */ > >+for (i = 0; i < smp_cpus; i++) { > >+if (atomic

Re: [Qemu-devel] [PATCH 0/8] target/alpha cleanups

2017-07-18 Thread Emilio G. Cota
on such that it is > just two loads and one mask. Which is one practically-free mask > away from being as minimal as one can get. Tested-by: Emilio G. Cota for the series. I tried to get some perf numbers but really booting linux doesn't spend much time in lookup_tb_ptr, nor does dbt

Re: [Qemu-devel] [PATCH] add scripts/git.orderfile

2017-07-18 Thread Emilio G. Cota
On Mon, Jul 17, 2017 at 12:16:32 +0200, Gerd Hoffmann wrote: > Based on a old patch by Laszlo. > Time to get this in ... > > Signed-off-by: Gerd Hoffmann > --- > scripts/git.orderfile | 29 +++++ Reviewed-by: Emilio G. Cota Been using this orderfile

Re: [Qemu-devel] [PATCH v2 10/45] translate-all: guarantee that tb_hash only holds valid TBs

2017-07-18 Thread Emilio G. Cota
On Mon, Jul 17, 2017 at 19:29:57 -1000, Richard Henderson wrote: > On 07/17/2017 06:54 PM, Emilio G. Cota wrote: > >What threw me off was that in lookup_tb_ptr we're not checking tb->invalid, > >and that biased me into thinking that it's not needed. But I should have &

[Qemu-devel] [PATCH v3 05/43] cpu-exec: rename have_tb_lock to acquired_tb_lock in tb_find

2017-07-19 Thread Emilio G. Cota
Reusing the have_tb_lock name, which is also defined in translate-all.c, makes code reviewing unnecessarily harder. Avoid potential confusion by renaming the local have_tb_lock variable to something else. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/cpu-exec.c

[Qemu-devel] [PATCH v3 00/43] tcg: support for multiple TCG contexts

2017-07-19 Thread Emilio G. Cota
v2: https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg04749.html v3 applies on top of the current master (d4e59218a). To ease review/testing, you can pull this series from: https://github.com/cota/qemu/tree/multi-tcg-v3 Note: I cannot even compile-test _WIN32 bits, help appreciated! S

[Qemu-devel] [PATCH v3 04/43] translate-all: make have_tb_lock static

2017-07-19 Thread Emilio G. Cota
It is only used by this object, and it's not exported to any other. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/translate-all.c b/acce

[Qemu-devel] [PATCH v3 06/43] tcg/i386: constify tcg_target_callee_save_regs

2017-07-19 Thread Emilio G. Cota
Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Emilio G. Cota --- tcg/i386/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 01e3b4e

[Qemu-devel] [PATCH v3 32/43] tcg: take .helpers out of TCGContext

2017-07-19 Thread Emilio G. Cota
Groundwork for supporting multiple TCG contexts. The hash table becomes read-only after it is filled in, so we can save space by keeping just a global pointer to it. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 2 -- tcg/tcg.c | 10

[Qemu-devel] [PATCH v3 15/43] target/i386: check CF_PARALLEL instead of parallel_cpus

2017-07-19 Thread Emilio G. Cota
Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/i386/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/translate.c b/target/i386

[Qemu-devel] [PATCH v3 08/43] tcg: remove addr argument from lookup_tb_ptr

2017-07-19 Thread Emilio G. Cota
on Signed-off-by: Emilio G. Cota --- tcg/tcg-op.h | 4 ++-- tcg/tcg-runtime.h | 2 +- target/alpha/translate.c | 2 +- target/arm/translate-a64.c | 4 ++-- target/arm/translate.c | 5 + target/hppa/translate.c| 6 +++--- target/i386/translate

[Qemu-devel] [PATCH v3 07/43] tcg/mips: constify tcg_target_callee_save_regs

2017-07-19 Thread Emilio G. Cota
Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Emilio G. Cota --- tcg/mips/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c index 85756b8

[Qemu-devel] [PATCH v3 16/43] target/m68k: check CF_PARALLEL instead of parallel_cpus

2017-07-19 Thread Emilio G. Cota
Thereby decoupling the resulting translated code from the current state of the system. Signed-off-by: Emilio G. Cota --- target/m68k/helper.h| 1 + target/m68k/op_helper.c | 33 - target/m68k/translate.c | 12 ++-- 3 files changed, 31 insertions

[Qemu-devel] [PATCH v3 19/43] target/sparc: check CF_PARALLEL instead of parallel_cpus

2017-07-19 Thread Emilio G. Cota
Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/sparc/translate.c b/target/sparc

[Qemu-devel] [PATCH v3 01/43] cputlb: bring back tlb_flush_count under !TLB_DEBUG

2017-07-19 Thread Emilio G. Cota
updating the accessors to tlb_flush_count to use atomic_read/set whenever there may be conflicting accesses (as defined in C11) to it. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- include/exec/cpu-defs.h | 1 + include/exec/cputlb.h | 3 +-- accel

[Qemu-devel] [PATCH v3 02/43] tcg: fix corruption of code_time profiling counter upon tb_flush

2017-07-19 Thread Emilio G. Cota
avg cycles111.0 Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/trans

[Qemu-devel] [PATCH v3 10/43] exec-all: bring tb->invalid into tb->cflags

2017-07-19 Thread Emilio G. Cota
This gets rid of a hole in struct TranslationBlock. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 3 +-- include/exec/tb-lookup.h | 2 +- accel/tcg/cpu-exec.c | 4 ++-- accel/tcg/translate-all.c | 3 +-- 4 files changed, 5 insertions(+), 7

[Qemu-devel] [PATCH v3 13/43] target/arm: check CF_PARALLEL instead of parallel_cpus

2017-07-19 Thread Emilio G. Cota
Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/arm/helper-a64.h| 4 target/arm/helper-a64.c| 38 -- target/arm/op_helper.c | 7

[Qemu-devel] [PATCH v3 22/43] translate-all: define and use DEBUG_TB_FLUSH_GATE

2017-07-19 Thread Emilio G. Cota
This gets rid of some ifdef checks while ensuring that the debug code is compiled, which prevents bit rot. Suggested-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 20 +--- 1 file changed, 13 insertions(+), 7

[Qemu-devel] [PATCH v3 14/43] target/hppa: check CF_PARALLEL instead of parallel_cpus

2017-07-19 Thread Emilio G. Cota
Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/hppa/helper.h| 2 ++ target/hppa/op_helper.c | 32 target/hppa/translate.c | 12 ++-- 3

[Qemu-devel] [PATCH v3 20/43] tcg: check CF_PARALLEL instead of parallel_cpus

2017-07-19 Thread Emilio G. Cota
isters, which results in a 4-byte hole in TCGContext. Use this hole for the bit we need, which we store in a bool. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 1 + accel/tcg/translate-all.c | 1 + tcg/tcg-op.c | 10 +- 3 files c

[Qemu-devel] [PATCH v3 24/43] translate-all: define and use DEBUG_TB_INVALIDATE_GATE

2017-07-19 Thread Emilio G. Cota
This gets rid of an ifdef check while ensuring that the debug code is compiled, which prevents bit rot. Suggested-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff

[Qemu-devel] [PATCH v3 03/43] exec-all: fix typos in TranslationBlock's documentation

2017-07-19 Thread Emilio G. Cota
Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 87b1b74..69c1b36 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec

[Qemu-devel] [PATCH v3 21/43] cpu-exec: lookup/generate TB outside exclusive region during step_atomic

2017-07-19 Thread Emilio G. Cota
. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/cpu-exec.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index b71e015..526cab3 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel

[Qemu-devel] [PATCH v3 18/43] target/sh4: check CF_PARALLEL instead of parallel_cpus

2017-07-19 Thread Emilio G. Cota
Thereby decoupling the resulting translated code from the current state of the system. Signed-off-by: Emilio G. Cota --- target/sh4/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 9fcaefd..52fabb3 100644 --- a

[Qemu-devel] [PATCH v3 28/43] exec-all: rename tb_free to tb_remove

2017-07-19 Thread Emilio G. Cota
We don't really free anything in this function anymore; we just remove the TB from the binary search tree. Suggested-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 2 +- accel/tcg/cpu-exec.c | 2 +- accel/tcg/translate-

[Qemu-devel] [PATCH v3 29/43] translate-all: report correct avg host TB size

2017-07-19 Thread Emilio G. Cota
t size, as well as the expansion ratio. In the future we might want to consider reporting the accurate numbers for the total translated code, together with a "bookkeeping/overhead" field to account for the TB structs. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota ---

[Qemu-devel] [PATCH v3 36/43] tcg: introduce **tcg_ctxs to keep track of all TCGContext's

2017-07-19 Thread Emilio G. Cota
elems) or having to check with ifdef's for usermode/softmmu. Signed-off-by: Emilio G. Cota --- tcg/tcg.c | 4 1 file changed, 4 insertions(+) diff --git a/tcg/tcg.c b/tcg/tcg.c index f907c47..2217314 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -115,6 +115,8 @@ static int tcg_target_c

[Qemu-devel] [PATCH v3 25/43] translate-all: define and use DEBUG_TB_CHECK_GATE

2017-07-19 Thread Emilio G. Cota
: Emilio G. Cota --- accel/tcg/translate-all.c | 28 ++-- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 962e9b3..845585b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -82,6

[Qemu-devel] [PATCH v3 09/43] tcg: consolidate TB lookups in tb_lookup__cpu_state

2017-07-19 Thread Emilio G. Cota
] 261,962,386 branch-misses #2.03% of all branches ( +- 0.71% ) [83.35%] 19.700174670 seconds time elapsed ( +- 0.56% ) Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota

[Qemu-devel] [PATCH v3 26/43] exec-all: extract tb->tc_* into a separate struct tc_tb

2017-07-19 Thread Emilio G. Cota
In preparation for adding tc.size to be able to keep track of TB's using the binary search tree implementation from glib. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 20 ++-- accel/tcg/cpu-exec.c | 6 +++--- acce

[Qemu-devel] [PATCH v3 23/43] exec-all: introduce TB_PAGE_ADDR_FMT

2017-07-19 Thread Emilio G. Cota
or target 'accel/tcg/translate-all.o' failed make[1]: *** [accel/tcg/translate-all.o] Error 1 Makefile:328: recipe for target 'subdir-mipsn32-linux-user' failed make: *** [subdir-mipsn32-linux-user] Error 2 cota@flamenco:/data/src/qemu/build ((18f3fe1...) *$)$ Reviewed-by: Richard

[Qemu-devel] [PATCH v3 39/43] osdep: introduce qemu_mprotect_rwx/none

2017-07-19 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- include/qemu/osdep.h | 2 ++ util/osdep.c | 41 + 2 files changed, 43 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 0cba871..2c7d7db 100644 --- a/include/qemu/osdep.h +++ b/include

[Qemu-devel] [PATCH v3 31/43] tcg: take tb_ctx out of TCGContext

2017-07-19 Thread Emilio G. Cota
Groundwork for supporting multiple TCG contexts. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- include/exec/tb-context.h | 2 ++ tcg/tcg.h | 2 -- accel/tcg/cpu-exec.c | 2 +- accel/tcg/translate-all.c | 57

[Qemu-devel] [PATCH v3 34/43] gen-icount: fold exitreq_label into TCGContext

2017-07-19 Thread Emilio G. Cota
Groundwork for supporting multiple TCG contexts. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- include/exec/gen-icount.h | 7 +++ tcg/tcg.h | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/exec/gen

[Qemu-devel] [PATCH v3 40/43] translate-all: use qemu_protect_rwx/none helpers

2017-07-19 Thread Emilio G. Cota
The helpers require the address and size to be page-aligned, so do that before calling them. Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 61 ++- 1 file changed, 13 insertions(+), 48 deletions(-) diff --git a/accel/tcg/translate

[Qemu-devel] [PATCH v3 38/43] util: move qemu_real_host_page_size/mask to osdep.h

2017-07-19 Thread Emilio G. Cota
-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/cpu-all.h | 2 -- include/qemu/osdep.h | 6 ++ exec.c | 4 util/pagesize.c| 18 ++ util/Makefile.objs | 1 + 5 files changed, 25 insertions(+), 6 deletions(-) create

[Qemu-devel] [PATCH v3 11/43] tcg: define CF_PARALLEL and use it for TB hashing

2017-07-19 Thread Emilio G. Cota
flags" inline. Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 20 +++- include/exec/tb-hash-xx.h | 9 ++--- include/exec/tb-hash.h| 4 ++-- include/exec/tb-lookup.h | 6 +++--- tcg/tcg.h | 1 - accel/tcg/cpu-exec.c

[Qemu-devel] [PATCH v3 12/43] tcg: convert tb->cflags reads to tb_cflags(tb)

2017-07-19 Thread Emilio G. Cota
$1tb_cflags(tb)/g' $FILES perl -pi -e 's/([a-z]*)->tb->cflags/tb_cflags($1->tb)/g' $FILES Then manually fixed the few errors that checkpatch reported. Compile-tested for all targets. Suggested-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/gen-icount.

[Qemu-devel] [PATCH v3 37/43] tcg: distribute profiling counters across TCGContext's

2017-07-19 Thread Emilio G. Cota
accesses (as defined in C11) to them. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 38 +--- accel/tcg/translate-all.c | 23 +- tcg/tcg.c | 110 ++ 3 files changed, 126

[Qemu-devel] [PATCH v3 42/43] tcg: introduce regions to split code_gen_buffer

2017-07-19 Thread Emilio G. Cota
avg_tb_size=364 That is, 20 flushes. Note how a static partitioning approach uses the code buffer poorly, leading to many unnecessary flushes. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 6 ++ accel/tcg/translate-all.c | 63 +--- bsd-user/main.c

[Qemu-devel] [PATCH v3 17/43] target/s390x: check CF_PARALLEL instead of parallel_cpus

2017-07-19 Thread Emilio G. Cota
Thereby decoupling the resulting translated code from the current state of the system. Signed-off-by: Emilio G. Cota --- target/s390x/helper.h | 4 +++ target/s390x/mem_helper.c | 80 +-- target/s390x/translate.c | 26 --- 3 files

[Qemu-devel] [PATCH v3 41/43] tcg: define TCG_HIGHWATER

2017-07-19 Thread Emilio G. Cota
Will come in handy very soon. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- tcg/tcg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 0ddd0dc..cb4ecbd 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c

[Qemu-devel] [PATCH v3 30/43] tci: move tci_regs to tcg_qemu_tb_exec's stack

2017-07-19 Thread Emilio G. Cota
Groundwork for supporting multiple TCG contexts. Compile-tested for all targets on an x86_64 host. Suggested-by: Richard Henderson Acked-by: Richard Henderson Signed-off-by: Emilio G. Cota --- tcg/tci.c | 552 +++--- 1 file changed, 279

[Qemu-devel] [PATCH v3 43/43] tcg: enable multiple TCG contexts in softmmu

2017-07-19 Thread Emilio G. Cota
ild_trampolines), use_vis3_instructions Only written by tcg_prologue_init: - 'struct jit_code_entry one_entry' - aarch64: tb_ret_addr - arm: tb_ret_addr - i386: tb_ret_addr, guest_base_flags - ia64: tb_ret_addr - mips: tb_ret_addr, bswap32_addr, bswap32u_addr, bswap64_addr Signed-off-by: Emili

[Qemu-devel] [PATCH v3 35/43] tcg: dynamically allocate optimizer temps

2017-07-19 Thread Emilio G. Cota
l branches ( +- 0.95% ) [83.31%] 20.601366430 seconds time elapsed ( +- 0.60% ) That is, 1.77% slowdown. Suggested-by: Richard Henderson Signed-off-by: Emilio G. Cota --- tcg/optimize.c | 307 ++

[Qemu-devel] [PATCH v3 27/43] translate-all: use a binary search tree to track TBs in TBContext

2017-07-19 Thread Emilio G. Cota
( +- 1.95% ) 195,601,289 branch-misses #1.81% of all branches ( +- 0.39% ) 8.828660235 seconds time elapsed ( +- 0.38% ) Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/ex

[Qemu-devel] [PATCH v3 33/43] tcg: define tcg_init_ctx and make tcg_ctx a pointer

2017-07-19 Thread Emilio G. Cota
- in this case &tcg_init_ctx. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/gen-icount.h | 10 ++--- include/exec/helper-gen.h | 12 +++--- tcg/tcg-op.h | 80 +-- tcg/tcg.h | 15 +++--

Re: [Qemu-devel] [PATCH v3 42/43] tcg: introduce regions to split code_gen_buffer

2017-07-20 Thread Emilio G. Cota
On Wed, Jul 19, 2017 at 22:04:50 -1000, Richard Henderson wrote: > On 07/19/2017 05:09 PM, Emilio G. Cota wrote: > >+/* We do not yet support multiple TCG contexts, so use one region for > >now */ > >+n_regions = 1; > >+ > >+/* start on a pa

Re: [Qemu-devel] [PATCH v3 42/43] tcg: introduce regions to split code_gen_buffer

2017-07-20 Thread Emilio G. Cota
On Thu, Jul 20, 2017 at 11:22:10 -1000, Richard Henderson wrote: > >Perhaps we should then enlarge both the first and last regions so that we > >fully use the buffer. > > I really like the idea. That's a lot of space recovered for 64k page hosts. > > I do think we can make the computation cleare

Re: [Qemu-devel] [PATCH v3 35/43] tcg: dynamically allocate optimizer temps

2017-07-20 Thread Emilio G. Cota
On Wed, Jul 19, 2017 at 21:39:35 -1000, Richard Henderson wrote: > On 07/19/2017 05:09 PM, Emilio G. Cota wrote: > >Groundwork for supporting multiple TCG contexts. > >That is, 2.70% slowdown. > > That's disappointing. How about using tcg_malloc? > > Maximum al

Re: [Qemu-devel] [PATCH v3 35/43] tcg: dynamically allocate optimizer temps

2017-07-20 Thread Emilio G. Cota
On Thu, Jul 20, 2017 at 14:02:53 -1000, Richard Henderson wrote: > On 07/20/2017 01:53 PM, Emilio G. Cota wrote: > >BTW, is there any chance that the pool will be initialized before we copy > >tcg_init_ctx? That'd mean the main thread has performed translation, which > >

[Qemu-devel] [PATCH] target/arm: fix TCG temp leak in aarch64 rev16

2017-07-20 Thread Emilio G. Cota
tcg_gen_and_i64(tcg_tmp, tcg_tmp, mask); > +tcg_gen_shli_i64(tcg_rd, tcg_rd, 8); > +tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_tmp); > > tcg_temp_free_i64(tcg_tmp); const leak! patch below -- cut with `git am --scissors'. Emilio ---8<--- Signed-off-

[Qemu-devel] [PATCH v4 00/43] tcg: support for multiple TCG contexts

2017-07-20 Thread Emilio G. Cota
v3: https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06353.html To ease review/testing, you can pull this series from: https://github.com/cota/qemu/tree/multi-tcg-v4 [ head commit: 1d50a9f24e ] In this iteration I'm sending only the few patches that contain changes from v3; they are

<    2   3   4   5   6   7   8   9   10   11   >