From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VswO8-0007TT-DD for qemu-devel@nongnu.org; Tue, 17 Dec 2013 10:16:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VswO0-00066e-0S for qemu-devel@nongnu.org; Tue, 17 Dec 2013 10:16:48 -0500 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]:35086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VswNz-00066Y-Oz for qemu-devel@nongnu.org; Tue, 17 Dec 2013 10:16:39 -0500 Received: by mail-pa0-f52.google.com with SMTP id ld10so4596442pab.39 for ; Tue, 17 Dec 2013 07:16:38 -0800 (PST) Message-ID: <52B06ACE.3050901@gmail.com> Date: Tue, 17 Dec 2013 23:16:30 +0800 From: lijun MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qemu will core dump with "-smp 254, , sockets=2, cores=3, threads=2" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, afaerber@suse.de, ehabkost@redhat.com, rth@twiddle.net As Eric and Eduardo's suggestions, use is_power_of_2 to check whether nr_cores and nr_threads is the power of 2 in function x86_apicid_from_cpu_idx in file target-i386/topology.h. This check is very simple, I prefer add it in a function to write a new function. Thanks for Eric and Eduardo. Best Regards, Jun Li Signed-off-by: Jun Li --- target-i386/topology.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target-i386/topology.h b/target-i386/topology.h index 07a6c5f..ff21a98 100644 --- a/target-i386/topology.h +++ b/target-i386/topology.h @@ -126,6 +126,14 @@ static inline apic_id_t x86_apicid_from_cpu_idx(unsigned nr_cores, unsigned cpu_index) { unsigned pkg_id, core_id, smt_id; + + /* Check whether nr_cores and nr_threads is a power of 2. + * If not, 1 is assigned to them. + */ + nr_cores = is_power_of_2(nr_cores) > 0 ? nr_cores : 1; + nr_threads = is_power_of_2(nr_threads) > 0 ? nr_threads : 1; + + x86_topo_ids_from_idx(nr_cores, nr_threads, cpu_index, &pkg_id, &core_id, &smt_id); return apicid_from_topo_ids(nr_cores, nr_threads, pkg_id, core_id, smt_id); -- 1.8.3.1