From nobody Sat Nov 23 23:02:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731431223; cv=none; d=zohomail.com; s=zohoarc; b=XIroSsxvCtEureNS/xVeU/5JLWwDK+4IN4ZIb7dGLfe1fsq+iFt7PoRulFH/gi+mNpG4zjzEeZBQIE5nZsRLC98bTzvbKBYo/kZjD6KuBav3kPemf7cTST0kEuJz6sUAtDN38ErH196R6RA/An+obVNvTw8LyqdN+uWDJ1CiZT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731431223; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+2axKaCW1Z2fkq8aW+kN1R6He+CoS5FSvi1e/Yf1gaQ=; b=NDxS9VZicXTPXJh4UYRd1Z/xGVlAxwQLU5mog2W+T78KwnoRoVVcBaa3UuJKuldwylvTcZaf9GYzjBKxvD7vx+VhSVc7uGbM7cWuo+fRL8KZo8zXN5yxhVOWumxiOb7J9Wnxf4re1DSi9Ip8OUr2irv3EyEwFT7QgoX+j4QR4Wk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731431223483814.8438410661977; Tue, 12 Nov 2024 09:07:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tAuL4-0007g4-Tw; Tue, 12 Nov 2024 12:06:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tAuIo-0003nq-B6 for qemu-devel@nongnu.org; Tue, 12 Nov 2024 12:03:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tAuIk-0001cZ-FJ for qemu-devel@nongnu.org; Tue, 12 Nov 2024 12:03:41 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-B4s0NHw1MPekBbUsA14cpw-1; Tue, 12 Nov 2024 12:03:31 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D7DE51954230; Tue, 12 Nov 2024 17:03:28 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BCD4B1956089; Tue, 12 Nov 2024 17:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731431017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+2axKaCW1Z2fkq8aW+kN1R6He+CoS5FSvi1e/Yf1gaQ=; b=exQ121wkadvIn8E/tFVcbw8orkzF1m3Hf+xyMeLW8LxvBmYDHYtpTTryh59YqJg1ITmuUO s2CjZpOCaYe8FU/wj9JxhxpGOXhrqKRc2HZYv8376mlMHqvLdJ/Pw9Lf5gGpVcamopoHcT EIJ4mqdaIzzlos8r/p0T56qEhqzK1LI= X-MC-Unique: B4s0NHw1MPekBbUsA14cpw-1 X-Mimecast-MFC-AGG-ID: B4s0NHw1MPekBbUsA14cpw From: Igor Mammedov To: qemu-devel@nongnu.org Cc: salil.mehta@huawei.com, mst@redhat.com, imammedo@redhat.com, jonathan.cameron@huawei.com, linuxarm@huawei.com, anisinha@redhat.com, karl.heubaum@oracle.com, miguel.luis@oracle.com, gustavo.romero@linaro.org Subject: [RFC 7/7] DO NOT MERGE: acpi: cpuhp: preserve always present vCPUs on unplug Date: Tue, 12 Nov 2024 18:02:58 +0100 Message-ID: <20241112170258.2996640-8-imammedo@redhat.com> In-Reply-To: <20241112170258.2996640-1-imammedo@redhat.com> References: <20241112170258.2996640-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.122, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1731431225639116600 do not drop reference to always present vCPU and also avoid destroying it (unparent) on unplug. Based-on: 2d6cfbaf174 (hw/acpi: Make CPUs ACPI `presence` conditional durin= g vCPU hot-unplug) Signed-off-by: Igor Mammedov --- include/hw/acpi/cpu.h | 4 +++- hw/acpi/acpi-cpu-hotplug-stub.c | 3 ++- hw/acpi/cpu.c | 10 ++++++++-- hw/acpi/cpu_hotplug.c | 2 +- hw/acpi/generic_event_device.c | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h index e9e9c28359..f6708cafba 100644 --- a/include/hw/acpi/cpu.h +++ b/include/hw/acpi/cpu.h @@ -36,6 +36,7 @@ typedef struct CPUHotplugState { uint32_t selector; uint8_t command; uint32_t dev_count; + bool always_present_cpus; AcpiCpuStatus *devs; } CPUHotplugState; =20 @@ -50,7 +51,8 @@ void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st, DeviceState *dev, Error **errp); =20 void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, - CPUHotplugState *state, hwaddr base_addr); + CPUHotplugState *state, hwaddr base_addr, + bool always_present_cpus); =20 typedef struct CPUHotplugFeatures { bool acpi_1_compatible; diff --git a/hw/acpi/acpi-cpu-hotplug-stub.c b/hw/acpi/acpi-cpu-hotplug-stu= b.c index c6c61bb9cd..748fd04006 100644 --- a/hw/acpi/acpi-cpu-hotplug-stub.c +++ b/hw/acpi/acpi-cpu-hotplug-stub.c @@ -20,7 +20,8 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, O= bject *owner, } =20 void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, - CPUHotplugState *state, hwaddr base_addr) + CPUHotplugState *state, hwaddr base_addr, + bool always_present_cpus) { return; } diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 992ae5d233..d85d4add60 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -145,7 +145,6 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, u= int64_t data, dev =3D DEVICE(cdev->cpu); hotplug_ctrl =3D qdev_get_hotplug_handler(dev); hotplug_handler_unplug(hotplug_ctrl, dev, NULL); - object_unparent(OBJECT(dev)); cdev->fw_remove =3D false; } else if (data & 16) { if (!cdev->cpu || cdev->cpu =3D=3D first_cpu) { @@ -215,7 +214,8 @@ static const MemoryRegionOps cpu_hotplug_ops =3D { }; =20 void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, - CPUHotplugState *state, hwaddr base_addr) + CPUHotplugState *state, hwaddr base_addr, + bool always_present_cpus) { MachineState *machine =3D MACHINE(qdev_get_machine()); MachineClass *mc =3D MACHINE_GET_CLASS(machine); @@ -226,6 +226,7 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owne= r, id_list =3D mc->possible_cpu_arch_ids(machine); state->dev_count =3D id_list->len; state->devs =3D g_new0(typeof(*state->devs), state->dev_count); + state->always_present_cpus =3D always_present_cpus; for (i =3D 0; i < id_list->len; i++) { state->devs[i].cpu =3D CPU(id_list->cpus[i].cpu); state->devs[i].arch_id =3D id_list->cpus[i].arch_id; @@ -286,12 +287,17 @@ void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st, { AcpiCpuStatus *cdev; =20 + if (cpu_st->always_present_cpus) { + return; + } + cdev =3D get_cpu_status(cpu_st, dev); if (!cdev) { return; } =20 cdev->cpu =3D NULL; + object_unparent(OBJECT(dev)); } =20 static const VMStateDescription vmstate_cpuhp_sts =3D { diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c index 83b8bc5deb..8c3618680f 100644 --- a/hw/acpi/cpu_hotplug.c +++ b/hw/acpi/cpu_hotplug.c @@ -115,7 +115,7 @@ void acpi_switch_to_modern_cphp(AcpiCpuHotplug *gpe_cpu, MemoryRegion *parent =3D pci_address_space_io(PCI_DEVICE(gpe_cpu->devi= ce)); =20 memory_region_del_subregion(parent, &gpe_cpu->io); - cpu_hotplug_hw_init(parent, gpe_cpu->device, cpuhp_state, io_port); + cpu_hotplug_hw_init(parent, gpe_cpu->device, cpuhp_state, io_port, fal= se); } =20 void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine, diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 663d9cb093..9099b76f80 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -427,7 +427,7 @@ static void acpi_ged_realize(DeviceState *dev, Error **= errp) ACPI_CPU_HOTPLUG_REG_LEN); sysbus_init_mmio(sbd, &s->container_cpuhp); cpu_hotplug_hw_init(&s->container_cpuhp, OBJECT(dev), - &s->cpuhp_state, 0); + &s->cpuhp_state, 0, false); break; } ged_events--; --=20 2.43.0