@@ -270,3 +270,9 @@ unsigned int machine_topo_get_threads_per_socket(const MachineState *ms)
{
return ms->smp.threads * machine_topo_get_cores_per_socket(ms);
}
+
+CpuTopologyLevel machine_get_cache_topo_level(const MachineState *ms,
+ SMPCacheName cache)
+{
+ return ms->smp_cache->props[cache].topo;
+}
@@ -1045,6 +1045,15 @@ static void machine_class_init(ObjectClass *oc, void *data)
object_class_property_set_description(oc, "smp",
"CPU topology");
+ /* TODO: Implement check() method based on machine support. */
+ object_class_property_add_link(oc, "smp-cache",
+ TYPE_SMP_CACHE,
+ offsetof(MachineState, smp_cache),
+ object_property_allow_set_link,
+ OBJ_PROP_LINK_STRONG);
+ object_class_property_set_description(oc, "smp-cache",
+ "SMP cache property");
+
object_class_property_add(oc, "phandle-start", "int",
machine_get_phandle_start, machine_set_phandle_start,
NULL, NULL);
@@ -6,10 +6,10 @@
#include "exec/memory.h"
#include "sysemu/hostmem.h"
#include "sysemu/blockdev.h"
-#include "qapi/qapi-types-machine.h"
#include "qemu/module.h"
#include "qom/object.h"
#include "hw/core/cpu.h"
+#include "hw/core/smp-cache.h"
#define TYPE_MACHINE_SUFFIX "-machine"
@@ -45,6 +45,8 @@ void machine_parse_smp_config(MachineState *ms,
const SMPConfiguration *config, Error **errp);
unsigned int machine_topo_get_cores_per_socket(const MachineState *ms);
unsigned int machine_topo_get_threads_per_socket(const MachineState *ms);
+CpuTopologyLevel machine_get_cache_topo_level(const MachineState *ms,
+ SMPCacheName cache);
void machine_memory_devices_init(MachineState *ms, hwaddr base, uint64_t size);
/**
@@ -409,6 +411,7 @@ struct MachineState {
AccelState *accelerator;
CPUArchIdList *possible_cpus;
CpuTopology smp;
+ SMPCache *smp_cache;
struct NVDIMMState *nvdimms_state;
struct NumaState *numa_state;
};
With smp-cache object support, add smp cache topology for machine by linking the smp-cache object. Also add a helper to access cache topology level. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> --- Changes since RFC v2: * Linked machine's smp_cache to smp-cache object instead of a builtin structure. This is to get around the fact that the keyval format of -machine can't support JSON. * Wrapped the cache topology level access into a helper. --- hw/core/machine-smp.c | 6 ++++++ hw/core/machine.c | 9 +++++++++ include/hw/boards.h | 5 ++++- 3 files changed, 19 insertions(+), 1 deletion(-)