[RFC 0/3] QEMU cpus.c refactoring

Claudio Fontana posted 3 patches 1 week ago
Test docker-mingw@fedora passed
Test checkpatch passed
Test asan passed
Test docker-quick@centos7 passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200521185407.25311-1-cfontana@suse.de
Maintainers: Eduardo Habkost <ehabkost@redhat.com>, Thomas Huth <thuth@redhat.com>, Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>, Peter Maydell <peter.maydell@linaro.org>, Alistair Francis <Alistair.Francis@wdc.com>, Palmer Dabbelt <palmer@dabbelt.com>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Roman Bolshakov <r.bolshakov@yadro.com>, Sunil Muthuswamy <sunilmut@microsoft.com>, "Michael S. Tsirkin" <mst@redhat.com>, Colin Xu <colin.xu@intel.com>, Wenchao Wang <wenchao.wang@intel.com>, Juan Quintela <quintela@redhat.com>, Sagar Karandikar <sagark@eecs.berkeley.edu>, Richard Henderson <rth@twiddle.net>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
MAINTAINERS                          |    3 +
Makefile.target                      |    9 +-
accel/kvm/Makefile.objs              |    2 +
accel/kvm/kvm-all.c                  |   15 +-
accel/kvm/kvm-cpus-interface.c       |   94 ++
accel/kvm/kvm-cpus-interface.h       |    8 +
accel/qtest.c                        |   85 +-
accel/stubs/kvm-stub.c               |    3 +-
accel/tcg/Makefile.objs              |    1 +
accel/tcg/cpu-exec.c                 |   43 +-
accel/tcg/tcg-all.c                  |   19 +-
accel/tcg/tcg-cpus-interface.c       |  523 +++++++++
accel/tcg/tcg-cpus-interface.h       |    8 +
accel/tcg/translate-all.c            |    3 +-
cpu-throttle.c                       |  122 ++
cpu-timers.c                         |  776 +++++++++++++
cpus.c                               | 2015 ++++------------------------------
docs/replay.txt                      |    6 +-
exec.c                               |    4 -
hw/core/cpu.c                        |    1 +
hw/core/ptimer.c                     |    6 +-
hw/i386/x86.c                        |    1 +
include/exec/cpu-all.h               |    4 +
include/exec/exec-all.h              |    4 +-
include/hw/core/cpu.h                |   37 -
include/qemu/main-loop.h             |    5 +
include/qemu/timer.h                 |   20 -
include/sysemu/cpu-throttle.h        |   50 +
include/sysemu/cpu-timers.h          |   73 ++
include/sysemu/cpus.h                |   56 +-
include/sysemu/hw_accel.h            |   57 +-
include/sysemu/kvm.h                 |    2 +-
include/sysemu/replay.h              |    4 +-
migration/migration.c                |    1 +
migration/ram.c                      |    1 +
qtest.c                              |    2 +-
replay/replay.c                      |    6 +-
softmmu/vl.c                         |    8 +-
stubs/Makefile.objs                  |    1 +
stubs/clock-warp.c                   |    4 +-
stubs/cpu-get-clock.c                |    2 +-
stubs/cpu-get-icount.c               |   14 +-
stubs/cpu-synchronize-state.c        |   15 +
target/alpha/translate.c             |    3 +-
target/arm/helper.c                  |    7 +-
target/i386/Makefile.objs            |    7 +-
target/i386/hax-all.c                |    6 +-
target/i386/hax-cpus-interface.c     |   85 ++
target/i386/hax-cpus-interface.h     |    8 +
target/i386/hax-i386.h               |    2 +
target/i386/hax-posix.c              |   12 +
target/i386/hax-windows.c            |   20 +
target/i386/hvf/Makefile.objs        |    2 +-
target/i386/hvf/hvf-cpus-interface.c |   83 ++
target/i386/hvf/hvf-cpus-interface.h |    8 +
target/i386/hvf/hvf.c                |    5 +-
target/i386/kvm.c                    |    4 +-
target/i386/whpx-all.c               |    3 +
target/i386/whpx-cpus-interface.c    |   96 ++
target/i386/whpx-cpus-interface.h    |    8 +
target/riscv/csr.c                   |    8 +-
tests/ptimer-test-stubs.c            |    6 +
tests/test-timed-average.c           |    2 +-
util/main-loop.c                     |    4 +-
util/qemu-timer.c                    |    9 +-
65 files changed, 2524 insertions(+), 1977 deletions(-)
create mode 100644 accel/kvm/kvm-cpus-interface.c
create mode 100644 accel/kvm/kvm-cpus-interface.h
create mode 100644 accel/tcg/tcg-cpus-interface.c
create mode 100644 accel/tcg/tcg-cpus-interface.h
create mode 100644 cpu-throttle.c
create mode 100644 cpu-timers.c
create mode 100644 include/sysemu/cpu-throttle.h
create mode 100644 include/sysemu/cpu-timers.h
create mode 100644 stubs/cpu-synchronize-state.c
create mode 100644 target/i386/hax-cpus-interface.c
create mode 100644 target/i386/hax-cpus-interface.h
create mode 100644 target/i386/hvf/hvf-cpus-interface.c
create mode 100644 target/i386/hvf/hvf-cpus-interface.h
create mode 100644 target/i386/whpx-cpus-interface.c
create mode 100644 target/i386/whpx-cpus-interface.h

[RFC 0/3] QEMU cpus.c refactoring

Posted by Claudio Fontana 1 week ago
Motivation and higher level steps:

https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg04628.html

This is point 8) in that plan. The idea is to extract the unrelated parts
in cpus, and register interfaces from each single accelerator to the main
cpus module (cpus.c).

While doing this RFC, I noticed some assumptions about Windows being
either TCG or HAX (not considering WHPX) that might need to be revisited.
I added a comment there.

The thing builds successfully based on Linux cross-compilations for
windows/hax, windows/whpx, and I got a good build on Darwin/hvf.

Tests run successully for tcg and kvm configurations, but did not test on
windows or darwin.

Welcome your feedback and help on this,

Claudio

Claudio Fontana (3):
  cpu-throttle: new module, extracted from cpus.c
  cpu-timers: new module extracted from cpus.c
  cpus: implement cpus interfaces for per-accelerator threads

 MAINTAINERS                          |    3 +
 Makefile.target                      |    9 +-
 accel/kvm/Makefile.objs              |    2 +
 accel/kvm/kvm-all.c                  |   15 +-
 accel/kvm/kvm-cpus-interface.c       |   94 ++
 accel/kvm/kvm-cpus-interface.h       |    8 +
 accel/qtest.c                        |   85 +-
 accel/stubs/kvm-stub.c               |    3 +-
 accel/tcg/Makefile.objs              |    1 +
 accel/tcg/cpu-exec.c                 |   43 +-
 accel/tcg/tcg-all.c                  |   19 +-
 accel/tcg/tcg-cpus-interface.c       |  523 +++++++++
 accel/tcg/tcg-cpus-interface.h       |    8 +
 accel/tcg/translate-all.c            |    3 +-
 cpu-throttle.c                       |  122 ++
 cpu-timers.c                         |  776 +++++++++++++
 cpus.c                               | 2015 ++++------------------------------
 docs/replay.txt                      |    6 +-
 exec.c                               |    4 -
 hw/core/cpu.c                        |    1 +
 hw/core/ptimer.c                     |    6 +-
 hw/i386/x86.c                        |    1 +
 include/exec/cpu-all.h               |    4 +
 include/exec/exec-all.h              |    4 +-
 include/hw/core/cpu.h                |   37 -
 include/qemu/main-loop.h             |    5 +
 include/qemu/timer.h                 |   20 -
 include/sysemu/cpu-throttle.h        |   50 +
 include/sysemu/cpu-timers.h          |   73 ++
 include/sysemu/cpus.h                |   56 +-
 include/sysemu/hw_accel.h            |   57 +-
 include/sysemu/kvm.h                 |    2 +-
 include/sysemu/replay.h              |    4 +-
 migration/migration.c                |    1 +
 migration/ram.c                      |    1 +
 qtest.c                              |    2 +-
 replay/replay.c                      |    6 +-
 softmmu/vl.c                         |    8 +-
 stubs/Makefile.objs                  |    1 +
 stubs/clock-warp.c                   |    4 +-
 stubs/cpu-get-clock.c                |    2 +-
 stubs/cpu-get-icount.c               |   14 +-
 stubs/cpu-synchronize-state.c        |   15 +
 target/alpha/translate.c             |    3 +-
 target/arm/helper.c                  |    7 +-
 target/i386/Makefile.objs            |    7 +-
 target/i386/hax-all.c                |    6 +-
 target/i386/hax-cpus-interface.c     |   85 ++
 target/i386/hax-cpus-interface.h     |    8 +
 target/i386/hax-i386.h               |    2 +
 target/i386/hax-posix.c              |   12 +
 target/i386/hax-windows.c            |   20 +
 target/i386/hvf/Makefile.objs        |    2 +-
 target/i386/hvf/hvf-cpus-interface.c |   83 ++
 target/i386/hvf/hvf-cpus-interface.h |    8 +
 target/i386/hvf/hvf.c                |    5 +-
 target/i386/kvm.c                    |    4 +-
 target/i386/whpx-all.c               |    3 +
 target/i386/whpx-cpus-interface.c    |   96 ++
 target/i386/whpx-cpus-interface.h    |    8 +
 target/riscv/csr.c                   |    8 +-
 tests/ptimer-test-stubs.c            |    6 +
 tests/test-timed-average.c           |    2 +-
 util/main-loop.c                     |    4 +-
 util/qemu-timer.c                    |    9 +-
 65 files changed, 2524 insertions(+), 1977 deletions(-)
 create mode 100644 accel/kvm/kvm-cpus-interface.c
 create mode 100644 accel/kvm/kvm-cpus-interface.h
 create mode 100644 accel/tcg/tcg-cpus-interface.c
 create mode 100644 accel/tcg/tcg-cpus-interface.h
 create mode 100644 cpu-throttle.c
 create mode 100644 cpu-timers.c
 create mode 100644 include/sysemu/cpu-throttle.h
 create mode 100644 include/sysemu/cpu-timers.h
 create mode 100644 stubs/cpu-synchronize-state.c
 create mode 100644 target/i386/hax-cpus-interface.c
 create mode 100644 target/i386/hax-cpus-interface.h
 create mode 100644 target/i386/hvf/hvf-cpus-interface.c
 create mode 100644 target/i386/hvf/hvf-cpus-interface.h
 create mode 100644 target/i386/whpx-cpus-interface.c
 create mode 100644 target/i386/whpx-cpus-interface.h

-- 
2.16.4