From: Sergey Fedorov <serge.f...@gmail.com> Hi,
This RFC series is a follow-up for a discussion on the subject [1]. Basically, this series is intended to show a possible way to perform operations on quiescent state, so that we can discuss if it a sane way to do this. The goal is to implement such a mechanism which can be used for safe translation buffer flush in multi-threaded user-mode emulation (and later in MTTCG) and merge it into mainline in v2.7. I tried to keep this series as small as possible so that would be easier to focus on the main idea. Thus bsd-user part was simply skipped here. Please note that this is just a kind of "proof of concept" series and needs to be polished and refined. The patch 1 is just a useful tweak from Alex's MTTCG tree, please don't comment on it here if possible. The patches 2 through 5 are arrangements for the patch 7 which adds support for CPU work in linux-user. This wouldn't make any sense without the patch 8 which is the subject matter of this series. Although there is nothing special to do in case of single-threaded round-robin CPU loop of current system-mode emulation to ensure quiescent state, that is shown in the patch 7, how it would look like in MTTCG. The last patch actually employs this new mechanism making translation buffer flush thread safe. Again for brevity, the considerations on expensiveness of work item dynamic allocation [2] was not taken into account. I'll just mention here that the desired effect can be achieved by either using dynamic arrays for CPU work queues or making queue_work_on_cpu() from the patch 2 a public interface thus allowing to use preallocated work items. I would like your comments in order to produce something upstreamable quickly! This series is available at a public git repository: https://github.com/sergefdrv/qemu.git safe-cpu-work Kind regards, Sergey [1] http://thread.gmane.org/gmane.comp.emulators.qemu/417599 [2] http://thread.gmane.org/gmane.comp.emulators.qemu/407030/focus=407039 Alex Bennée (1): cpus: pass CPUState to run_on_cpu helpers Sergey Fedorov (7): cpus: Move common code out of {async_,}run_on_cpu() cpus: Add 'qemu_work_cond' usage wrappers linux-user: Rework exclusive operation mechanism linux-user: Add qemu_cpu_is_self() and qemu_cpu_kick() linux-user: Support CPU work queue cpu-exec-common: Introduce async_safe_run_on_cpu() tcg: Make tb_flush() thread safe cpu-exec-common.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++ cpus.c | 98 +++++++------------------------------ hw/i386/kvm/apic.c | 3 +- hw/i386/kvmvapic.c | 8 +-- hw/ppc/ppce500_spin.c | 3 +- hw/ppc/spapr.c | 6 +-- hw/ppc/spapr_hcall.c | 12 ++--- include/exec/exec-all.h | 6 +++ include/qom/cpu.h | 22 +++++++-- kvm-all.c | 20 +++----- linux-user/main.c | 47 +++++++++++++----- target-i386/helper.c | 3 +- target-i386/kvm.c | 6 +-- target-s390x/cpu.c | 4 +- target-s390x/cpu.h | 7 +-- translate-all.c | 12 +++-- 16 files changed, 238 insertions(+), 145 deletions(-) -- 1.9.1