diff options
Diffstat (limited to 'hw/loongarch/virt.c')
-rw-r--r-- | hw/loongarch/virt.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index c0999878df..12d20055fe 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -1192,15 +1192,14 @@ virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) static int64_t virt_get_default_cpu_node_id(const MachineState *ms, int idx) { - int64_t nidx = 0; + int64_t socket_id; if (ms->numa_state->num_nodes) { - nidx = idx / (ms->smp.cpus / ms->numa_state->num_nodes); - if (ms->numa_state->num_nodes <= nidx) { - nidx = ms->numa_state->num_nodes - 1; - } + socket_id = ms->possible_cpus->cpus[idx].props.socket_id; + return socket_id % ms->numa_state->num_nodes; + } else { + return 0; } - return nidx; } static void loongarch_class_init(ObjectClass *oc, void *data) |