[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 31/42] pc: numa: replace node_cpu indexing by apic_id
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [RFC 31/42] pc: numa: replace node_cpu indexing by apic_id with possible_cpus index |
Date: |
Mon, 2 May 2016 14:33:40 +0200 |
that removes dependency on apic_id_limit, reducing size of
node_cpu to a number of maxcpus and allowing usage of
32bit APIC IDs without allocating a huge array.
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/i386/acpi-build.c | 2 +-
hw/i386/pc.c | 28 ++++++++++++----------------
2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index b27502a..93f7b5b 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2362,7 +2362,7 @@ build_srat(GArray *table_data, GArray *linker,
MachineState *machine)
core->type = ACPI_SRAT_PROCESSOR;
core->length = sizeof(*core);
core->local_apic_id = apic_id;
- curnode = pcms->node_cpu[apic_id];
+ curnode = pcms->node_cpu[i];
core->proximity_lo = curnode;
memset(core->proximity_hi, 0, 3);
core->local_sapic_eid = 0;
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 1cad132..2dba916 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1104,7 +1104,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
void pc_cpus_init(PCMachineState *pcms)
{
- int i;
+ int i, j;
X86CPU *cpu = NULL;
MachineState *machine = MACHINE(pcms);
@@ -1133,9 +1133,19 @@ void pc_cpus_init(PCMachineState *pcms)
pcms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
sizeof(CPUArchId) * max_cpus);
+ pcms->node_cpu = g_malloc0(max_cpus * sizeof *pcms->node_cpu);
+
for (i = 0; i < max_cpus; i++) {
pcms->possible_cpus->cpus[i].arch_id = x86_cpu_apic_id_from_index(i);
pcms->possible_cpus->len++;
+
+ for (j = 0; j < nb_numa_nodes; j++) {
+ if (test_bit(i, numa_info[j].node_cpu)) {
+ pcms->node_cpu[i] = j;
+ break;
+ }
+ }
+
if (i < smp_cpus) {
cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i),
&error_fatal);
@@ -1185,7 +1195,7 @@ void pc_machine_done(Notifier *notifier, void *data)
void pc_guest_info_init(PCMachineState *pcms)
{
- int i, j;
+ int i;
pcms->apic_xrupt_override = kvm_allows_irq0_override();
pcms->numa_nodes = nb_numa_nodes;
@@ -1195,20 +1205,6 @@ void pc_guest_info_init(PCMachineState *pcms)
pcms->node_mem[i] = numa_info[i].node_mem;
}
- pcms->node_cpu = g_malloc0(pcms->apic_id_limit *
- sizeof *pcms->node_cpu);
-
- for (i = 0; i < max_cpus; i++) {
- unsigned int apic_id = x86_cpu_apic_id_from_index(i);
- assert(apic_id < pcms->apic_id_limit);
- for (j = 0; j < nb_numa_nodes; j++) {
- if (test_bit(i, numa_info[j].node_cpu)) {
- pcms->node_cpu[apic_id] = j;
- break;
- }
- }
- }
-
pcms->machine_done.notify = pc_machine_done;
qemu_add_machine_init_done_notifier(&pcms->machine_done);
}
--
1.8.3.1
- [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property, (continued)
- [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 19/42] pc: add generic CPU unplug callbacks, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 18/42] acpi: hardware side of CPU hotplug, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 22/42] pc: piix4: initialize new CPU hotplug hw, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 21/42] pc: q35: initialize new CPU hotplug hw, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 25/42] tests: acpi: update cphp_legacy case with new ProcessorID values, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 26/42] pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 24/42] pc: acpi: cpuhp-legacy: switch ProcessorID to possible_cpus idx, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 31/42] pc: numa: replace node_cpu indexing by apic_id with possible_cpus index,
Igor Mammedov <=
- [Qemu-devel] [RFC 27/42] acpi: add CPU devices AML to DSDT, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 28/42] acpi: add CPU hotplug methods to DSDT, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 32/42] pc: set X86CPU.node property if QEMU starts with numa enabled, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 29/42] tests: acpi: update expected files with new CPU AML description, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 14/42] tests: acpi: check legacy CPU hotplug AML is present for 2.6 machine type, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 23/42] tests: pc-cpu-test: turn on cpu-hotplug explicily, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 30/42] qdev: hotplug: Introduce HotplugHandler.pre_plug() callback, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 34/42] acpi: cpuhp: add command and data registers, Igor Mammedov, 2016/05/02
- [Qemu-devel] [RFC 35/42] acpi: cpuhp: provide cpu._PXM method if running in numa mode, Igor Mammedov, 2016/05/02