[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC 33/38] cpu: introduce cpu_tcg_sched_work to run wo
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [RFC 33/38] cpu: introduce cpu_tcg_sched_work to run work while other CPUs sleep |
Date: |
Sun, 23 Aug 2015 18:24:55 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 23/08/2015 17:24, Emilio G. Cota wrote:
> This is similar in intent to the async_safe_work mechanism. The main
> differences are:
>
> - Work is run on a single CPU thread *after* all others are put to sleep
>
> - Sleeping threads are woken up by the worker thread upon completing its job
>
> - A flag as been added to tcg_ctx so that only one thread can schedule
> work at a time. The flag is checked every time tb_lock is acquired.
>
> - Handles the possibility of CPU threads being created after the existing
> CPUs are put to sleep. This is easily triggered with many threads on
> a many-core host in usermode.
>
> - Works for both softmmu and usermode
>
> Signed-off-by: Emilio G. Cota <address@hidden>
I think this is a duplicate of the existing run_on_cpu code. If needed
in user-mode emulation, it should be extracted out of cpus.c.
Also I think it is dangerous (prone to deadlocks) to wait for other CPUs
with synchronize_cpu and condvar. I would much rather prefer to _halt_
the CPUs if there is pending work, and keep it halted like this:
static inline bool cpu_has_work(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
+ if (tcg_ctx.tb_ctx.tcg_has_work) {
+ return false;
+ }
g_assert(cc->has_work);
return cc->has_work(cpu);
}
You can then run flush_queued_work from linux-user/main.c (and
bsd-user/main.c) when cpu_exec returns EXCP_HALTED.
Paolo
- [Qemu-devel] [RFC 19/38] tcg: add tcg_gen_smp_rmb(), (continued)
- [Qemu-devel] [RFC 31/38] cpu: protect l1_map with tb_lock in full-system mode, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 27/38] cpu-exec: convert tb_invalidated_flag into a per-TB flag, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 33/38] cpu: introduce cpu_tcg_sched_work to run work while other CPUs sleep, Emilio G. Cota, 2015/08/23
- Re: [Qemu-devel] [RFC 33/38] cpu: introduce cpu_tcg_sched_work to run work while other CPUs sleep,
Paolo Bonzini <=
- [Qemu-devel] [RFC 21/38] target-i386: emulate atomic instructions + barriers using AIE, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 38/38] Revert "target-i386: yield to another VCPU on PAUSE", Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 37/38] cpus: remove async_run_safe_work_on_cpu, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 32/38] cpu list: convert to RCU QLIST, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 28/38] cpu-exec: use RCU to perform lockless TB lookups, Emilio G. Cota, 2015/08/23
- Re: [Qemu-devel] [RFC 00/38] MTTCG: i386, user+system mode, Paolo Bonzini, 2015/08/24
- Re: [Qemu-devel] [RFC 00/38] MTTCG: i386, user+system mode, Artyom Tarasenko, 2015/08/24