[Qemu-devel] [PATCH 3/3] rcu: add liburcu knob to configure script

2015-02-03 Thread Emilio G. Cota
burcu flavor to the one that QEMU's RCU is using. Note that the rcutorture under test/ doesn't work with --enable-liburcu, since it relies on some internals of QEMU's RCU. liburcu is tested with the urcutorture distributed with it. Signed-off-by: Emilio G. Cota --- config

[Qemu-devel] [PATCH 0/3] rcu: add option to use upstream liburcu

2015-02-03 Thread Emilio G. Cota
Hi Paolo + all, First off, thanks for your ongoing RCU work, which I'm closely following. As you stated in the initial RCU patch (7911747b), the intent is to keep the same API as liburcu's. I checked whether this was the case and found a couple of issues that I'm addressing in the appended series

[Qemu-devel] [PATCH 1/3] rcu: use call_rcu semantics from liburcu

2015-02-03 Thread Emilio G. Cota
between liburcu and QEMU's RCU implementation. Signed-off-by: Emilio G. Cota --- docs/rcu.txt | 21 ++--- include/qemu/rcu.h | 6 +++--- memory.c | 4 ++-- util/rcu.c | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/docs/rcu

[Qemu-devel] [PATCH 2/3] rcu: use rcu_{dereference, assign_pointer} instead of atomic_rcu_{read, set}

2015-02-03 Thread Emilio G. Cota
This matches the semantics of liburcu. Signed-off-by: Emilio G. Cota --- docs/rcu.txt | 33 +++-- include/qemu/atomic.h | 35 ++- memory.c | 6 +++--- tests/rcutorture.c| 4 ++-- 4 files changed, 38

Re: [Qemu-devel] [PATCH 2/3] rcu: use rcu_{dereference, assign_pointer} instead of atomic_rcu_{read, set}

2015-02-04 Thread Emilio G. Cota
On Wed, Feb 04, 2015 at 11:01:00 +0100, Paolo Bonzini wrote: > On 03/02/2015 23:08, Emilio G. Cota wrote: > > This matches the semantics of liburcu. > > This is not necessary. The two sets of macros are exactly the same, so > it's okay to use atomic_rcu_read/write. They&

Re: [Qemu-devel] [PATCH 0/3] rcu: add option to use upstream liburcu

2015-02-04 Thread Emilio G. Cota
On Wed, Feb 04, 2015 at 11:32:57 +0100, Paolo Bonzini wrote: > On 03/02/2015 23:08, Emilio G. Cota wrote: > > * The first two patches bring back the RCU API to exactly > > match that of liburcu. > > Bringing over rcu_dereference/rcu_assign_pointer is unnecessary, I >

Re: [Qemu-devel] [PATCH 0/3] rcu: add option to use upstream liburcu

2015-02-04 Thread Emilio G. Cota
On Wed, Feb 04, 2015 at 22:17:44 +0100, Paolo Bonzini wrote: > > What I'm investigating now is how to do this in a manner that is palatable > > to upstream. For this as it's well known we need a multi-threaded TCG, > > and I believe quite a few bits from liburcu(-cds) might help to > > get there. >

[Qemu-devel] [PATCH] translate-all: remove superfluous #ifdef FOO || 1

2015-03-20 Thread Emilio G. Cota
It always evaluates to true. Signed-off-by: Emilio G. Cota --- translate-all.c | 4 1 file changed, 4 deletions(-) diff --git a/translate-all.c b/translate-all.c index 9f47ce7..11763c6 100644 --- a/translate-all.c +++ b/translate-all.c @@ -1334,8 +1334,6 @@ static inline void

[Qemu-devel] [PATCH] translate-all: use bitmap helpers for PageDesc's bitmap

2015-03-20 Thread Emilio G. Cota
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. Signed-off-by: Emilio G. Cota --- translate-all.c | 39 +

[Qemu-devel] [PATCH] tcg: pack TCGTemp to reduce size by 8 bytes

2015-03-20 Thread Emilio G. Cota
This brings down the size of the struct from 56 to 48 bytes. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/tcg.h b/tcg/tcg.h index add7f75..3276924 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -429,8 +429,8 @@ typedef struct

[Qemu-devel] [PATCH] target-i386: remove superfluous TARGET_HAS_SMC macro

2015-03-21 Thread Emilio G. Cota
Suggested-by: Paolo Bonzini Signed-off-by: Emilio G. Cota --- target-i386/cpu.h | 2 -- translate-all.c | 4 2 files changed, 6 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 15db6d7..4ee12ca 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -31,8 +31,6

[Qemu-devel] [PATCH] tcg: optimise memory layout of TCGTemp

2015-03-25 Thread Emilio G. Cota
igned-off-by: Emilio G. Cota --- tcg/tcg.h | 22 +- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tcg/tcg.h b/tcg/tcg.h index add7f75..71ae7b2 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -193,7 +193,7 @@ typedef struct TCGPool { typedef enum TCGType

Re: [Qemu-devel] [PATCH] tcg: optimise memory layout of TCGTemp

2015-03-27 Thread Emilio G. Cota
e able to > do a compile time check if TCG_TYPE_COUNT doesn't fit into > TCG_TYPE_NR_BITS? > > +#define TEMP_VAL_NR_BITS 2 > > A similar compile time check could be added here. Ack, addressed below. On Fri, Mar 27, 2015 at 07:58:06 -0700, Richard Henderson wrote: >

[Qemu-devel] [PATCH v2] tcg: optimise memory layout of TCGTemp

2015-04-02 Thread Emilio G. Cota
( +- 0.30% ) Suggested-by: Stefan Weil Suggested-by: Richard Henderson Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tcg/tcg.h b/tcg/tcg.h index add7f75..7f95132 100644 ---

Re: [Qemu-devel] [PATCH] translate-all: use bitmap helpers for PageDesc's bitmap

2015-04-02 Thread Emilio G. Cota
On Sat, Mar 21, 2015 at 02:25:42 -0400, 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. &g

[Qemu-devel] [PATCH v2] translate-all: use glib for all page descriptor allocations

2015-04-09 Thread Emilio G. Cota
Since commit b7b5233a "bsd-user/mmap.c: Don't try to override g_malloc/g_free" the exception we make here for usermode has been unnecessary. Get rid of it. Signed-off-by: Emilio G. Cota --- translate-all.c | 18 ++ 1 file changed, 2 insertions(+), 16 deletions

[Qemu-devel] [PATCH] translate-all: use g_malloc0 for all page descriptor allocations

2015-04-09 Thread Emilio G. Cota
Since commit b7b5233a "bsd-user/mmap.c: Don't try to override g_malloc/g_free" the exception we make here for usermode has been unnecessary. Get rid of it. Signed-off-by: Emilio G. Cota --- translate-all.c | 18 ++ 1 file changed, 2 insertions(+), 16 deletions

[Qemu-devel] [PATCH v3] translate-all: use glib for all page descriptor allocations

2015-04-09 Thread Emilio G. Cota
Since commit b7b5233a "bsd-user/mmap.c: Don't try to override g_malloc/g_free" the exception we make here for usermode has been unnecessary. Get rid of it. Signed-off-by: Emilio G. Cota --- translate-all.c | 18 ++ 1 file changed, 2 insertions(+), 16 deletions

[Qemu-devel] [PATCH] translate-all: remove redundant page_find from tb_invalidate_phys_page

2015-04-08 Thread Emilio G. Cota
The callers have just looked up the page descriptor, so there's no point in searching again for it. Signed-off-by: Emilio G. Cota --- translate-all.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/translate-all.c b/translate-all.c index 11763c6..4d05898 1

Re: [Qemu-devel] [PATCH] translate-all: use bitmap helpers for PageDesc's bitmap

2015-04-22 Thread Emilio G. Cota
On Wed, Apr 22, 2015 at 15:13:05 +0200, Paolo Bonzini wrote: > 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

[Qemu-devel] [PATCH v2] translate-all: use bitmap helpers for PageDesc's bitmap

2015-04-22 Thread 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 --- translate-all.c | 40 +++- 1 file changed, 7 insertions(+), 33 deletions(-)

Re: [Qemu-devel] [PATCH v2] translate-all: use bitmap helpers for PageDesc's bitmap

2015-04-22 Thread Emilio G. Cota
On Wed, Apr 22, 2015 at 22:30:23 +0200, Paolo Bonzini wrote: > On 22/04/2015 18:53, Emilio G. Cota wrote: > > @@ -1221,8 +1194,9 @@ void tb_invalidate_phys_page_fast(tb_page_addr_t > > start, int len) > > return; > > } > > if (p->code_b

[Qemu-devel] [PATCH v3] translate-all: use bitmap helpers for PageDesc's bitmap

2015-04-22 Thread 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 --- translate-all.c | 42 +- 1 file changed, 9 insertions(+), 33 deletions(-)

[Qemu-devel] [PATCH] i440fx-test: remove ARRAY_SIZE redefinition

2015-04-26 Thread Emilio G. Cota
It's defined in osdep.h and shouldn't be redefined here. Signed-off-by: Emilio G. Cota --- tests/i440fx-test.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c index d0bc8de..33a7ecb 100644 --- a/tests/i440fx-test.c +++ b/tests/i44

Re: [Qemu-devel] [PATCH] i440fx-test: remove ARRAY_SIZE redefinition

2015-04-27 Thread Emilio G. Cota
On Sun, Apr 26, 2015 at 19:18:41 -0700, Peter Crosthwaite wrote: > On Sun, Apr 26, 2015 at 3:04 PM, Emilio G. Cota wrote: > > It's defined in osdep.h and shouldn't be redefined here. > > > > Signed-off-by: Emilio G. Cota > > > Reviewed-by: Peter Crost

qemu-devel@nongnu.org

2015-04-27 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index e6dcae3..62d157a 100644 --- a/cpus.c +++ b/cpus.c @@ -1016,7 +1016,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) qemu_cond_signal(&qemu_cpu_

[Qemu-devel] [PATCH 0/6] trivial fixes

2015-04-27 Thread Emilio G. Cota
Here is a hodge-podge of fixes for issues I found while reviewing QTAILQ callers, with a .gitignore patch as a bonus. Thanks, Emilio

[Qemu-devel] [PATCH 6/6] linux-user/elfload: use QTAILQ_FOREACH instead of open-coding it

2015-04-27 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- linux-user/elfload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 399c021..0ba9706 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2887,8 +2887,7 @@ static int

[Qemu-devel] [PATCH 4/6] gitignore: ignore *.patch files

2015-04-27 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index aed0e1f..025a841 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,7 @@ *.fn *.ky *.log +*.patch *.pdf *.pod *.cps -- 1.9.1

[Qemu-devel] [PATCH 2/6] input: remove unused mouse_handlers list

2015-04-27 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- ui/input-legacy.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 2d4ca19..3e9bb38 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -57,8 +57,6 @@ struct QEMUPutLEDEntry { static QTAILQ_HEAD

[Qemu-devel] [PATCH 3/6] qemu-char: remove unused list node from FDCharDriver

2015-04-27 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- qemu-char.c | 1 - 1 file changed, 1 deletion(-) diff --git a/qemu-char.c b/qemu-char.c index a405d76..d0c1564 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -973,7 +973,6 @@ typedef struct FDCharDriver { CharDriverState *chr; GIOChannel *fd_in

[Qemu-devel] [PATCH 5/6] coroutine: remove unnecessary parentheses in qemu_co_queue_empty

2015-04-27 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- qemu-coroutine-lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c index e4860ae..6b49033 100644 --- a/qemu-coroutine-lock.c +++ b/qemu-coroutine-lock.c @@ -108,7 +108,7 @@ bool

Re: [Qemu-devel] [RFC 00/10] MultiThread TCG.

2015-04-27 Thread Emilio G. Cota
Hi Fred, On Wed, Apr 22, 2015 at 14:26:14 +0200, Frederic Konrad wrote: > git clone g...@git.greensocs.com:fkonrad/mttcg.git -b multi_tcg_v4 I've tried to run buildroot's vexpress-a9 with this, but unfortunately it gets stuck before showing much progress towards boot: [ messages in brackets are m

Re: [Qemu-devel] [PATCH 4/6] gitignore: ignore *.patch files

2015-04-27 Thread Emilio G. Cota
On Mon, Apr 27, 2015 at 12:28:00 -0600, Eric Blake wrote: > On 04/27/2015 12:11 PM, Peter Crosthwaite wrote: > > This Issue is discussed and I think it was concluded to not gitignore > > patches. See: > > > > commit f3a22014e94dfaacb57277dafce66b41cd994869 > > Author: Michael Tokarev > > Date:

Re: [Qemu-devel] [RFC 00/10] MultiThread TCG.

2015-04-28 Thread Emilio G. Cota
On Tue, Apr 28, 2015 at 11:06:37 +0200, Paolo Bonzini wrote: > On 27/04/2015 19:06, Emilio G. Cota wrote: > > Note that I'm running with -smp 1. My guess is that the iothread > > is starved, since patch 472f4003 "Drop global lock during TCG code > > execution&quo

Re: [Qemu-devel] [PATCH 1/8] tls: require compiler support for __thread

2015-04-28 Thread Emilio G. Cota
the missing piece to have this patch finally merged? Thanks, Emilio commit ad45e590025c1197a7aef5164e1ae174894b0969 Author: Emilio G. Cota Date: Tue Apr 28 16:54:44 2015 -0400 configure: require __thread support The codebase doesn't build without __thread support. Forma

Re: [Qemu-devel] [RFC 0/5] Slow-path for atomic instruction translation

2015-05-26 Thread Emilio G. Cota
On Mon, May 11, 2015 at 11:10:05 +0200, alvise rigo wrote: > the last commit was b8df9208f357d2b36e1b19634aea973618dc7ba8. Thanks. Unfortunately a segfault still happens very early: $ gdb arm-softmmu/qemu-system-arm GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04 Copyright (C) 2012 Fr

Re: [Qemu-devel] [qemu] How to reliably obtain physaddr from vaddr

2015-03-15 Thread Emilio G. Cota
On Sun, Mar 15, 2015 at 16:10:21 -0700, Richard Henderson wrote: > On 03/15/2015 03:00 AM, Emilio G. Cota wrote: > > On a TLB hit this is trivial (just do nothing), but on > > a TLB miss I'm lost on what to do--I cannot even follow > > where helper_ld/st go (grep

Re: [Qemu-devel] [qemu] How to reliably obtain physaddr from vaddr

2015-03-16 Thread Emilio G. Cota
On Sun, Mar 15, 2015 at 20:42:31 -0400, Emilio G. Cota wrote: > On Sun, Mar 15, 2015 at 16:10:21 -0700, Richard Henderson wrote: > > It goes into softmmu_template.h. Which then tests a victim tlb, and finally > > calls tlb_fill. You'll probably need to do the same. > &g

Re: [Qemu-devel] [qemu] How to reliably obtain physaddr from vaddr

2015-03-16 Thread Emilio G. Cota
On Mon, Mar 16, 2015 at 22:23:24 +, Peter Maydell wrote: > On 16 March 2015 at 20:08, Emilio G. Cota wrote: > > I fail to see why calling tlb_fill() from the helper causes > > trouble. What I thought would happen is that the exception > > (if any) is started from the

Re: [Qemu-devel] [RFC v5 0/6] Slow-path for atomic instruction translation

2015-10-01 Thread Emilio G. Cota
On Wed, Sep 30, 2015 at 06:44:32 +0200, Paolo Bonzini wrote: > I have a doubt about your patches for ll/sc emulation, that I hope you > can clarify. > > From 1ft, both approaches rely on checking a flag during stores. > This is split between the TLB and the CPUState for Alvise's patches (in >

Re: [Qemu-devel] [PATCH 08/10] tcg: add memory barriers in page_find_alloc accesses

2015-08-12 Thread Emilio G. Cota
On Wed, Aug 12, 2015 at 18:41:00 +0200, Paolo Bonzini wrote: > page_find is reading the radix tree outside all locks, so it has to > use the RCU primitives. It does not need RCU critical sections > because the PageDescs are never removed, so there is never a need > to wait for the end of code sect

Re: [Qemu-devel] [PATCH 08/10] tcg: add memory barriers in page_find_alloc accesses

2015-08-13 Thread Emilio G. Cota
On Thu, Aug 13, 2015 at 10:13:32 +0200, Paolo Bonzini wrote: > On 12/08/2015 22:37, Emilio G. Cota wrote: > > > page_find is reading the radix tree outside all locks, so it has to > > > use the RCU primitives. It does not need RCU critical sections > > > because t

Re: [Qemu-devel] [RFC 08/38] rcu: init rcu_registry_lock after fork

2015-09-08 Thread Emilio G. Cota
On Tue, Sep 08, 2015 at 18:34:38 +0100, Alex Bennée wrote: > Emilio G. Cota writes: (snip) > > +static void rcu_init_child(void) > > +{ > > +qemu_mutex_init(&rcu_registry_lock); > > +} > > #endif > > > > void rcu_after_fork(void)

Re: [Qemu-devel] [RFC 11/38] qemu-thread: handle spurious futex_wait wakeups

2015-09-10 Thread Emilio G. Cota
On Thu, Sep 10, 2015 at 14:22:49 +0100, Alex Bennée wrote: > Emilio G. Cota writes: > > > Signed-off-by: Emilio G. Cota > > --- > > util/qemu-thread-posix.c | 11 ++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/u

Re: [Qemu-devel] [RFC 13/38] cputlb: add physical address to CPUTLBEntry

2015-09-10 Thread Emilio G. Cota
On Thu, Sep 10, 2015 at 14:49:07 +0100, Alex Bennée wrote: > Emilio G. Cota writes: > > > Having the physical address in the TLB entry will allow us > > to portably obtain the physical address of a memory access, > > which will prove useful when implementing a scalable

Re: [Qemu-devel] [RFC 15/38] radix-tree: add generic lockless radix tree module

2015-09-10 Thread Emilio G. Cota
On Thu, Sep 10, 2015 at 15:25:50 +0100, Alex Bennée wrote: > > Emilio G. Cota writes: > > > This will be used by atomic instruction emulation code. > > If we are adding utility functions into the code base like this (which I > can see being useful) we should at leas

Re: [Qemu-devel] [RFC 19/38] tcg: add tcg_gen_smp_rmb()

2015-09-10 Thread Emilio G. Cota
On Thu, Sep 10, 2015 at 17:01:14 +0100, Alex Bennée wrote: > > Emilio G. Cota writes: > > > Signed-off-by: Emilio G. Cota > > --- > > tcg/tcg-op.h | 10 ++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/tcg/tcg-op.h b/tcg/tcg-op.

[Qemu-devel] [RFC 10/38] translate-all: remove obsolete comment about l1_map

2015-08-23 Thread Emilio G. Cota
l1_map is based on physical addresses in full-system mode, as pointed out in an earlier comment. Said comment also mentions that virtual addresses are only used in l1_map in user-only mode. Signed-off-by: Emilio G. Cota --- translate-all.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions

[Qemu-devel] [RFC 01/38] cpu-exec: add missing mmap_lock in tb_find_slow

2015-08-23 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- cpu-exec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu-exec.c b/cpu-exec.c index f53475c..b8a11e1 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -330,6 +330,7 @@ static TranslationBlock *tb_find_slow(CPUState *cpu, if (!tb) { tb

[Qemu-devel] [RFC 13/38] cputlb: add physical address to CPUTLBEntry

2015-08-23 Thread Emilio G. Cota
Having the physical address in the TLB entry will allow us to portably obtain the physical address of a memory access, which will prove useful when implementing a scalable emulation of atomic instructions. Signed-off-by: Emilio G. Cota --- cputlb.c| 1 + include/exec/cpu-defs.h

[Qemu-devel] [RFC 06/38] seqlock: add missing 'inline' to seqlock_read_retry

2015-08-23 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- include/qemu/seqlock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qemu/seqlock.h b/include/qemu/seqlock.h index 3ff118a..f1256f5 100644 --- a/include/qemu/seqlock.h +++ b/include/qemu/seqlock.h @@ -62,7 +62,7 @@ static inline

[Qemu-devel] [RFC 08/38] rcu: init rcu_registry_lock after fork

2015-08-23 Thread Emilio G. Cota
We were unlocking this lock after fork, which is wrong since only the thread that holds a mutex is allowed to unlock it. Signed-off-by: Emilio G. Cota --- util/rcu.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/rcu.c b/util/rcu.c index 8ba304d..47c2bce 100644

[Qemu-devel] [RFC 07/38] seqlock: read sequence number atomically

2015-08-23 Thread Emilio G. Cota
With this change we make sure that the compiler will not optimise the read of the sequence number in any way. Signed-off-by: Emilio G. Cota --- include/qemu/seqlock.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/qemu/seqlock.h b/include/qemu/seqlock.h index

[Qemu-devel] [RFC 04/38] translate-all: remove volatile from have_tb_lock

2015-08-23 Thread Emilio G. Cota
This is a thread-local variable and therefore all changes to it will be seen in order by the owning thread. There is no need for it to be volatile. Signed-off-by: Emilio G. Cota --- translate-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translate-all.c b/translate

[Qemu-devel] [RFC 03/38] cpu-exec: set current_cpu at cpu_exec()

2015-08-23 Thread Emilio G. Cota
So that it applies to usermode as well. Signed-off-by: Emilio G. Cota --- cpu-exec.c | 2 ++ cpus.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cpu-exec.c b/cpu-exec.c index b8a11e1..2b9a447 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -386,6 +386,8 @@ int cpu_exec

[Qemu-devel] [RFC 18/38] tcg: add fences

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- tcg/tcg-op.c | 5 + tcg/tcg-op.h | 18 ++ tcg/tcg-opc.h | 5 + 3 files changed, 28 insertions(+) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 45098c3..6d5b1df 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -57,6 +57,11 @@ static

[Qemu-devel] [RFC 29/38] tcg: export have_tb_lock

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tcg/tcg.h b/tcg/tcg.h index 8d30d61..9a873ac 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -599,6 +599,7 @@ void tb_lock(void); void tb_unlock(void); bool tb_lock_recursive(void); void tb_lock_reset

[Qemu-devel] [RFC 05/38] thread-posix: inline qemu_spin functions

2015-08-24 Thread Emilio G. Cota
On some parallel workloads this gives up to a 15% speed improvement. Signed-off-by: Emilio G. Cota --- include/qemu/thread-posix.h | 47 ++ include/qemu/thread.h | 6 -- util/qemu-thread-posix.c| 50

[Qemu-devel] [RFC 02/38] hw/i386/kvmvapic: add missing include of tcg.h

2015-08-24 Thread Emilio G. Cota
So that the declaration of tb_lock can be found. Signed-off-by: Emilio G. Cota --- hw/i386/kvmvapic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index 1c3b5b6..a9a33fd 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -13,6 +13,7

[Qemu-devel] [RFC 19/38] tcg: add tcg_gen_smp_rmb()

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- tcg/tcg-op.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 52482c0..3ec9f13 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -716,6 +716,16 @@ static inline void tcg_gen_fence_full(void) tcg_gen_op0

[Qemu-devel] [RFC 12/38] linux-user: call rcu_(un)register_thread on pthread_(exit|create)

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f62c698..732936f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4513,6 +4513,7 @@ static void *clone_func(void *arg

[Qemu-devel] [RFC 14/38] softmmu: add helpers to get ld/st physical addresses

2015-08-24 Thread Emilio G. Cota
This will be used by the atomic instruction emulation code. Signed-off-by: Emilio G. Cota --- softmmu_template.h | 48 tcg/tcg.h | 5 + 2 files changed, 53 insertions(+) diff --git a/softmmu_template.h b/softmmu_template.h index

[Qemu-devel] [RFC 11/38] qemu-thread: handle spurious futex_wait wakeups

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- util/qemu-thread-posix.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index 04dae0f..3760e27 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -303,7

[Qemu-devel] [RFC 31/38] cpu: protect l1_map with tb_lock in full-system mode

2015-08-24 Thread Emilio G. Cota
Note that user-only uses mmap_lock for this. Signed-off-by: Emilio G. Cota --- translate-all.c | 31 +++ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/translate-all.c b/translate-all.c index e7b4a31..8f8c402 100644 --- a/translate-all.c +++ b

[Qemu-devel] [RFC 15/38] radix-tree: add generic lockless radix tree module

2015-08-24 Thread Emilio G. Cota
This will be used by atomic instruction emulation code. Signed-off-by: Emilio G. Cota --- include/qemu/radix-tree.h | 29 ++ util/Makefile.objs| 2 +- util/radix-tree.c | 75 +++ 3 files changed, 105 insertions(+), 1

[Qemu-devel] [RFC 17/38] aie: add target helpers

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- aie-helper.c | 112 ++ include/exec/cpu-defs.h | 5 +++ include/qemu/aie-helper.h | 6 +++ 3 files changed, 123 insertions(+) create mode 100644 aie-helper.c create mode 100644 include/qemu/aie

[Qemu-devel] [RFC 00/38] MTTCG: i386, user+system mode

2015-08-24 Thread Emilio G. Cota
Hi all, Here is MTTCG code I've been working on out-of-tree for the last few months. The patchset applies on top of pbonzini's mttcg branch, commit ca56de6f. Fetch the branch from: https://github.com/bonzini/qemu/commits/mttcg The highlights of the patchset are as follows: - The first 5 patches

[Qemu-devel] [RFC 25/38] cpu: add barriers around cpu->tcg_exit_req

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- include/exec/gen-icount.h | 1 + translate-all.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 05d89d3..f429821 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h

[Qemu-devel] [RFC 20/38] tcg/i386: implement fences

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- tcg/i386/tcg-target.c | 20 1 file changed, 20 insertions(+) diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 887f22f..6600c45 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -1123,6 +1123,13 @@ static void

[Qemu-devel] [RFC 16/38] aie: add module for Atomic Instruction Emulation

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- Makefile.target| 1 + aie.c | 57 ++ include/qemu/aie.h | 49 ++ translate-all.c| 2 ++ 4 files changed, 109 insertions(+) create mode 100644

[Qemu-devel] [RFC 09/38] rcu: fix comment with s/rcu_gp_lock/rcu_registry_lock/

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- include/qemu/rcu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h index 7df1e86..f6d1d56 100644 --- a/include/qemu/rcu.h +++ b/include/qemu/rcu.h @@ -71,7 +71,7 @@ struct rcu_reader_data { /* Data

[Qemu-devel] [RFC 23/38] cpu-exec: grab iothread lock during interrupt handling

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- cpu-exec.c| 34 -- include/qom/cpu.h | 1 + 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index fd57b9c..a1700ac 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -371,6 +371,29

[Qemu-devel] [RFC 24/38] cpu-exec: reset mmap_lock after exiting the CPU loop

2015-08-24 Thread Emilio G. Cota
Otherwise after an exception we end up in a deadlock. Signed-off-by: Emilio G. Cota --- bsd-user/mmap.c | 12 cpu-exec.c | 1 + include/exec/exec-all.h | 2 ++ linux-user/mmap.c | 8 4 files changed, 23 insertions(+) diff --git a/bsd-user

[Qemu-devel] [RFC 26/38] cpu: protect tb_jmp_cache with seqlock

2015-08-24 Thread Emilio G. Cota
This paves the way for a lockless tb_find_fast. Signed-off-by: Emilio G. Cota --- cpu-exec.c| 8 +++- exec.c| 2 ++ include/qom/cpu.h | 15 +++ qom/cpu.c | 2 +- translate-all.c | 32 +++- 5 files changed, 56

[Qemu-devel] [RFC 30/38] translate-all: add tb_lock assertions

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- translate-all.c | 28 1 file changed, 28 insertions(+) diff --git a/translate-all.c b/translate-all.c index df65c83..e7b4a31 100644 --- a/translate-all.c +++ b/translate-all.c @@ -252,6 +252,8 @@ static int cpu_restore_state_from_tb

[Qemu-devel] [RFC 21/38] target-i386: emulate atomic instructions + barriers using AIE

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- aie-helper.c | 3 +- linux-user/main.c | 4 +- target-i386/cpu.h | 3 - target-i386/excp_helper.c | 7 ++ target-i386/helper.h | 6 +- target-i386/mem_helper.c | 39 +++-- target-i386/translate.c | 217

[Qemu-devel] [RFC 34/38] translate-all: use tcg_sched_work for tb_flush

2015-08-24 Thread Emilio G. Cota
While at it, add an assertion in tb_flush to check for tb_lock being held. Signed-off-by: Emilio G. Cota --- translate-all.c | 40 +++- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/translate-all.c b/translate-all.c index f3f7fb2..378517d

[Qemu-devel] [RFC 36/38] cputlb: use tcg_sched_work for tlb_flush_page_all

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- cputlb.c | 39 +++ 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/cputlb.c b/cputlb.c index d81a4eb..717a856 100644 --- a/cputlb.c +++ b/cputlb.c @@ -145,41 +145,24 @@ void tlb_flush_page(CPUState *cpu

[Qemu-devel] [RFC 32/38] cpu list: convert to RCU QLIST

2015-08-24 Thread Emilio G. Cota
This avoids the chance of reading a corrupted list of CPUs in usermode. Note: this breaks hw/ppc/spapr due to the removal of CPU_FOREACH_REVERSE. Signed-off-by: Emilio G. Cota --- exec.c | 16 ++-- include/qom/cpu.h| 15 +++ linux-user/main.c| 2

[Qemu-devel] [RFC 35/38] cputlb: use cpu_tcg_sched_work for tlb_flush_all

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- cputlb.c | 41 +++-- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/cputlb.c b/cputlb.c index 1b3673e..d81a4eb 100644 --- a/cputlb.c +++ b/cputlb.c @@ -73,43 +73,24 @@ void tlb_flush(CPUState *cpu, int

[Qemu-devel] [RFC 22/38] cpu: update interrupt_request atomically

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- cpu-exec.c | 9 ++--- exec.c | 2 +- hw/openrisc/cputimer.c | 2 +- qom/cpu.c | 4 ++-- target-arm/helper-a64.c| 2 +- target-arm/helper.c

[Qemu-devel] [RFC 38/38] Revert "target-i386: yield to another VCPU on PAUSE"

2015-08-24 Thread Emilio G. Cota
significantly because threads are most of the time just exiting the CPU loop, thereby causing great contention on the BQL. Fix it by reverting to the old behaviour by which no interrupt is raised, which shouldn't be an issue given that we have now one thread per VCPU. Signed-off-by: Emilio G.

[Qemu-devel] [RFC 27/38] cpu-exec: convert tb_invalidated_flag into a per-TB flag

2015-08-24 Thread Emilio G. Cota
This will allow us to safely look up TB's without taking any locks. Note however that tb_lock protects the valid field, so if chaining is an option then we'll have to acquire the lock. Signed-off-by: Emilio G. Cota --- cpu-exec.c | 23 +++--- include/exec/

[Qemu-devel] [RFC 37/38] cpus: remove async_run_safe_work_on_cpu

2015-08-24 Thread Emilio G. Cota
It has no callers left. Signed-off-by: Emilio G. Cota --- cpu-exec.c| 10 - cpus.c| 64 +-- include/qom/cpu.h | 24 + 3 files changed, 2 insertions(+), 96 deletions(-) diff --git a/cpu-exec.c b

[Qemu-devel] [RFC 33/38] cpu: introduce cpu_tcg_sched_work to run work while other CPUs sleep

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- cpu-exec.c | 89 + exec.c | 4 +++ include/exec/exec-all.h | 5 +++ include/qom/cpu.h | 20 +++ tcg/tcg.h | 1 + translate-all.c | 23

[Qemu-devel] [RFC 28/38] cpu-exec: use RCU to perform lockless TB lookups

2015-08-24 Thread Emilio G. Cota
t be OK to just leave it alone. Signed-off-by: Emilio G. Cota --- cpu-exec.c | 21 +--- include/exec/exec-all.h | 12 +--- translate-all.c | 52 - 3 files changed, 43 insertions(+), 42 deletions(-) diff -

Re: [Qemu-devel] [RFC 00/38] MTTCG: i386, user+system mode

2015-08-24 Thread Emilio G. Cota
On Mon, Aug 24, 2015 at 18:08:37 +0200, Artyom Tarasenko wrote: > On Mon, Aug 24, 2015 at 2:23 AM, Emilio G. Cota wrote: > > * tb_lock must be held every time code is generated. The rationale is > > that most of the time QEMU is executing code, not generating it. > >

[Qemu-devel] [PATCH 3/4] linux-user: call rcu_(un)register_thread on thread creation/deletion

2015-08-24 Thread Emilio G. Cota
Note that the right place to call rcu_register_thread() is do_cpu_loop() and not just in clone_func(), since the original 'main' thread needs to call rcu_register_thread() as well. Signed-off-by: Emilio G. Cota --- linux-user/qemu.h| 1 + linux-user/syscall.c | 1 + 2 files

[Qemu-devel] [PATCH 2/4] linux-user: add helper to set current_cpu before cpu_loop()

2015-08-24 Thread Emilio G. Cota
There are as many versions of cpu_loop as architectures supported, so introduce here a helper that is common to all of them. Signed-off-by: Emilio G. Cota --- linux-user/main.c| 2 +- linux-user/qemu.h| 6 ++ linux-user/syscall.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions

[Qemu-devel] [PATCH 4/4] bsd-user: add helper to set current_cpu before cpu_loop()

2015-08-24 Thread Emilio G. Cota
Note: cannot compile bsd-user here (linux), please compile-test. Signed-off-by: Emilio G. Cota --- bsd-user/main.c | 2 +- bsd-user/qemu.h | 6 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index ee68daa..0bea358 100644 --- a/bsd-user

[Qemu-devel] [PATCH 1/4] cpus: add qemu_cpu_thread_init_common() to avoid code duplication

2015-08-24 Thread Emilio G. Cota
Signed-off-by: Emilio G. Cota --- cpus.c | 32 +--- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/cpus.c b/cpus.c index 81dda93..fd9e903 100644 --- a/cpus.c +++ b/cpus.c @@ -922,18 +922,23 @@ static void qemu_kvm_wait_io_event(CPUState *cpu

Re: [Qemu-devel] [RFC 12/38] linux-user: call rcu_(un)register_thread on pthread_(exit|create)

2015-08-24 Thread Emilio G. Cota
On Sun, Aug 23, 2015 at 20:23:41 -0400, Emilio G. Cota wrote: > Signed-off-by: Emilio G. Cota > --- > linux-user/syscall.c | 2 ++ > 1 file changed, 2 insertions(+) Just noticed that this patch is incomplete, since the 'main' thread doesn't get to call rcu_register_

Re: [Qemu-devel] [RFC 05/38] thread-posix: inline qemu_spin functions

2015-08-24 Thread Emilio G. Cota
On Sun, Aug 23, 2015 at 18:04:46 -0700, Paolo Bonzini wrote: > On 23/08/2015 17:23, Emilio G. Cota wrote: > > On some parallel workloads this gives up to a 15% speed improvement. > > > > Signed-off-by: Emilio G. Cota > > --- > >

Re: [Qemu-devel] [RFC 14/38] softmmu: add helpers to get ld/st physical addresses

2015-08-24 Thread Emilio G. Cota
On Sun, Aug 23, 2015 at 19:02:30 -0700, Paolo Bonzini wrote: > On 23/08/2015 17:23, Emilio G. Cota wrote: > > This will be used by the atomic instruction emulation code. > > Is this a fast path? If not, we can use the existing addend field and > convert the host address to a

Re: [Qemu-devel] [RFC 20/38] tcg/i386: implement fences

2015-08-24 Thread Emilio G. Cota
On Sun, Aug 23, 2015 at 18:32:51 -0700, Paolo Bonzini wrote: > > > On 23/08/2015 17:23, Emilio G. Cota wrote: > > +case INDEX_op_fence_load: > > +tcg_out_fence(s, 0xe8); > > +break; > > +case INDEX_op_fence_full: > > +tcg

Re: [Qemu-devel] [PATCH 4/4] bsd-user: add helper to set current_cpu before cpu_loop()

2015-08-25 Thread Emilio G. Cota
On Mon, Aug 24, 2015 at 20:41:10 -0400, Emilio G. Cota wrote: > Note: cannot compile bsd-user here (linux), please compile-test. > > Signed-off-by: Emilio G. Cota > --- (snip) > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h > index 5902614..751efd5 100644 > --- a/bsd-us

Re: [Qemu-devel] [RFC 05/38] thread-posix: inline qemu_spin functions

2015-08-25 Thread Emilio G. Cota
On Mon, Aug 24, 2015 at 22:30:03 -0400, Emilio G. Cota wrote: > On Sun, Aug 23, 2015 at 18:04:46 -0700, Paolo Bonzini wrote: > > On 23/08/2015 17:23, Emilio G. Cota wrote: > (snip) > > Applied, but in the end the spinlock will probably simply use a simple > > test-and-test

Re: [Qemu-devel] [RFC 22/38] cpu: update interrupt_request atomically

2015-08-25 Thread Emilio G. Cota
On Sun, Aug 23, 2015 at 18:09:48 -0700, Paolo Bonzini wrote: > On 23/08/2015 17:23, Emilio G. Cota wrote: > > Signed-off-by: Emilio G. Cota > > --- > > cpu-exec.c | 9 ++--- > > exec.c | 2 +- > > hw/ope

Re: [Qemu-devel] [RFC 24/38] cpu-exec: reset mmap_lock after exiting the CPU loop

2015-08-25 Thread Emilio G. Cota
On Sun, Aug 23, 2015 at 19:01:39 -0700, Paolo Bonzini wrote: > On 23/08/2015 17:23, Emilio G. Cota wrote: > > Otherwise after an exception we end up in a deadlock. > > Can you explain better the path that exits cpu_exec with the lock taken? In fact I cannot :-) So please ignore

  1   2   3   4   5   6   7   8   9   10   >