From patchwork Wed Nov 27 13:02:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vasilis Liaskovitis X-Patchwork-Id: 294579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1771F2C00A7 for ; Thu, 28 Nov 2013 00:03:25 +1100 (EST) Received: from localhost ([::1]:35755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vlelz-0003Kr-Q8 for incoming@patchwork.ozlabs.org; Wed, 27 Nov 2013 08:03:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vlele-0003EI-Ok for qemu-devel@nongnu.org; Wed, 27 Nov 2013 08:03:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlelZ-0007ud-1X for qemu-devel@nongnu.org; Wed, 27 Nov 2013 08:02:58 -0500 Received: from mail-bk0-f49.google.com ([209.85.214.49]:52285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlelY-0007uX-Oj for qemu-devel@nongnu.org; Wed, 27 Nov 2013 08:02:52 -0500 Received: by mail-bk0-f49.google.com with SMTP id my13so3143908bkb.8 for ; Wed, 27 Nov 2013 05:02:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=KflhJo31/X0tP5cbgheOs+Suggaa6SLNP37rGTIOt6o=; b=N0MswVxD1/zrY0eH3M68B/NCjK3CuSDkebXLbMKcwDvBI6/dLVcAbs4USl/WqdW699 EyPJcQyIHyf/gObFmPhD8tGvhNA5YBzCXiHQ4xZwTnSBqBw0gKHppKC0b2UQnXW0GHoS areTfVAQ6J4tCPgjjHKYDbPiKy+y8/mGJd2bz38gYtPSbv6UdBYJG399TP5SIvFW5d3P fQde1du9YMyii+9Pj8nv4R2HAbuDzrPTPGGFs2s6XcMf8OaljhJzvCdm6O1nJY42rP5S WYJ43ihKmgrFq0jCuTAdFIuxNGaucMYlEMBB8xPYjqvQ2/iWXCH/Jhrab3FLdLaoiD1U jwWw== X-Gm-Message-State: ALoCoQkkLpVQVKVqAFElLfjM3lpz4ivGq3B8jSAfkjXB/WwvONR0NR8ALqqA3JgTx8aWE69b6elM X-Received: by 10.205.13.68 with SMTP id pl4mr116348bkb.99.1385557370774; Wed, 27 Nov 2013 05:02:50 -0800 (PST) Received: from dhcp-192-168-178-175.ri.pb.local. ([62.217.45.26]) by mx.google.com with ESMTPSA id k9sm27799457bko.16.2013.11.27.05.02.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Nov 2013 05:02:49 -0800 (PST) From: Vasilis Liaskovitis To: qemu-devel@nongnu.org Date: Wed, 27 Nov 2013 14:02:43 +0100 Message-Id: <1385557363-25756-1-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.214.49 Cc: Vasilis Liaskovitis , imammedo@redhat.com, thilo.fromm@profitbricks.com, seabios@seabios.org, mst@redhat.com Subject: [Qemu-devel] =?utf-8?q?=5BRFC_PATCH_v2=5D_i386=3A_Add_=5FPXM_ACPI?= =?utf-8?q?_method_to_CPU_objects?= X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch adds a _PXM method to ACPI CPU objects for the pc machine. The _PXM value is derived from the passed in guest info, same way as CPU SRAT entries. Currently, CPU SRAT entries are only enabled for cpus that are already present in the system. The SRAT entries for hotpluggable processors are disabled (flags bit 0 set to 0 in hw/i385/acpi-build.c:build_srat). Section 5.2.16.1 of ACPI spec mentions "If the Local APIC ID of a dynamically added processor is not present in the SRAT, a _PXM object must exist for the processor’s device or one of its ancestors in the ACPI Namespace." Since SRAT entries are not available for the hot-pluggable processors, a _PXM method must exist for them. Otherwise, the CPU is hot-added in the wrong NUMA node (default node 0). Even if CPU SRAT entries are enabled, _PXM method is what the linux kernel consults on hot-add time. Section 17.2.1 of ACPI spec mentions " OSPM will consume the SRAT only at boot time. OSPM should use _PXM for any devices that are hot-added into the system after boot up." To be more precise if SRAT information is available to the guest kernel, it is used. However, parsed SRAT info is reset and lost after hot-remove operations, see kernel commit c4c60524. This means that on a hot-unplug / hot-replug scenario, and without a _PXM method, the kernel may put a CPU on different nodes because SRAT info has been reset by a previous hot-remove operation. The above hot-remove/hot-add scenario has been tested on master, plus cpu-del patches from: https://lists.gnu.org/archive/html/qemu-devel/2013-10/msg01085.html With the curret _PXM patch, hot-added CPUs are always placed into the correct NUMA node, regardless of kernel behaviour. v1->v2: Make method return a DWORD integer Tested on qemu master + cpu-del patches Signed-off-by: Vasilis Liaskovitis Reviewed-by: Thilo Fromm --- hw/i386/acpi-build.c | 5 +++++ hw/i386/ssdt-proc.dsl | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d089e1e..3c11ddc 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -603,6 +603,7 @@ static inline char acpi_get_hex(uint32_t val) #define ACPI_PROC_OFFSET_CPUHEX (*ssdt_proc_name - *ssdt_proc_start + 2) #define ACPI_PROC_OFFSET_CPUID1 (*ssdt_proc_name - *ssdt_proc_start + 4) #define ACPI_PROC_OFFSET_CPUID2 (*ssdt_proc_id - *ssdt_proc_start) +#define ACPI_PROC_OFFSET_CPUPXM (*ssdt_proc_pxm - *ssdt_proc_start) #define ACPI_PROC_SIZEOF (*ssdt_proc_end - *ssdt_proc_start) #define ACPI_PROC_AML (ssdp_proc_aml + *ssdt_proc_start) @@ -724,6 +725,10 @@ build_ssdt(GArray *table_data, GArray *linker, proc[ACPI_PROC_OFFSET_CPUHEX+1] = acpi_get_hex(i); proc[ACPI_PROC_OFFSET_CPUID1] = i; proc[ACPI_PROC_OFFSET_CPUID2] = i; + proc[ACPI_PROC_OFFSET_CPUPXM] = guest_info->node_cpu[i]; + proc[ACPI_PROC_OFFSET_CPUPXM + 1] = 0; + proc[ACPI_PROC_OFFSET_CPUPXM + 2] = 0; + proc[ACPI_PROC_OFFSET_CPUPXM + 3] = 0; } /* build this code: diff --git a/hw/i386/ssdt-proc.dsl b/hw/i386/ssdt-proc.dsl index 8229bfd..8d4c5bf 100644 --- a/hw/i386/ssdt-proc.dsl +++ b/hw/i386/ssdt-proc.dsl @@ -47,6 +47,8 @@ DefinitionBlock ("ssdt-proc.aml", "SSDT", 0x01, "BXPC", "BXSSDT", 0x1) * also updating the C code. */ Name(_HID, "ACPI0007") + ACPI_EXTRACT_NAME_DWORD_CONST ssdt_proc_pxm + Name(PXM, 0xAAAAAAAA) External(CPMA, MethodObj) External(CPST, MethodObj) External(CPEJ, MethodObj) @@ -59,5 +61,8 @@ DefinitionBlock ("ssdt-proc.aml", "SSDT", 0x01, "BXPC", "BXSSDT", 0x1) Method(_EJ0, 1, NotSerialized) { CPEJ(ID, Arg0) } + Method(_PXM, 0) { + Return (PXM) + } } }