[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 03/16] tcg: track TBs with per-region BST's
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH 03/16] tcg: track TBs with per-region BST's |
Date: |
Wed, 28 Feb 2018 12:53:39 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 02/26/2018 09:39 PM, Emilio G. Cota wrote:
> This paves the way for enabling scalable parallel generation of TCG code.
>
> Instead of tracking TBs with a single binary search tree (BST), use a
> BST for each TCG region, protecting it with a lock. This is as scalable
> as it gets, since each TCG thread operates on a separate region.
>
> The core of this change is the introduction of struct tcg_region_tree,
> which contains a pointer to a GTree and an associated lock to serialize
> accesses to it. We then allocate an array of tcg_region_tree's, adding
> the appropriate padding to avoid false sharing based on
> qemu_dcache_linesize.
>
> Given a tc_ptr, we first find the corresponding region_tree. This
> is done by special-casing the first and last regions first, since they
> might be of size != region.size; otherwise we just divide the offset
> by region.stride. I was worried about this division (several dozen
> cycles of latency), but profiling shows that this is not a fast path.
> Note that region.stride is not required to be a power of two; it
> is only required to be a multiple of the host's page size.
>
> Note that with this design we can also provide consistent snapshots
> about all region trees at once; for instance, tcg_tb_foreach
> acquires/releases all region_tree locks before/after iterating over them.
> For this reason we now drop tb_lock in dump_exec_info().
>
> As an alternative I considered implementing a concurrent BST, but this
> can be tricky to get right, offers no consistent snapshots of the BST,
> and performance and scalability-wise I don't think it could ever beat
> having separate GTrees, given that our workload is insert-mostly (all
> concurrent BST designs I've seen focus, understandably, on making
> lookups fast, which comes at the expense of convoluted, non-wait-free
> insertions/removals).
>
> Signed-off-by: Emilio G. Cota <address@hidden>
> ---
> accel/tcg/cpu-exec.c | 2 +-
> accel/tcg/translate-all.c | 101 ++++--------------------
> include/exec/exec-all.h | 1 -
> include/exec/tb-context.h | 1 -
> tcg/tcg.c | 191
> ++++++++++++++++++++++++++++++++++++++++++++++
> tcg/tcg.h | 6 ++
> 6 files changed, 213 insertions(+), 89 deletions(-)
Reviewed-by: Richard Henderson <address@hidden>
r~
- [Qemu-devel] [PATCH 06/16] translate-all: make l1_map lockless, (continued)
- [Qemu-devel] [PATCH 06/16] translate-all: make l1_map lockless, Emilio G. Cota, 2018/02/27
- [Qemu-devel] [PATCH 09/16] translate-all: move tb_invalidate_phys_page_range up in the file, Emilio G. Cota, 2018/02/27
- [Qemu-devel] [PATCH 12/16] translate-all: discard TB when tb_link_page returns an existing matching TB, Emilio G. Cota, 2018/02/27
- [Qemu-devel] [PATCH 01/16] qht: require a default comparison function, Emilio G. Cota, 2018/02/27
- [Qemu-devel] [PATCH 11/16] translate-all: add page_collection assertions, Emilio G. Cota, 2018/02/27
- [Qemu-devel] [PATCH 15/16] translate-all: remove tb_lock mention from cpu_restore_state_from_tb, Emilio G. Cota, 2018/02/27
- [Qemu-devel] [PATCH 14/16] cputlb: remove tb_lock from tlb_flush functions, Emilio G. Cota, 2018/02/27
- [Qemu-devel] [PATCH 05/16] translate-all: iterate over TBs in a page with PAGE_FOR_EACH_TB, Emilio G. Cota, 2018/02/27
- [Qemu-devel] [PATCH 03/16] tcg: track TBs with per-region BST's, Emilio G. Cota, 2018/02/27
- Re: [Qemu-devel] [PATCH 03/16] tcg: track TBs with per-region BST's,
Richard Henderson <=
- [Qemu-devel] [PATCH 10/16] translate-all: use per-page locking in !user-mode, Emilio G. Cota, 2018/02/27
- [Qemu-devel] [PATCH 16/16] tcg: remove tb_lock, Emilio G. Cota, 2018/02/27