4e88e7e340
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>
113 lines
2.9 KiB
Python
113 lines
2.9 KiB
Python
# -*- Mode: Python -*-
|
|
# vim: filetype=python
|
|
#
|
|
# This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
# See the COPYING file in the top-level directory.
|
|
|
|
##
|
|
# = Common machine types
|
|
##
|
|
|
|
##
|
|
# @S390CpuEntitlement:
|
|
#
|
|
# An enumeration of CPU entitlements that can be assumed by a virtual
|
|
# S390 CPU
|
|
#
|
|
# Since: 8.2
|
|
##
|
|
{ 'enum': 'S390CpuEntitlement',
|
|
'data': [ 'auto', 'low', 'medium', 'high' ] }
|
|
|
|
##
|
|
# @CpuTopologyLevel:
|
|
#
|
|
# An enumeration of CPU topology levels.
|
|
#
|
|
# @thread: thread level, which would also be called SMT level or
|
|
# logical processor level. The @threads option in
|
|
# SMPConfiguration is used to configure the topology of this
|
|
# level.
|
|
#
|
|
# @core: core level. The @cores option in SMPConfiguration is used
|
|
# to configure the topology of this level.
|
|
#
|
|
# @module: module level. The @modules option in SMPConfiguration is
|
|
# used to configure the topology of this level.
|
|
#
|
|
# @cluster: cluster level. The @clusters option in SMPConfiguration
|
|
# is used to configure the topology of this level.
|
|
#
|
|
# @die: die level. The @dies option in SMPConfiguration is used to
|
|
# configure the topology of this level.
|
|
#
|
|
# @socket: socket level, which would also be called package level.
|
|
# The @sockets option in SMPConfiguration is used to configure
|
|
# the topology of this level.
|
|
#
|
|
# @book: book level. The @books option in SMPConfiguration is used
|
|
# to configure the topology of this level.
|
|
#
|
|
# @drawer: drawer level. The @drawers option in SMPConfiguration is
|
|
# used to configure the topology of this level.
|
|
#
|
|
# @default: default level. Some architectures will have default
|
|
# topology settings (e.g., cache topology), and this special
|
|
# level means following the architecture-specific settings.
|
|
#
|
|
# Since: 9.2
|
|
##
|
|
{ 'enum': 'CpuTopologyLevel',
|
|
'data': [ 'thread', 'core', 'module', 'cluster', 'die',
|
|
'socket', 'book', 'drawer', 'default' ] }
|
|
|
|
##
|
|
# @CacheLevelAndType:
|
|
#
|
|
# Caches a system may have. The enumeration value here is the
|
|
# combination of cache level and cache type.
|
|
#
|
|
# @l1d: L1 data cache.
|
|
#
|
|
# @l1i: L1 instruction cache.
|
|
#
|
|
# @l2: L2 (unified) cache.
|
|
#
|
|
# @l3: L3 (unified) cache
|
|
#
|
|
# Since: 9.2
|
|
##
|
|
{ 'enum': 'CacheLevelAndType',
|
|
'data': [ 'l1d', 'l1i', 'l2', 'l3' ] }
|
|
|
|
##
|
|
# @SmpCacheProperties:
|
|
#
|
|
# Cache information for SMP system.
|
|
#
|
|
# @cache: Cache name, which is the combination of cache level
|
|
# and cache type.
|
|
#
|
|
# @topology: Cache topology level. It accepts the CPU topology
|
|
# enumeration as the parameter, i.e., CPUs in the same
|
|
# topology container share the same cache.
|
|
#
|
|
# Since: 9.2
|
|
##
|
|
{ 'struct': 'SmpCacheProperties',
|
|
'data': {
|
|
'cache': 'CacheLevelAndType',
|
|
'topology': 'CpuTopologyLevel' } }
|
|
|
|
##
|
|
# @SmpCachePropertiesWrapper:
|
|
#
|
|
# List wrapper of SmpCacheProperties.
|
|
#
|
|
# @caches: the list of SmpCacheProperties.
|
|
#
|
|
# Since 9.2
|
|
##
|
|
{ 'struct': 'SmpCachePropertiesWrapper',
|
|
'data': { 'caches': ['SmpCacheProperties'] } }
|