[PATCH v3 00/11] accel/tcg: Push BQL down into per-target do_interrupt handlers

Philippe Mathieu-Daudé posted 11 patches 3 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260902152044.31291-1-philmd@oss.qualcomm.com
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Michael Rolnik <mrolnik@gmail.com>, Brian Cain <brian.cain@oss.qualcomm.com>, Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>, Helge Deller <deller@gmx.de>, Song Gao <17746591750@163.com>, Bibo Mao <maobibo@loongson.cn>, Xianglai Li <lixianglai@loongson.cn>, Laurent Vivier <laurent@vivier.eu>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <arikalo@gmail.com>, Stafford Horne <shorne@gmail.com>, Chinmay Rath <rathc@linux.ibm.com>, Nicholas Piggin <npiggin@gmail.com>, Glenn Miles <milesg@linux.ibm.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu@processmission.com>, Yoshinori Sato <yoshinori.sato@nifty.com>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Cornelia Huck <cohuck@redhat.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, Max Filippov <jcmvbkbc@gmail.com>
include/accel/tcg/cpu-ops.h         | 32 +++++++++++++++++++++++++----
target/arm/internals.h              |  2 +-
target/i386/tcg/helper-tcg.h        |  4 +++-
target/s390x/s390x-internal.h       |  5 ++---
accel/tcg/cpu-exec.c                |  7 +++----
target/alpha/helper.c               |  3 +++
target/arm/cpu-irq.c                |  2 +-
target/arm/helper.c                 |  1 +
target/arm/tcg/cpu-v7m.c            |  2 +-
target/arm/tcg/m_helper.c           |  2 ++
target/avr/helper.c                 |  3 +++
target/hppa/int_helper.c            |  2 ++
target/i386/tcg/system/seg_helper.c |  2 ++
target/i386/tcg/tcg-cpu.c           |  2 +-
target/i386/tcg/user/seg_helper.c   |  6 +++---
target/mips/tcg/system/tlb_helper.c |  3 +++
target/ppc/excp_helper.c            |  2 ++
target/rx/helper.c                  |  3 +++
target/s390x/tcg/excp_helper.c      |  8 +++-----
target/sh4/helper.c                 |  3 +++
target/sparc/int32_helper.c         |  2 ++
target/sparc/int64_helper.c         |  2 ++
target/xtensa/exc_helper.c          |  2 ++
23 files changed, 76 insertions(+), 24 deletions(-)
[PATCH v3 00/11] accel/tcg: Push BQL down into per-target do_interrupt handlers
Posted by Philippe Mathieu-Daudé 3 weeks, 3 days ago
This is a respin of Robert Foley's v2 series from August 2020 [1]
triggered by a broader review of BQL contract in my halt-to-exec
transitions series by Peter [2] and Mark [3].

v3:
- kind of rebase
- rename misleading fake_user_interrupt callback names for clarity
- restrict interrupt handlers to their appropriate modes (system vs user)
- explicitly document that do_interrupt() and cpu_exec_interrupt()
  callbacks are called WITH BQL held (explicit BQL contract in docstrings)

v2 Summary
----------

This series pushes the Big QEMU Lock (BQL) down from the core TCG
cpu_handle_interrupt/cpu_handle_exception paths into per-target
implementations. This allows each architecture to manage BQL locking
granularity independently, reducing contention on a known bottleneck
as measured by QEMU sync profiling (qsp).

The BQL has long been a scaling bottleneck in QEMU, and the
interrupt/exception handling path is one of its heaviest users. By
allowing targets to acquire the BQL only when needed, we enable
future per-target optimizations.

Refs:
[1] https://lore.kernel.org/qemu-devel/20200819182856.4893-1-robert.foley@linaro.org/
[2] https://lore.kernel.org/qemu-devel/CAFEAcA8xk8y1W0UvttpVhKYuoMBSQqZoF_15of0Rrq4wKkWDuw@mail.gmail.com/
[3] https://lore.kernel.org/qemu-devel/69d07179-388e-4285-902b-36788b2b3da1@nutanix.com/

Philippe Mathieu-Daudé (10):
  target/arm: Call arm*_cpu_do_interrupt directly instead of via
    TCGCPUOps
  target/s390x: Restrict interrupt handlers to system mode
  target/i386: Rename fake_do_interrupt to fake_user_exception
  accel/tcg: Document cpu_exec_interrupt() callback contract
  accel/tcg: Document do_interrupt() callback contract
  accel/tcg: Add do_interrupt() wrapper for targets to manage BQL
  target/hexagon: Move to do_interrupt() (BQL acquired internally)
  targets: Move interrupt handlers to do_interrupt()
  targets: Move BQL locking into do_interrupt() handlers
  accel/tcg: Remove do_interrupt_locked() callback

Robert Foley (1):
  accel/tcg: Rename do_interrupt() to do_interrupt_locked()

 include/accel/tcg/cpu-ops.h         | 32 +++++++++++++++++++++++++----
 target/arm/internals.h              |  2 +-
 target/i386/tcg/helper-tcg.h        |  4 +++-
 target/s390x/s390x-internal.h       |  5 ++---
 accel/tcg/cpu-exec.c                |  7 +++----
 target/alpha/helper.c               |  3 +++
 target/arm/cpu-irq.c                |  2 +-
 target/arm/helper.c                 |  1 +
 target/arm/tcg/cpu-v7m.c            |  2 +-
 target/arm/tcg/m_helper.c           |  2 ++
 target/avr/helper.c                 |  3 +++
 target/hppa/int_helper.c            |  2 ++
 target/i386/tcg/system/seg_helper.c |  2 ++
 target/i386/tcg/tcg-cpu.c           |  2 +-
 target/i386/tcg/user/seg_helper.c   |  6 +++---
 target/mips/tcg/system/tlb_helper.c |  3 +++
 target/ppc/excp_helper.c            |  2 ++
 target/rx/helper.c                  |  3 +++
 target/s390x/tcg/excp_helper.c      |  8 +++-----
 target/sh4/helper.c                 |  3 +++
 target/sparc/int32_helper.c         |  2 ++
 target/sparc/int64_helper.c         |  2 ++
 target/xtensa/exc_helper.c          |  2 ++
 23 files changed, 76 insertions(+), 24 deletions(-)

-- 
2.53.0


Re: [PATCH v3 00/11] accel/tcg: Push BQL down into per-target do_interrupt handlers
Posted by Philippe Mathieu-Daudé 3 weeks, 3 days ago
On 2/9/26 17:20, Philippe Mathieu-Daudé wrote:
> This is a respin of Robert Foley's v2 series from August 2020 [1]
> triggered by a broader review of BQL contract in my halt-to-exec
> transitions series by Peter [2] and Mark [3].


> v2 Summary
> ----------
> 
> This series pushes the Big QEMU Lock (BQL) down from the core TCG
> cpu_handle_interrupt/cpu_handle_exception paths into per-target
> implementations. This allows each architecture to manage BQL locking
> granularity independently, reducing contention on a known bottleneck
> as measured by QEMU sync profiling (qsp).

(I couldn't find what/where 'QEMU sync profiling' is).

> 
> The BQL has long been a scaling bottleneck in QEMU, and the
> interrupt/exception handling path is one of its heaviest users. By
> allowing targets to acquire the BQL only when needed, we enable
> future per-target optimizations.