qemu/qapi
Zhao Liu 4e88e7e340 qapi/qom: Define cache enumeration and properties for machine
The x86 and ARM need to allow user to configure cache properties
(current only topology):
 * For x86, the default cache topology model (of max/host CPU) does not
   always match the Host's real physical cache topology. Performance can
   increase when the configured virtual topology is closer to the
   physical topology than a default topology would be.
 * For ARM, QEMU can't get the cache topology information from the CPU
   registers, then user configuration is necessary. Additionally, the
   cache information is also needed for MPAM emulation (for TCG) to
   build the right PPTT.

Define smp-cache related enumeration and properties in QAPI, so that
user could configure cache properties for SMP system through -machine in
the subsequent patch.

Cache enumeration (CacheLevelAndType) is implemented as the combination
of cache level (level 1/2/3) and cache type (data/instruction/unified).

Currently, separated L1 cache (L1 data cache and L1 instruction cache)
with unified higher-level cache (e.g., unified L2 and L3 caches), is the
most common cache architectures.

Therefore, enumerate the L1 D-cache, L1 I-cache, L2 cache and L3 cache
with smp-cache object to add the basic cache topology support. Other
kinds of caches (e.g., L1 unified or L2/L3 separated caches) can be
added directly into CacheLevelAndType if necessary.

Cache properties (SmpCacheProperties) currently only contains cache
topology information, and other cache properties can be added in it
if necessary.

Note, define cache topology based on CPU topology level with two
reasons:

 1. In practice, a cache will always be bound to the CPU container
    (either private in the CPU container or shared among multiple
    containers), and CPU container is often expressed in terms of CPU
    topology level.
 2. The x86's cache-related CPUIDs encode cache topology based on APIC
    ID's CPU topology layout. And the ACPI PPTT table that ARM/RISCV
    relies on also requires CPU containers to help indicate the private
    shared hierarchy of the cache. Therefore, for SMP systems, it is
    natural to use the CPU topology hierarchy directly in QEMU to define
    the cache topology.

With smp-cache QAPI support, add smp cache topology for machine by
parsing the smp-cache object list.

Also add the helper to access/update cache topology level of machine.

Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Tested-by: Yongwei Ma <yongwei.ma@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-ID: <20241101083331.340178-4-zhao1.liu@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2024-11-05 23:32:25 +00:00
..
acpi.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00
audio.json audio/pw: Pipewire->PipeWire case fix for user-visible text 2023-07-17 15:22:56 +04:00
authz.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
block-core.json block-backend: per-device throttling of BLOCK_IO_ERROR reports 2024-10-22 17:52:49 +02:00
block-export.json nbd/server: CVE-2024-7409: Cap default max-connections to 100 2024-08-08 16:02:23 -05:00
block.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
char.json chardev: add path option for pty backend 2024-10-09 12:13:05 +04:00
common.json qapi/common: Supply missing member documentation 2024-10-02 09:10:01 +02:00
compat.json qapi: Belatedly update CompatPolicy documentation for unstable 2023-10-19 07:02:29 +02:00
control.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
crypto.json qapi/crypto: Supply missing member documentation 2024-10-02 09:10:01 +02:00
cryptodev.json qapi: Document QCryptodevBackendServiceType 2024-10-02 09:10:01 +02:00
cxl.json qapi/cxl: Supply missing member documentation 2024-10-02 09:10:01 +02:00
dump.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
ebpf.json qapi/ebpf: Drop temporary 'prefix' 2024-09-10 13:22:47 +02:00
error.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
introspect.json qapi/introspect: Supply missing member documentation 2024-10-02 09:10:01 +02:00
job.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
machine-common.json qapi/qom: Define cache enumeration and properties for machine 2024-11-05 23:32:25 +00:00
machine-target.json qapi/machine: Rename CpuS390* to S390Cpu*, and drop 'prefix' 2024-09-10 13:22:47 +02:00
machine.json Revert "Remove the unused sh4eb target" 2024-11-04 14:16:11 +01:00
meson.build qapi/vfio: Add VFIO migration QAPI event 2024-05-16 16:59:19 +02:00
migration.json migration: Deprecate query-migrationthreads command 2024-10-31 15:48:18 -04:00
misc-target.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00
misc.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
net.json net/stream: deprecate 'reconnect' in favor of 'reconnect-ms' 2024-10-28 14:37:25 +08:00
opts-visitor.c qapi: Inline and remove QERR_INVALID_PARAMETER definition 2024-04-24 09:50:58 +02:00
pci.json qapi/pci: Supply missing member documentation 2024-10-02 09:10:01 +02:00
pragma.json qapi: Document QCryptodevBackendServiceType 2024-10-02 09:10:01 +02:00
qapi-clone-visitor.c qapi: Do not cast function pointers 2024-05-29 12:41:56 +02:00
qapi-dealloc-visitor.c qapi: Make visitor functions taking Error ** return bool, not void 2020-07-10 15:18:08 +02:00
qapi-forward-visitor.c qapi: remove needless include 2022-03-22 14:46:18 +04:00
qapi-schema.json qapi/vfio: Add VFIO migration QAPI event 2024-05-16 16:59:19 +02:00
qapi-type-helpers.c qapi: New strv_from_str_list() 2024-03-04 07:12:40 +01:00
qapi-util.c qapi: Fix dangling references to docs/devel/qapi-code-gen.txt 2024-01-26 07:04:53 +01:00
qapi-visit-core.c qapi: Factor out compat_policy_input_ok() 2021-10-29 21:27:20 +02:00
qdev.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
qmp-dispatch.c Revert "monitor: use aio_co_reschedule_self()" 2024-06-10 11:05:43 +02:00
qmp-event.c Replace qemu_gettimeofday() with g_get_real_time() 2022-04-06 10:50:37 +02:00
qmp-registry.c qapi: Generalize command policy checking 2021-10-29 18:24:46 +02:00
qobject-input-visitor.c qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant value) 2024-04-24 09:50:58 +02:00
qobject-output-visitor.c qapi: Extend -compat to set policy for unstable interfaces 2021-10-29 21:28:01 +02:00
qom.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
replay.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00
rocker.json qapi/rocker: Supply missing member documentation 2024-10-02 09:10:01 +02:00
run-state.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
sockets.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
stats.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
string-input-visitor.c qapi: Inline QERR_INVALID_PARAMETER_TYPE definition (constant value) 2024-04-24 09:50:58 +02:00
string-output-visitor.c string-output-visitor: Fix (pseudo) struct handling 2024-01-26 11:16:58 +01:00
tpm.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00
trace-events qapi: Generalize struct member policy checking 2021-10-29 18:23:09 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
trace.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00
transaction.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
ui.json qapi/ui: Drop temporary 'prefix' 2024-09-10 13:22:47 +02:00
vfio.json qapi/vfio: Rename VfioMigrationState to Qapi*, and drop prefix 2024-09-10 14:03:45 +02:00
virtio.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
yank.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00