Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-06 Thread Sergey Fedorov
On 06/06/16 18:58, Pranith Kumar wrote: > On Mon, Jun 6, 2016 at 11:49 AM, Sergey Fedorov wrote: >> On 06/06/16 18:47, Pranith Kumar wrote: >>> On Mon, Jun 6, 2016 at 11:44 AM, Sergey Fedorov >>> wrote: >>>> On 03/06/16 21:27, Pranith Kumar wrote: >&g

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-06 Thread Sergey Fedorov
On 06/06/16 18:47, Pranith Kumar wrote: > On Mon, Jun 6, 2016 at 11:44 AM, Sergey Fedorov wrote: >> On 03/06/16 21:27, Pranith Kumar wrote: >>> On Thu, Jun 2, 2016 at 5:18 PM, Richard Henderson wrote: >>>> What if we have tcg_canonicalize_memop (or some such

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-06 Thread Sergey Fedorov
On 03/06/16 21:27, Pranith Kumar wrote: > On Thu, Jun 2, 2016 at 5:18 PM, Richard Henderson wrote: >> Hum. That does seem helpful-ish. But I'm not certain how helpful it is to >> complicate the helper functions even further. >> >> What if we have tcg_canonicalize_memop (or some such) split off t

Re: [Qemu-devel] [RFC v1 12/12] cpus: default MTTCG to on for 32 bit ARM on x86

2016-06-06 Thread Sergey Fedorov
On 06/06/16 11:58, Alex Bennée wrote: > Sergey Fedorov writes: > >> On 15/04/16 17:23, Alex Bennée wrote: >>> diff --git a/cpus.c b/cpus.c >>> index 860e2a9..daa92c7 100644 >>> --- a/cpus.c >>> +++ b/cpus.c >>> @@ -171,12 +171,2

Re: [Qemu-devel] [RFC v1 09/12] translate-all: introduces tb_flush_safe.

2016-06-06 Thread Sergey Fedorov
On 06/06/16 11:54, Alex Bennée wrote: > Sergey Fedorov writes: > >> On 15/04/16 17:23, Alex Bennée wrote: >>> diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h >>> index f695577..858055b 100644 >>> --- a/include/exec/exec-all.h >>> ++

Re: [Qemu-devel] [RFC v1 08/12] cputlb: introduce tlb_flush_* async work.

2016-06-06 Thread Sergey Fedorov
On 06/06/16 11:54, Alex Bennée wrote: > Sergey Fedorov writes: > >> On 15/04/16 17:23, Alex Bennée wrote: >>> diff --git a/cputlb.c b/cputlb.c >>> index 1412049..42a3b07 100644 >>> --- a/cputlb.c >>> +++ b/cputlb.c (snip) >>> @@ -89,6

Re: [Qemu-devel] [RFC v1 07/12] cpus: introduce async_safe_run_on_cpu.

2016-06-06 Thread Sergey Fedorov
On 06/06/16 11:50, Alex Bennée wrote: > Sergey Fedorov writes: > >> On 15/04/16 17:23, Alex Bennée wrote: >>> diff --git a/cpus.c b/cpus.c >>> index 9177161..860e2a9 100644 >>> --- a/cpus.c >>> +++ b/cpus.c >>> @@ -928,6 +928,

Re: [Qemu-devel] [RFC v1 12/12] cpus: default MTTCG to on for 32 bit ARM on x86

2016-06-05 Thread Sergey Fedorov
On 15/04/16 17:23, Alex Bennée wrote: > This makes multi-threading the default for 32 bit ARM on x86. It has > been tested with Debian Jessie as well as my extended KVM unit tests > which stress the SMC and TB invalidation code. Those tests can be found > at: > > https://github.com/stsquad/kvm-un

Re: [Qemu-devel] [RFC v1 10/12] arm: use tlb_flush_page_all for tlbimva[a]

2016-06-05 Thread Sergey Fedorov
On 15/04/16 17:23, Alex Bennée wrote: > From: KONRAD Frederic > > Instead of flushing each individual vCPU use the tlb_flush_page_all > functions which is async enabled for MTTCG. > > Signed-off-by: KONRAD Frederic > Signed-off-by: Alex Bennée > --- > include/exec/exec-all.h | 3 +++ > target-

Re: [Qemu-devel] [RFC v1 09/12] translate-all: introduces tb_flush_safe.

2016-06-05 Thread Sergey Fedorov
On 15/04/16 17:23, Alex Bennée wrote: > diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h > index f695577..858055b 100644 > --- a/include/exec/exec-all.h > +++ b/include/exec/exec-all.h > @@ -307,6 +307,7 @@ struct TBContext { > > void tb_free(TranslationBlock *tb); > void tb_flush

Re: [Qemu-devel] [RFC v1 07/12] cpus: introduce async_safe_run_on_cpu.

2016-06-05 Thread Sergey Fedorov
On 15/04/16 17:23, Alex Bennée wrote: > +/* > + * Safe work interface > + * > + * Safe work is defined as work that requires the system to be > + * quiescent before making changes. > + */ > + > +void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data) > +{ > +CPUState *iter;

Re: [Qemu-devel] [RFC v1 08/12] cputlb: introduce tlb_flush_* async work.

2016-06-05 Thread Sergey Fedorov
On 15/04/16 17:23, Alex Bennée wrote: > diff --git a/cputlb.c b/cputlb.c > index 1412049..42a3b07 100644 > --- a/cputlb.c > +++ b/cputlb.c > @@ -56,22 +56,14 @@ > } \ > } while (0) > > +/* We need a solution for stuffing 64 bit pointers in 32 bit ones if > + * we care about this combination

Re: [Qemu-devel] [RFC v1 07/12] cpus: introduce async_safe_run_on_cpu.

2016-06-05 Thread Sergey Fedorov
On 15/04/16 17:23, Alex Bennée wrote: > diff --git a/cpu-exec-common.c b/cpu-exec-common.c > index 3d7eaa3..c2f7c29 100644 > --- a/cpu-exec-common.c > +++ b/cpu-exec-common.c > @@ -79,3 +79,4 @@ void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc) > cpu->current_tb = NULL; > siglongjmp

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-03 Thread Sergey Fedorov
On 03/06/16 23:43, Peter Maydell wrote: > On 3 June 2016 at 20:49, Sergey Fedorov wrote: >> I'm not so sure about acq/rel flags. Is there any architecture which has >> explicit acq/rel barriers? I suppose acq/rel memory access instructions >> are always load-link and

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-03 Thread Sergey Fedorov
On 03/06/16 21:27, Pranith Kumar wrote: > On Thu, Jun 2, 2016 at 5:18 PM, Richard Henderson wrote: >> > >> > Hum. That does seem helpful-ish. But I'm not certain how helpful it is to >> > complicate the helper functions even further. >> > >> > What if we have tcg_canonicalize_memop (or some such

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-03 Thread Sergey Fedorov
On 03/06/16 21:30, Pranith Kumar wrote: > On Thu, Jun 2, 2016 at 9:08 PM, Richard Henderson wrote: >> On 06/02/2016 02:37 PM, Sergey Fedorov wrote: >>> >>> It would give us three TCG operations for each memory operation instead >>> of one. But then we

Re: [Qemu-devel] [PATCH v6 08/15] qdist: add module to represent frequency distributions of data

2016-06-03 Thread Sergey Fedorov
On 03/06/16 20:29, Sergey Fedorov wrote: > On 03/06/16 20:22, Emilio G. Cota wrote: >> On Sat, May 28, 2016 at 21:15:06 +0300, Sergey Fedorov wrote: >>> On 25/05/16 04:13, Emilio G. Cota wrote: >>> (snip) >>>> +double qdist_avg(const struct qdist *dist

Re: [Qemu-devel] [PATCH v6 08/15] qdist: add module to represent frequency distributions of data

2016-06-03 Thread Sergey Fedorov
On 03/06/16 20:22, Emilio G. Cota wrote: > On Sat, May 28, 2016 at 21:15:06 +0300, Sergey Fedorov wrote: >> On 25/05/16 04:13, Emilio G. Cota wrote: >> (snip) >>> +double qdist_avg(const struct qdist *dist) >>> +{ >>> +unsigned long count;

Re: [Qemu-devel] [RFC v1 05/12] atomic: introduce cmpxchg_bool

2016-06-03 Thread Sergey Fedorov
On 15/04/16 17:23, Alex Bennée wrote: > diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h > index 5dba7db..94e7110 100644 > --- a/include/qemu/atomic.h > +++ b/include/qemu/atomic.h > @@ -123,6 +123,16 @@ > _old; \ > }

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-03 Thread Sergey Fedorov
On 03/06/16 18:45, Richard Henderson wrote: > On 06/03/2016 08:16 AM, Sergey Fedorov wrote: >> On 03/06/16 04:08, Richard Henderson wrote: >> So your suggestion is to generate different TCG opcode sequences >> depending on the underlying target architecture? And you are again

Re: [Qemu-devel] [PATCH v6 12/15] qht: add qht-bench, a performance benchmark

2016-06-03 Thread Sergey Fedorov
On 03/06/16 14:41, Emilio G. Cota wrote: > On Sun, May 29, 2016 at 23:45:23 +0300, Sergey Fedorov wrote: >> On 25/05/16 04:13, Emilio G. Cota wrote: >>> diff --git a/tests/qht-bench.c b/tests/qht-bench.c >>> new file mode 100644 >>> index 000..30d27c8 &

Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalable Hash Table

2016-06-03 Thread Sergey Fedorov
On 03/06/16 14:01, Emilio G. Cota wrote: > On Sun, May 29, 2016 at 22:52:27 +0300, Sergey Fedorov wrote: >>> +/* >>> + * Find the last valid entry in @head, and swap it with @orig[pos], which >>> has >>> + * just been invalidated. >>> + */ >

Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalable Hash Table

2016-06-03 Thread Sergey Fedorov
On 03/06/16 12:18, Emilio G. Cota wrote: > On Sun, May 29, 2016 at 22:52:27 +0300, Sergey Fedorov wrote: >> I was just wondering if it could be worthwhile to pass a hash function >> when initializing a QHT. Then we could have variants of qht_insert(), >> qht_remove() and qh

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-03 Thread Sergey Fedorov
On 03/06/16 04:08, Richard Henderson wrote: > On 06/02/2016 02:37 PM, Sergey Fedorov wrote: >> On 03/06/16 00:18, Richard Henderson wrote: >>> On 06/02/2016 01:38 PM, Sergey Fedorov wrote: >>>> On 02/06/16 23:36, Richard Henderson wrote: >>>>> On 06/02/

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-02 Thread Sergey Fedorov
On 03/06/16 00:18, Richard Henderson wrote: > On 06/02/2016 01:38 PM, Sergey Fedorov wrote: >> On 02/06/16 23:36, Richard Henderson wrote: >>> On 06/02/2016 09:30 AM, Sergey Fedorov wrote: >>>> I think we need to extend TCG load/store instruction attributes to >&g

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-02 Thread Sergey Fedorov
On 02/06/16 23:36, Richard Henderson wrote: > On 06/02/2016 09:30 AM, Sergey Fedorov wrote: >> I think we need to extend TCG load/store instruction attributes to >> provide information about guest ordering requirements and leave this TCG >> operation only for explici

Re: [Qemu-devel] [RFC v1 04/12] atomic: introduce atomic_dec_fetch.

2016-06-02 Thread Sergey Fedorov
On 15/04/16 17:23, Alex Bennée wrote: > Useful for counting down. > > Signed-off-by: Alex Bennée Reviewed-by: Sergey Fedorov > --- > include/qemu/atomic.h | 4 > 1 file changed, 4 insertions(+) > > diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h > in

Re: [Qemu-devel] [RFC v2 PATCH 11/13] target-arm: Generate fences in ARMv7 frontend

2016-06-02 Thread Sergey Fedorov
On 31/05/16 21:39, Pranith Kumar wrote: > Signed-off-by: Pranith Kumar > Signed-off-by: Richard Henderson > --- > target-arm/translate.c | 7 +-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/target-arm/translate.c b/target-arm/translate.c > index c946c0e..e1b16c0 100644

Re: [Qemu-devel] [RFC v2 PATCH 08/13] tcg/s390: Add support for fence

2016-06-02 Thread Sergey Fedorov
On 31/05/16 21:39, Pranith Kumar wrote: > Cc: Alexander Graf > Signed-off-by: Richard Henderson > Signed-off-by: Pranith Kumar > --- > tcg/s390/tcg-target.inc.c | 9 + > 1 file changed, 9 insertions(+) > > diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c > index e95b04

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-02 Thread Sergey Fedorov
On 02/06/16 00:35, Richard Henderson wrote: > On 06/01/2016 11:43 AM, Pranith Kumar wrote: >> All we want to do here is map a barrier instruction from guest to a >> barrier instruction on hist. This mapping is 1:1 if the host has >> barrier instructions with matching semantics. Otherwise we generat

Re: [Qemu-devel] [RFC v2 PATCH 01/13] Introduce TCGOpcode for memory barrier

2016-06-02 Thread Sergey Fedorov
On 31/05/16 21:39, Pranith Kumar wrote: > diff --git a/tcg/README b/tcg/README > index f4a8ac1..cfe79d7 100644 > --- a/tcg/README > +++ b/tcg/README > @@ -402,6 +402,23 @@ double-word product T0. The later is returned in two > single-word outputs. > > Similar to mulu2, except the two inputs T1

Re: [Qemu-devel] [RFC v2 09/11] tcg: add kick timer for single-threaded vCPU emulation

2016-06-02 Thread Sergey Fedorov
On 02/06/16 19:00, Alex Bennée wrote: > Sergey Fedorov writes: >> On 05/04/16 18:32, Alex Bennée wrote: >>> @@ -1179,6 +1198,14 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) >>> } >>> } >>> >>> +/* Set to kick if we

Re: [Qemu-devel] [RFC v2 05/11] tcg: protect TBContext with tb_lock.

2016-06-02 Thread Sergey Fedorov
On 01/06/16 13:30, Alex Bennée wrote: > Sergey Fedorov writes: > >> On 05/04/16 18:32, Alex Bennée wrote: >> (snip) >>> diff --git a/exec.c b/exec.c >>> index 17f390e..c46c123 100644 >>> --- a/exec.c >>> +++ b/exec.c >>> @@ -211

Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalable Hash Table

2016-06-01 Thread Sergey Fedorov
On 31/05/16 10:46, Alex Bennée wrote: > Sergey Fedorov writes: > >> On 25/05/16 04:13, Emilio G. Cota wrote: >>> diff --git a/include/qemu/qht.h b/include/qemu/qht.h >>> new file mode 100644 >>> index 000..aec60aa >>> --- /dev/null >>>

Re: [Qemu-devel] [PATCH v6 15/15] translate-all: add tb hash bucket info to 'info jit' dump

2016-05-29 Thread Sergey Fedorov
ckets 8192/8192 (100.00% head buckets used) > TB hash occupancy 98.30% avg chain occ. Histogram: > [95.3,95.8)%|▁▁▃▄▃▄▁▇▁█|[99.5,100.0]% > TB hash avg chain 22.070 buckets. Histogram: > [15.0,16.7)|▁▂▅▄█▅|[30.3,32.0] I personally don't see much use of the histogram labels.

Re: [Qemu-devel] [PATCH v6 14/15] tb hash: track translated blocks with qht

2016-05-29 Thread Sergey Fedorov
= get_page_addr_code(desc.env, pc); > +desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; > h = tb_hash_func(phys_pc, pc, flags); > - > -/* Start at head of the hash entry */ > -ptb1 = tb_hash_head = &tcg_ctx.tb_ctx.tb_phys_hash[h]; > -tb = *ptb1; > - > -while (tb) {

Re: [Qemu-devel] [PATCH v6 13/15] qht: add test-qht-par to invoke qht-bench from 'check' target

2016-05-29 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > diff --git a/tests/test-qht-par.c b/tests/test-qht-par.c > new file mode 100644 > index 000..fc0cb23 > --- /dev/null > +++ b/tests/test-qht-par.c > @@ -0,0 +1,56 @@ (snip) > + > +#define TEST_QHT_STRING "tests/qht-bench 1>/dev/null 2>&1 -R -S0.1 -D1000

Re: [Qemu-devel] [PATCH v6 12/15] qht: add qht-bench, a performance benchmark

2016-05-29 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > diff --git a/tests/qht-bench.c b/tests/qht-bench.c > new file mode 100644 > index 000..30d27c8 > --- /dev/null > +++ b/tests/qht-bench.c > @@ -0,0 +1,474 @@ (snip) > +static void do_rw(struct thread_info *info) > +{ > +struct thread_stats *stats =

Re: [Qemu-devel] [PATCH v6 11/15] qht: add test program

2016-05-29 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > Reviewed-by: Alex Bennée > Reviewed-by: Richard Henderson > Signed-off-by: Emilio G. Cota Acked-by: Sergey Fedorov > --- > tests/.gitignore | 1 + > tests/Makefile | 6 ++- > t

Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalable Hash Table

2016-05-29 Thread Sergey Fedorov
On 29/05/16 22:52, Sergey Fedorov wrote: > On 25/05/16 04:13, Emilio G. Cota wrote: >> + >> +/* call with head->lock held */ >> +static bool qht_insert__locked(struct qht *ht, struct qht_map *map, >> + struct qht_bucket *he

Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalable Hash Table

2016-05-29 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > diff --git a/include/qemu/qht.h b/include/qemu/qht.h > new file mode 100644 > index 000..aec60aa > --- /dev/null > +++ b/include/qemu/qht.h > @@ -0,0 +1,183 @@ (snip) > +/** > + * qht_init - Initialize a QHT > + * @ht: QHT to be initialized > + * @n_el

Re: [Qemu-devel] [PATCH v6 09/15] qdist: add test program

2016-05-28 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > Reviewed-by: Richard Henderson > Signed-off-by: Emilio G. Cota Acked-by: Sergey Fedorov > --- > tests/.gitignore | 1 + > tests/Makefile | 6 +- > tests/test-qdist.c | 369 > +++

Re: [Qemu-devel] [PATCH v6 08/15] qdist: add module to represent frequency distributions of data

2016-05-28 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > diff --git a/util/qdist.c b/util/qdist.c > new file mode 100644 > index 000..3343640 > --- /dev/null > +++ b/util/qdist.c > @@ -0,0 +1,386 @@ (snip) > + > +void qdist_add(struct qdist *dist, double x, long count) > +{ > +struct qdist_entry *entry =

Re: [Qemu-devel] [PATCH v6 07/15] tb hash: hash phys_pc, pc, and flags with xxhash

2016-05-28 Thread Sergey Fedorov
ie arm > bootup). This is dealt with later in this series. > > Reviewed-by: Richard Henderson > Reviewed-by: Alex Bennée > Signed-off-by: Emilio G. Cota Reviewed-by: Sergey Fedorov > --- > cpu-exec.c | 4 ++-- > include/exec/tb-hash.h | 8 ++-- >

Re: [Qemu-devel] [PATCH v6 06/15] exec: add tb_hash_func5, derived from xxhash

2016-05-28 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > This will be used by upcoming changes for hashing the tb hash. > > Add this into a separate file to include the copyright notice from > xxhash. > > Reviewed-by: Richard Henderson > Signed-off-by: Emilio G. Cota Review

Re: [Qemu-devel] [PATCH v6 04/15] include/processor.h: define cpu_relax()

2016-05-28 Thread Sergey Fedorov
On 28/05/16 00:10, Emilio G. Cota wrote: > On Fri, May 27, 2016 at 23:53:01 +0300, Sergey Fedorov wrote: >> On 25/05/16 04:13, Emilio G. Cota wrote: >>> Taken from the linux kernel. >>> >>> Reviewed-by: Richard Henderson >>> Reviewed-by: A

Re: [Qemu-devel] [PATCH v6 04/15] include/processor.h: define cpu_relax()

2016-05-27 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > Taken from the linux kernel. > > Reviewed-by: Richard Henderson > Reviewed-by: Alex Bennée > Signed-off-by: Emilio G. Cota > --- > include/qemu/processor.h | 30 ++ > 1 file changed, 30 insertions(+) > create mode 100644 in

Re: [Qemu-devel] [PATCH v6 03/15] seqlock: rename write_lock/unlock to write_begin/end

2016-05-27 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > It is a more appropriate name, now that the mutex embedded > in the seqlock is gone. > > Reviewed-by: Alex Bennée > Reviewed-by: Richard Henderson > Signed-off-by: Emilio G. Cota Reviewed-by: Sergey Fedorov > --- > cpu

Re: [Qemu-devel] [PATCH v6 02/15] seqlock: remove optional mutex

2016-05-27 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > This option is unused; besides, it bloats the struct when not needed. > Let's just let writers define their own locks elsewhere. > > Reviewed-by: Alex Bennée > Reviewed-by: Richard Henderson > Signed-off-by: Emilio G. Cota Revi

Re: [Qemu-devel] [PATCH v6 01/15] compiler.h: add QEMU_ALIGNED() to enforce struct alignment

2016-05-27 Thread Sergey Fedorov
On 25/05/16 04:13, Emilio G. Cota wrote: > Reviewed-by: Richard Henderson > Reviewed-by: Alex Bennée > Signed-off-by: Emilio G. Cota Reviewed-by: Sergey Fedorov > --- > include/qemu/compiler.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/qemu/c

Re: [Qemu-devel] [RFC v2 11/11] tcg: enable thread-per-vCPU

2016-05-27 Thread Sergey Fedorov
On 27/05/16 18:25, Paolo Bonzini wrote: > > On 27/05/2016 17:07, Sergey Fedorov wrote: >>>>>> 1. Make 'cpu->thread_kicked' access atomic >>>>>> 2. Remove global 'exit_request' and use per-CPU 'exit_request' >>&

Re: [Qemu-devel] [RFC v2 11/11] tcg: enable thread-per-vCPU

2016-05-27 Thread Sergey Fedorov
On 27/05/16 17:55, Paolo Bonzini wrote: > > On 27/05/2016 15:57, Sergey Fedorov wrote: >> 1. Make 'cpu->thread_kicked' access atomic >> 2. Remove global 'exit_request' and use per-CPU 'exit_request' >> 3. Change how 'current_cpu

Re: [Qemu-devel] [RFC v2 11/11] tcg: enable thread-per-vCPU

2016-05-27 Thread Sergey Fedorov
On 05/04/16 18:32, Alex Bennée wrote: > From: KONRAD Frederic > > This allows the user to switch on multi-thread behaviour and spawn a > thread per-vCPU. For a simple test like: > > ./arm/run ./arm/locking-test.flat -smp 4 -tcg mttcg=on > > Will now use 4 vCPU threads and have an expected FAIL (

Re: [Qemu-devel] [PATCH v2 10/12] tcg/tci: Add support for fence

2016-05-27 Thread Sergey Fedorov
On 27/05/16 17:17, Pranith Kumar wrote: > Hi Sergey, > > Sergey Fedorov writes: > >> On 27/05/16 04:00, Richard Henderson wrote: >>> diff --git a/tci.c b/tci.c >>> index b488c0d..53b3f71 100644 >>> --- a/tci.c >>> +++ b/tci.c >>> @@

Re: [Qemu-devel] [PATCH v2 10/12] tcg/tci: Add support for fence

2016-05-27 Thread Sergey Fedorov
On 27/05/16 04:00, Richard Henderson wrote: > diff --git a/tci.c b/tci.c > index b488c0d..53b3f71 100644 > --- a/tci.c > +++ b/tci.c > @@ -1236,6 +1236,9 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t > *tb_ptr) > tcg_abort(); > } > break; > +

Re: [Qemu-devel] [PATCH v2 01/12] Introduce TCGOpcode for fence instruction

2016-05-27 Thread Sergey Fedorov
On 27/05/16 04:00, Richard Henderson wrote: > diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h > index 6d0410c..b772d90 100644 > --- a/tcg/tcg-opc.h > +++ b/tcg/tcg-opc.h > @@ -42,6 +42,8 @@ DEF(br, 0, 0, 1, TCG_OPF_BB_END) > # define IMPL64 TCG_OPF_64BIT > #endif > > +DEF(fence, 0, 0, 0, TCG_OPF_SI

Re: [Qemu-devel] qemu-arm-static, multiprocess, atomic

2016-05-26 Thread Sergey Fedorov
On 26/05/16 14:21, Paolo Bonzini wrote: > > On 26/05/2016 12:42, Sergey Fedorov wrote: >> I'm afraid even our recent efforts in >> multi-threaded TCG won't change the situation. The problem is that it >> would require to translate somehow ARM's exclusive a

Re: [Qemu-devel] [RFC v2 07/11] tcg: cpus rm tcg_exec_all()

2016-05-26 Thread Sergey Fedorov
On 05/04/16 18:32, Alex Bennée wrote: > diff --git a/cpus.c b/cpus.c > index e118fdf..46732a5 100644 > --- a/cpus.c > +++ b/cpus.c (snip) > @@ -1109,7 +1108,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) > #endif > } > > -static void tcg_exec_all(void); > +static int tcg_cpu_exec(CPUStat

Re: [Qemu-devel] qemu-arm-static, multiprocess, atomic

2016-05-26 Thread Sergey Fedorov
On 25/05/16 15:34, Jeff Epler wrote: > Hi. Before I take the time to prepare a detailed bug report, I wanted to > ask whether I'm doing something that is expected to work, or expected not > to work. > > I am a developer of the LinuxCNC, Free and Open Source software for control > of milling machin

Re: [Qemu-devel] [RFC PATCH 2/3] tcg: Add support for fence generation in x86 backend

2016-05-25 Thread Sergey Fedorov
On 25/05/16 22:59, Pranith Kumar wrote: > On Wed, May 25, 2016 at 3:43 PM, Sergey Fedorov wrote: >> I think it would better not to defer native support for the operation. >> It should be relatively simple instruction. Otherwise we could wind up >> deferring this indefinitely

Re: [Qemu-devel] [RFC PATCH 2/3] tcg: Add support for fence generation in x86 backend

2016-05-25 Thread Sergey Fedorov
On 25/05/16 22:25, Alex Bennée wrote: > Richard Henderson writes: >> On 05/24/2016 10:18 AM, Pranith Kumar wrote: >>> Signed-off-by: Pranith Kumar >>> --- >>> tcg/i386/tcg-target.h | 1 + >>> tcg/i386/tcg-target.inc.c | 9 + >>> tcg/tcg-opc.h | 2 +- >>> tcg/tcg.c

Re: [Qemu-devel] [RFC v2 03/11] docs: new design document multi-thread-tcg.txt (DRAFTING)

2016-05-25 Thread Sergey Fedorov
On 25/05/16 21:03, Paolo Bonzini wrote: >> The page table seems to be protected by 'mmap_lock' in user mode >> emulation but by 'tb_lock' in system mode emulation. It may turn to be >> possible to read it safely even with no lock held. > Yes, it is possible to at least follow the radix tree safely

Re: [Qemu-devel] [PATCH] cpu-exec: Fix direct jump to TB spanning page

2016-05-25 Thread Sergey Fedorov
On 16/05/16 17:36, Sergey Fedorov wrote: > On 16/05/16 16:49, Richard Henderson wrote: >> On 05/16/2016 06:13 AM, Sergey Fedorov wrote: >>> It is not safe to make a direct jump to a TB spanning two pages in >>> system emulation because the mapping for the second page

Re: [Qemu-devel] [RFC v2 03/11] docs: new design document multi-thread-tcg.txt (DRAFTING)

2016-05-25 Thread Sergey Fedorov
On 11/04/16 23:00, Sergey Fedorov wrote: > On 05/04/16 18:32, Alex Bennée wrote: > > (snip) >> + >> +Memory maps and TLBs >> + >> + >> +The memory handling code is fairly critical to the speed of memory >> +access in the emulate

Re: [Qemu-devel] [PATCH 1/2] atomics: do not use __atomic primitives for RCU atomics

2016-05-25 Thread Sergey Fedorov
On 25/05/16 11:52, Alex Bennée wrote: > Sergey Fedorov writes: > >> On 24/05/16 22:56, Emilio G. Cota wrote: >>> On Tue, May 24, 2016 at 09:08:01 +0200, Paolo Bonzini wrote: >>>> On 23/05/2016 19:09, Emilio G. Cota wrote: >>>>> PS. And really eq

Re: [Qemu-devel] [PATCH v5 13/18] qht: support parallel writes

2016-05-24 Thread Sergey Fedorov
On 25/05/16 01:07, Emilio G. Cota wrote: > On Mon, May 23, 2016 at 23:28:27 +0300, Sergey Fedorov wrote: >> What if we turn qht::lock into a mutex and change the function as follows: >> >> static inline >> struct qht_bucket *qht_bucket_lock__no_stale(struct qh

Re: [Qemu-devel] [RFC v2 10/11] tcg: drop global lock during TCG code execution

2016-05-24 Thread Sergey Fedorov
On 05/04/16 18:32, Alex Bennée wrote: > diff --git a/cpu-exec.c b/cpu-exec.c > index bd50fef..f558508 100644 > --- a/cpu-exec.c > +++ b/cpu-exec.c > @@ -28,6 +28,7 @@ > #include "qemu/rcu.h" > #include "exec/tb-hash.h" > #include "exec/log.h" > +#include "qemu/main-loop.h" > #if defined(TARGET_

Re: [Qemu-devel] [PATCH v2 2/3] atomics: emit an smp_read_barrier_depends() barrier only for Sparc and Thread Sanitizer

2016-05-24 Thread Sergey Fedorov
On 24/05/16 23:06, Emilio G. Cota wrote: > For correctness, smp_read_barrier_depends() is only required to > emit a barrier on Sparc hosts. However, we are currently emitting > a consume fence unconditionally. > > Fix it by keeping the consume fence if we're compiling with Thread > Sanitizer, since

Re: [Qemu-devel] [PATCH 1/2] atomics: do not use __atomic primitives for RCU atomics

2016-05-24 Thread Sergey Fedorov
On 24/05/16 22:56, Emilio G. Cota wrote: > On Tue, May 24, 2016 at 09:08:01 +0200, Paolo Bonzini wrote: >> On 23/05/2016 19:09, Emilio G. Cota wrote: >>> PS. And really equating smp_wmb/rmb to release/acquire as we have under >>> #ifdef __ATOMIC is hard to justify, other than to please tsan. >> Tha

Re: [Qemu-devel] [PATCH v5 00/18] tb hash improvements

2016-05-23 Thread Sergey Fedorov
I think I'm done reviewing v5. (Though I haven't reviewed tests and statistics patches.) Kind regards, Sergey On 14/05/16 06:34, Emilio G. Cota wrote: > This patchset applies on top of tcg-next (8b1fe3f4 "cpu-exec: > Clean up 'interrupt_request' reloading", tagged "pull-tcg-20160512"). > > For re

Re: [Qemu-devel] [PATCH v5 13/18] qht: support parallel writes

2016-05-23 Thread Sergey Fedorov
On 14/05/16 06:34, Emilio G. Cota wrote: > +/* > + * Get a head bucket and lock it, making sure its parent map is not stale. > + * @pmap is filled with a pointer to the bucket's parent map. > + * > + * Unlock with qemu_spin_unlock(&b->lock). > + */ > +static inline > +struct qht_bucket *qht_bucket_

Re: [Qemu-devel] [PATCH v5 12/18] qht: QEMU's fast, resizable and scalable Hash Table

2016-05-23 Thread Sergey Fedorov
On 21/05/16 05:48, Emilio G. Cota wrote: > On Sat, May 21, 2016 at 01:13:20 +0300, Sergey Fedorov wrote: >> Although the API is mostly intuitive some kernel-doc-style comments >> wouldn’t hurt, I think. ;-) > The nit that bothered me is the "external lock needed" bi

Re: [Qemu-devel] GSoC 2016: Introductory email

2016-05-23 Thread Sergey Fedorov
On 20/05/16 15:51, Pranith Kumar wrote: > Hello all, > > I've been selected to participate in GSoC 2016 in the Qemu project. I will be > mentored by Alex Bennée and will be working on solving memory consistency > issues in the MTTCG project. In particular we are targeting to get ARM guests > workin

Re: [Qemu-devel] [PATCH v5 12/18] qht: QEMU's fast, resizable and scalable Hash Table

2016-05-21 Thread Sergey Fedorov
On 21/05/16 05:48, Emilio G. Cota wrote: > Thanks for taking a look! If you have time, please check patch 13 out. > That patch should eventually be merged onto this one. Actually, I was reviewing the final code with all the series applied :) I'd like to spend some time and review all the series in

Re: [Qemu-devel] [PATCH v5 12/18] qht: QEMU's fast, resizable and scalable Hash Table

2016-05-20 Thread Sergey Fedorov
Wow, that's really great stuff! On 14/05/16 06:34, Emilio G. Cota wrote: > diff --git a/include/qemu/qht.h b/include/qemu/qht.h > new file mode 100644 > index 000..c2ab8b8 > --- /dev/null > +++ b/include/qemu/qht.h > @@ -0,0 +1,66 @@ > +/* > + * Copyright (C) 2016, Emilio G. Cota > + * > + *

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-18 Thread Sergey Fedorov
On 18/05/16 23:52, Emilio G. Cota wrote: > On Wed, May 18, 2016 at 22:51:09 +0300, Sergey Fedorov wrote: >> On 14/05/16 06:34, Emilio G. Cota wrote: >>> +static inline void qemu_spin_lock(QemuSpin *spin) >>> +{ >>> +while (atomic_test_and_set_acquire(&sp

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-18 Thread Sergey Fedorov
On 14/05/16 06:34, Emilio G. Cota wrote: > +static inline void qemu_spin_lock(QemuSpin *spin) > +{ > +while (atomic_test_and_set_acquire(&spin->value)) { A possible optimization might be using unlikely() here, copmare: spin.o: file format elf64-littleaarch64 Disassembly of section .text

Re: [Qemu-devel] [PATCH v5 04/18] include/processor.h: define cpu_relax()

2016-05-18 Thread Sergey Fedorov
On 18/05/16 21:29, Emilio G. Cota wrote: > On Wed, May 18, 2016 at 20:47:56 +0300, Sergey Fedorov wrote: >> Why don't do like this: >> >> #if defined(__foo__) >> # define ... >> #elif defined(__bar__) >> # define ... >> #else >> # d

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-18 Thread Sergey Fedorov
On 14/05/16 06:34, Emilio G. Cota wrote: > +static inline int qemu_spin_trylock(QemuSpin *spin) > +{ > +if (atomic_test_and_set_acquire(&spin->value)) { > +return -EBUSY; Seems this should be: return EBUSY; > +} > +return 0; > +}

Re: [Qemu-devel] [PATCH v5 04/18] include/processor.h: define cpu_relax()

2016-05-18 Thread Sergey Fedorov
On 14/05/16 06:34, Emilio G. Cota wrote: > Taken from the linux kernel. > > Reviewed-by: Richard Henderson > Reviewed-by: Alex Bennée > Signed-off-by: Emilio G. Cota > --- > include/qemu/processor.h | 34 ++ > 1 file changed, 34 insertions(+) > create mode 10064

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-18 Thread Sergey Fedorov
On 18/05/16 18:44, Peter Maydell wrote: > On 18 May 2016 at 16:36, Paolo Bonzini wrote: >> On 18/05/2016 17:35, Peter Maydell wrote: > $ arm-linux-gnueabi-gcc -march=armv6 -O2 -c a.c >>> I don't think armv6 is a sufficiently common host for us to >>> worry too much about how its atomic primiti

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-18 Thread Sergey Fedorov
On 18/05/16 17:59, Paolo Bonzini wrote: > > On 18/05/2016 16:47, Sergey Fedorov wrote: >>>>>> Why not? AFAIK the reason to avoid __sync primitives is that in most >>>>>> cases >>>>>> they include barriers that callers might not necessar

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-18 Thread Sergey Fedorov
On 18/05/16 17:18, Sergey Fedorov wrote: > On 18/05/16 03:28, Emilio G. Cota wrote: >> On Tue, May 17, 2016 at 23:20:11 +0300, Sergey Fedorov wrote: >>> On 17/05/16 23:04, Emilio G. Cota wrote: >> (snip) >>>> +/* >>>> + * We might we tempted to

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-18 Thread Sergey Fedorov
On 18/05/16 03:28, Emilio G. Cota wrote: > On Tue, May 17, 2016 at 23:20:11 +0300, Sergey Fedorov wrote: >> On 17/05/16 23:04, Emilio G. Cota wrote: > (snip) >>> +/* >>> + * We might we tempted to use __atomic_test_and_set with __ATOMIC_ACQUIRE; >>> + * how

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-18 Thread Sergey Fedorov
On 18/05/16 17:05, Paolo Bonzini wrote: > > On 18/05/2016 15:59, Sergey Fedorov wrote: >> But actually (cf include/qemu/atomic.h) we can have: >> >>

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-18 Thread Sergey Fedorov
On 18/05/16 02:18, Emilio G. Cota wrote: > On Tue, May 17, 2016 at 23:35:57 +0300, Sergey Fedorov wrote: >> On 17/05/16 22:38, Emilio G. Cota wrote: >>> On Tue, May 17, 2016 at 20:13:24 +0300, Sergey Fedorov wrote: >>>> On 14/05/16 06:34, Emilio G. Cota wrote:

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-17 Thread Sergey Fedorov
On 17/05/16 23:04, Emilio G. Cota wrote: > On Tue, May 17, 2016 at 12:19:27 -0700, Richard Henderson wrote: >> On 05/17/2016 10:13 AM, Sergey Fedorov wrote: >>>>> +static inline void qemu_spin_lock(QemuSpin *spin) >>>>> +{ >>>>> +while (

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-17 Thread Sergey Fedorov
On 17/05/16 22:19, Richard Henderson wrote: > On 05/17/2016 10:13 AM, Sergey Fedorov wrote: >>>> +static inline void qemu_spin_lock(QemuSpin *spin) >>>> +{ >>>> +while (atomic_test_and_set_acquire(&spin->value)) { >> >From gcc-

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-17 Thread Sergey Fedorov
On 17/05/16 22:57, Sergey Fedorov wrote: > On 17/05/16 22:19, Richard Henderson wrote: >> On 05/17/2016 10:13 AM, Sergey Fedorov wrote: >>>>> +static inline void qemu_spin_lock(QemuSpin *spin) >>>>> +{ >>>>> +while (atomic_test_and_set_acqu

Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock

2016-05-17 Thread Sergey Fedorov
On 17/05/16 22:38, Emilio G. Cota wrote: > On Tue, May 17, 2016 at 20:13:24 +0300, Sergey Fedorov wrote: >> On 14/05/16 06:34, Emilio G. Cota wrote: (snip) >>> +while (atomic_read(&spin->value)) { >>> +cpu_relax(); >>> +} >

Re: [Qemu-devel] [PATCH v5 09/18] tb hash: hash phys_pc, pc, and flags with xxhash

2016-05-17 Thread Sergey Fedorov
On 14/05/16 06:34, Emilio G. Cota wrote: > For some workloads such as arm bootup, tb_phys_hash is performance-critical. > The is due to the high frequency of accesses to the hash table, originated > by (frequent) TLB flushes that wipe out the cpu-private tb_jmp_cache's. > More info: > https://lis

Re: [Qemu-devel] [PATCH v5 08/18] exec: add tb_hash_func5, derived from xxhash

2016-05-17 Thread Sergey Fedorov
On 14/05/16 06:34, Emilio G. Cota wrote: > This will be used by upcoming changes for hashing the tb hash. > > Add this into a separate file to include the copyright notice from > xxhash. > > Reviewed-by: Richard Henderson > Signed-off-by: Emilio G. Cota > --- > include/exec/tb-hash-xx.h | 94 >

Re: [Qemu-devel] [PATCH v5 06/18] atomics: add atomic_read_acquire and atomic_set_release

2016-05-17 Thread Sergey Fedorov
On 14/05/16 06:34, Emilio G. Cota wrote: > When __atomic is not available, we use full memory barriers instead > of smp/wmb, since acquire/release barriers apply to all memory > operations and not just to loads/stores, respectively. > > Signed-off-by: Emilio G. Cota > --- > include/qemu/atomic.h

Re: [Qemu-devel] [PATCH v5 05/18] atomics: add atomic_test_and_set_acquire

2016-05-17 Thread Sergey Fedorov
On 17/05/16 19:23, Paolo Bonzini wrote: > > On 17/05/2016 18:15, Sergey Fedorov wrote: >> On 14/05/16 06:34, Emilio G. Cota wrote: >>> This new helper expands to __atomic_test_and_set with acquire semantics >>> where available; otherwise it expands to __sync_test_

Re: [Qemu-devel] [PATCH v5 05/18] atomics: add atomic_test_and_set_acquire

2016-05-17 Thread Sergey Fedorov
On 14/05/16 06:34, Emilio G. Cota wrote: > This new helper expands to __atomic_test_and_set with acquire semantics > where available; otherwise it expands to __sync_test_and_set, which > has acquire semantics. Why don't also add atomic_clear_release() for completeness? Kind regards, Sergey > > S

Re: [Qemu-devel] [PATCH 2/5] user-exec: Push resume-from-signal code out to handle_cpu_signal()

2016-05-16 Thread Sergey Fedorov
> Signed-off-by: Peter Maydell Reviewed-by: Sergey Fedorov > --- > cpu-exec-common.c | 2 +- > translate-all.c | 12 > translate-all.h | 2 +- > user-exec.c | 41 + > 4 files changed, 39 insertions(+), 18 de

Re: [Qemu-devel] [PATCH 5/5] target-i386: Move user-mode exception actions out of user-exec.c

2016-05-16 Thread Sergey Fedorov
On 16/05/16 19:09, Peter Maydell wrote: > The exception_action() function in user-exec.c is just a call to > cpu_loop_exit() for every target CPU except i386. Since this > function is only called if the target's handle_mmu_fault() hook has > indicated an MMU fault, and that hook is only called fro

Re: [Qemu-devel] [PATCH 4/5] user-exec: Don't reextract sigmask from usercontext pointer

2016-05-16 Thread Sergey Fedorov
need to do it again in cpu_exit_tb_from_sighandler(). > This then means we don't need to pass a usercontext pointer in to > handle_cpu_signal() at all. > > Signed-off-by: Peter Maydell Reviewed-by: Sergey Fedorov > --- > user-exec.c | 48 ---

Re: [Qemu-devel] [PATCH 3/5] cpu-exec: Rename cpu_resume_from_signal() to cpu_loop_exit_noexc()

2016-05-16 Thread Sergey Fedorov
ny exception, so rename > it to cpu_loop_exit_noexc() and drop the useless unused argument. > > Signed-off-by: Peter Maydell Reviewed-by: Sergey Fedorov > --- > cpu-exec-common.c| 6 ++ > exec.c | 2 +- > hw/i386/kvmvapic.c | 2 +

Re: [Qemu-devel] [PATCH 1/5] translate-all.c: Don't pass puc, locked to tb_invalidate_phys_page()

2016-05-16 Thread Sergey Fedorov
On 16/05/16 20:15, Peter Maydell wrote: > On 16 May 2016 at 18:13, Sergey Fedorov wrote: >> On 16/05/16 19:09, Peter Maydell wrote: >>> @@ -1996,7 +1997,10 @@ int page_unprotect(target_ulong address, uintptr_t >>> pc, void *puc) >>> >>>

<    1   2   3   4   5   6   7   8   9   >