[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 14/22] arm/cpuhp: Release objects for *disabled* possible vcp
From: |
Salil Mehta |
Subject: |
[PATCH RFC 14/22] arm/cpuhp: Release objects for *disabled* possible vcpus after init |
Date: |
Sat, 13 Jun 2020 22:36:21 +0100 |
During machvirt_init(), ARMCPU objects are pre-created along with the
corresponding KVM vcpus in the host. Disabled possible KVM vcpus are then
parked at the per-virt-machine list "kvm_parked_vcpus".
Prime purpose to pre-create ARMCPU objects for the disabled vcpus is to
facilitate the GIC initialization (pre-sized with possible vcpus). GIC
requires all vcpus corresponding to its GICC(GIC CPU Interface) to be
initialized and present during its own initialization.
After initialization of the machine is complete we release the ARMCPU objects
for the disabled vcpus(which shall be re-created at the time when vcpu is hot
plugged again. This newly created ARMCPU object is then attached with
corresponding parked KVM VCPU).
We have few options after the machine init where the disabled ARMCPU object
could be released:
1. Release in context to the virt_machine_done() notifier.(This is also our
current approach)
2. Defer the release till a new vcpu object is hot plugged. Then release the
object in context to the pre_plug() phase.
3. Never release and keep on reusing them and release once at VM exit. This
will require some modifications within the interface of qdevice_add() to
get old ARMCPU object instead of creating a new one for the hotplug request.
Each of the above approaches come with their own pros and cons. This prototype
uses the 1st approach.(suggestions are welcome!)
Co-developed-by: Keqian Zhu <zhukeqian1@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
hw/arm/virt.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index e9ead0e2dd..0faf54aa8f 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1403,6 +1403,28 @@ static void create_secure_ram(VirtMachineState *vms,
g_free(nodename);
}
+static void virt_remove_disabled_cpus(VirtMachineState *vms)
+{
+ MachineState *ms = MACHINE(vms);
+ int n;
+
+ /*
+ * RFC: Question: Other approach could have been to keep them forever
+ * and release it only once when qemu exits as part o finalize or when
+ * new vcpu is hotplugged. In the later old could be released for the
+ * newly created object for the same vcpu?
+ */
+ for (n = vms->smp_cpus; n < vms->max_cpus; n++) {
+ CPUState *cs = qemu_get_possible_cpu(n);
+ if (!qemu_present_cpu(cs)) {
+ CPUArchId *cpu_slot;
+ cpu_slot = virt_find_cpu_slot(ms, cs->cpu_index);
+ cpu_slot->cpu = NULL;
+ object_unref(OBJECT(cs));
+ }
+ }
+}
+
static bool virt_pmu_init(VirtMachineState *vms)
{
CPUArchIdList *possible_cpus = vms->parent.possible_cpus;
@@ -1500,6 +1522,9 @@ void virt_machine_done(Notifier *notifier, void *data)
virt_acpi_setup(vms);
virt_build_smbios(vms);
+
+ /* release the disabled ARMCPU objects used during init for pre-sizing */
+ virt_remove_disabled_cpus(vms);
}
static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
--
2.17.1
- [PATCH RFC 06/22] arm/cpuhp: Changes to pre-size GIC with possible vcpus @machine init, (continued)
- [PATCH RFC 06/22] arm/cpuhp: Changes to pre-size GIC with possible vcpus @machine init, Salil Mehta, 2020/06/13
- [PATCH RFC 07/22] arm/cpuhp: Init PMU at host for all possible vcpus, Salil Mehta, 2020/06/13
- [PATCH RFC 08/22] arm/cpuhp: Enable ACPI support for vcpu hotplug, Salil Mehta, 2020/06/13
- [PATCH RFC 09/22] arm/cpuhp: Init GED framework with cpu hotplug events, Salil Mehta, 2020/06/13
- [PATCH RFC 10/22] arm/cpuhp: Update CPUs AML with cpu-(ctrl)dev change, Salil Mehta, 2020/06/13
- [PATCH RFC 11/22] arm/cpuhp: Update GED _EVT method AML with cpu scan, Salil Mehta, 2020/06/13
- [PATCH RFC 12/22] arm/cpuhp: MADT Tbl change to size the guest with possible vcpus, Salil Mehta, 2020/06/13
- [PATCH RFC 13/22] arm/cpuhp: Add ACPI _MAT entry for Processor object, Salil Mehta, 2020/06/13
- [PATCH RFC 14/22] arm/cpuhp: Release objects for *disabled* possible vcpus after init,
Salil Mehta <=
- [PATCH RFC 15/22] arm/cpuhp: Update ACPI GED framework to support vcpu hotplug, Salil Mehta, 2020/06/13
- [PATCH RFC 16/22] arm/cpuhp: Add/update basic hot-(un)plug framework, Salil Mehta, 2020/06/13
- [PATCH RFC 17/22] arm/cpuhp: Changes to (un)wire GICC<->VCPU IRQs during hot-(un)plug, Salil Mehta, 2020/06/13
- [PATCH RFC 18/22] arm/cpuhp: Changes to update GIC with vcpu hot-plug notification, Salil Mehta, 2020/06/13
- [PATCH RFC 19/22] arm/cpuhp: Changes required to (re)init the vcpu register info, Salil Mehta, 2020/06/13
- [PATCH RFC 20/22] arm/cpuhp: Update the guest(via GED) about cpu hot-(un)plug events, Salil Mehta, 2020/06/13
- [PATCH RFC 21/22] arm/cpuhp: Changes required for reset and to support next boot, Salil Mehta, 2020/06/13
- [PATCH RFC 22/22] arm/cpuhp: Add support of *unrealize* ARMCPU during vcpu hot-unplug, Salil Mehta, 2020/06/13
- Re: [PATCH RFC 00/22] Support of Virtual CPU Hotplug for ARMv8 Arch, no-reply, 2020/06/13
- Re: [PATCH RFC 00/22] Support of Virtual CPU Hotplug for ARMv8 Arch, no-reply, 2020/06/13