Received: from eggs.gnu.org ([2001:4830:134:3::10]:54206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVMmz-0004gk-8b for qemu-devel@nongnu.org; Mon, 15 Feb 2016 12:18:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVMmt-0006Ad-4U for qemu-devel@nongnu.org; Mon, 15 Feb 2016 12:18:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVMms-0006AZ-VC for qemu-devel@nongnu.org; Mon, 15 Feb 2016 12:18:15 -0500 Date: Mon, 15 Feb 2016 18:18:11 +0100 From: Igor Mammedov Message-ID: <20160215181811.4ef30327@nial.brq.redhat.com> In-Reply-To: <20160212183328.GL6239@thinpad.lan.raisama.net> References: <1454695626-70225-1-git-send-email-imammedo@redhat.com> <1454695626-70225-3-git-send-email-imammedo@redhat.com> <20160212183328.GL6239@thinpad.lan.raisama.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 02/10] machine: introduce MachineClass.possible_cpu_arch_ids() hook List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: pbonzini@redhat.com, mst@redhat.com, qemu-devel@nongnu.org, marcel.apfelbaum@gmail.com, afaerber@suse.de On Fri, 12 Feb 2016 16:33:28 -0200 Eduardo Habkost wrote: > On Fri, Feb 05, 2016 at 07:06:58PM +0100, Igor Mammedov wrote: > > on x86 currently range 0..max_cpus is used to generate > > architecture-dependent CPU ID (APIC Id) for each present > > and possible CPUs. However architecture-dependent CPU IDs > > list could be sparse and code that needs to enumerate > > all IDs (ACPI) ended up doing guess work enumerating all > > possible and impossible IDs up to > > apic_id_limit = x86_cpu_apic_id_from_index(max_cpus). > > > > That leads to creation of MADT entries and Processor > > objects in ACPI tables for not possible CPUs. > > Fix it by allowing board specify a concrete list of > > CPU IDs accourding its own rules (which for x86 depends > > on topology). So that code that needs this list could > > request it from board instead of trying to figure out > > what IDs are correct on its own. > > > > Signed-off-by: Igor Mammedov > > --- > > hw/i386/pc.c | 16 ++++++++++++++++ > > include/hw/boards.h | 18 ++++++++++++++++++ > > 2 files changed, 34 insertions(+) > > > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > > index 9227bde..548ec64 100644 > > --- a/hw/i386/pc.c > > +++ b/hw/i386/pc.c > > @@ -1931,6 +1931,21 @@ static unsigned pc_cpu_index_to_socket_id(unsigned cpu_index) > > return topo.pkg_id; > > } > > > > +static GArray *pc_possible_cpu_arch_ids(void) > > +{ > > + int i; > > + GArray *list = g_array_new(FALSE, FALSE, sizeof(CPUArchId)); > > + > > + for (i = 0; i < max_cpus; i++) { > > + CPUArchId val; > > + > > + val.arch_id = x86_cpu_apic_id_from_index(i); > > + val.cpu = qemu_get_cpu_by_arch_id(val.arch_id); > > + g_array_append_val(list, val); > > + } > > + return list; > > +} > > You claim this version is linear, but I don't see any change from > v1, except for a whitespace change. > > qemu_get_cpu_by_arch_id() is O(smp_cpus). This calls > qemu_get_cpu_by_arch_id() max_cpus times, so this is > O(max_cpus*smp_cpus). I'm sorry, I've fixed it for ACPI tables only but not here. I've just posted and alternative patch for possible CPU in CPU hotplug introspection context '[RFC] QMP: add query-hotpluggable-cpus' which creates list in 2*O(N) and also makes access to list more typesafe. Lets see how it goes and later I can respin this series with that patch included.