From patchwork Mon May 2 12:33:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8992241 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1B56BBF29F for ; Mon, 2 May 2016 12:56:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61B58201FE for ; Mon, 2 May 2016 12:56:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73AC8201FA for ; Mon, 2 May 2016 12:56:33 +0000 (UTC) Received: from localhost ([::1]:36544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axDOn-0007Si-Ey for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 May 2016 08:56:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD4I-0007Qq-ID for qemu-devel@nongnu.org; Mon, 02 May 2016 08:35:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axD46-0000Dt-AS for qemu-devel@nongnu.org; Mon, 02 May 2016 08:35:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37962) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD46-000080-39 for qemu-devel@nongnu.org; Mon, 02 May 2016 08:35:06 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06E64C003579 for ; Mon, 2 May 2016 12:34:55 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u42CXqcM000450; Mon, 2 May 2016 08:34:53 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 2 May 2016 14:33:44 +0200 Message-Id: <1462192431-146342-36-git-send-email-imammedo@redhat.com> In-Reply-To: <1462192431-146342-1-git-send-email-imammedo@redhat.com> References: <1462192431-146342-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 35/42] acpi: cpuhp: provide cpu._PXM method if running in numa mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drjones@redhat.com, ehabkost@redhat.com, mst@redhat.com, armbru@redhat.com, marcel@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Having proximity in SRAT table is not enough in case of linux guest as it discards SRAT table information after it's done with booting. So hotplugged CPUs will go to 1st node as kernel doesn't know to what node they belong to anymore. So do the same as with hotplugged memory and provide _PXM method in CPU device context so that OSPM could assign CPU to a correct node. Signed-off-by: Igor Mammedov --- hw/acpi/cpu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 1 + 2 files changed, 49 insertions(+) diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index a238ced..a2a03b2 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -11,6 +11,7 @@ #define ACPI_CPU_CMD_DATA_OFFSET_RW 8 enum { + CPHP_PXM_CMD = 0, CPHP_CMD_MAX }; @@ -35,6 +36,12 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) break; case ACPI_CPU_CMD_DATA_OFFSET_RW: switch (cpu_st->command) { + case CPHP_PXM_CMD: { + Object *o = OBJECT(CPU(cdev->cpu)); + val = o ? object_property_get_int(o, "node", NULL) : ~0; + trace_cpuhp_acpi_read_pxm(cpu_st->selector, val); + break; + } default: break; } @@ -243,6 +250,7 @@ const VMStateDescription vmstate_cpu_hotplug = { #define CPU_SCAN_METHOD "CSCN" #define CPU_EJECT_METHOD "CEJ0" #define CPU_NOTIFY_METHOD "CTFY" +#define CPU_PXM_METHOD "CPXM" #define CPU_ENABLED "CPEN" #define CPU_SELECTOR "CSEL" @@ -321,6 +329,8 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat, cpus_dev = aml_device("\\_SB.CPUS"); { int i; + bool has_pxm = true; + Error *local_err = NULL; Aml *one = aml_int(1); Aml *cpu_selector = aml_name("%s.%s", cphp_res_path, CPU_SELECTOR); Aml *ins_evt = aml_name("%s.%s", cphp_res_path, CPU_INSERT_EVENT); @@ -328,11 +338,25 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat, Aml *ej_evt = aml_name("%s.%s", cphp_res_path, CPU_EJECT_EVENT); Aml *is_enabled = aml_name("%s.%s", cphp_res_path, CPU_ENABLED); Aml *ctrl_lock = aml_name("%s.%s", cphp_res_path, CPU_LOCK); + Aml *cpu_cmd = aml_name("%s.%s", cphp_res_path, CPU_COMMAND); + Aml *cpu_data = aml_name("%s.%s", cphp_res_path, CPU_DATA); aml_append(cpus_dev, aml_name_decl("_HID", aml_string("ACPI0010"))); aml_append(cpus_dev, aml_name_decl("_CID", aml_eisaid("PNP0A05"))); if (machine->cpu_hotplug) { + local_err = NULL; + /* + * sample 1st VCPU (BSP) if it has support for numa and use result + * to enable _PXM method support + */ + object_property_get_int(OBJECT(arch_ids->cpus[0].cpu), "node", + &local_err); + if (local_err) { + error_free(local_err); + has_pxm = false; + } + method = aml_method(CPU_NOTIFY_METHOD, 2, AML_NOTSERIALIZED); for (i = 0; i < arch_ids->len; i++) { Aml *cpu = aml_name(CPU_NAME_FMT, i); @@ -413,6 +437,23 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat, aml_append(method, aml_release(ctrl_lock)); } aml_append(cpus_dev, method); + + if (has_pxm) { + method = aml_method(CPU_PXM_METHOD, 1, AML_SERIALIZED); + { + Aml *uid = aml_arg(0); + Aml *pxm = aml_local(0); + Aml *pxm_cmd = aml_int(CPHP_PXM_CMD); + + aml_append(method, aml_acquire(ctrl_lock, 0xFFFF)); + aml_append(method, aml_store(uid, cpu_selector)); + aml_append(method, aml_store(pxm_cmd, cpu_cmd)); + aml_append(method, aml_store(cpu_data, pxm)); + aml_append(method, aml_release(ctrl_lock)); + aml_append(method, aml_return(pxm)); + } + aml_append(cpus_dev, method); + } } /* build Processor object for each processor */ @@ -461,6 +502,13 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat, method = aml_method("_EJ0", 1, AML_NOTSERIALIZED); aml_append(method, aml_call1(CPU_EJECT_METHOD, uid)); aml_append(dev, method); + + if (has_pxm) { + method = aml_method("_PXM", 0, AML_SERIALIZED); + aml_append(method, + aml_return(aml_call1(CPU_PXM_METHOD, uid))); + aml_append(dev, method); + } } aml_append(cpus_dev, dev); } diff --git a/trace-events b/trace-events index 108ae07..159c94d 100644 --- a/trace-events +++ b/trace-events @@ -1913,6 +1913,7 @@ aspeed_vic_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 # hw/acpi/cpu.c cpuhp_acpi_invalid_idx_selected(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_read_flags(uint32_t idx, uint8_t flags) "idx[0x%"PRIx32"] flags: 0x%"PRIx8 +cpuhp_acpi_read_pxm(uint32_t idx, uint32_t pxm) "idx[0x%"PRIx32"] flags: 0x%"PRIx32 cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_clear_remove_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_write_idx(uint32_t idx) "set active cpu idx: 0x%"PRIx32