From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754761AbbI1B7A (ORCPT ); Sun, 27 Sep 2015 21:59:00 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:38829 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752864AbbI1B66 (ORCPT ); Sun, 27 Sep 2015 21:58:58 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101152465" Message-ID: <56089E7A.7040400@cn.fujitsu.com> Date: Mon, 28 Sep 2015 09:57:14 +0800 From: Tang Chen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Tejun Heo CC: , , , , , , , , , , , , , , , , Subject: Re: [PATCH v2 5/7] x86, acpi, cpu-hotplug: Introduce apicid_to_cpuid[] array to store persistent cpuid <-> apicid mapping. References: <1441859269-25831-1-git-send-email-tangchen@cn.fujitsu.com> <1441859269-25831-6-git-send-email-tangchen@cn.fujitsu.com> <20150910195532.GK8114@mtj.duckdns.org> <56066AC9.6020703@cn.fujitsu.com> <20150926175622.GC3572@htj.duckdns.org> In-Reply-To: <20150926175622.GC3572@htj.duckdns.org> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/27/2015 01:56 AM, Tejun Heo wrote: > On Sat, Sep 26, 2015 at 05:52:09PM +0800, Tang Chen wrote: >>>> +static int allocate_logical_cpuid(int apicid) >>>> +{ >>>> + int i; >>>> + >>>> + /* >>>> + * cpuid <-> apicid mapping is persistent, so when a cpu is up, >>>> + * check if the kernel has allocated a cpuid for it. >>>> + */ >>>> + for (i = 0; i < max_logical_cpuid; i++) { >>>> + if (cpuid_to_apicid[i] == apicid) >>>> + return i; >>>> + } >>>> + >>>> + /* Allocate a new cpuid. */ >>>> + if (max_logical_cpuid >= nr_cpu_ids) { >>>> + WARN_ONCE(1, "Only %d processors supported." >>>> + "Processor %d/0x%x and the rest are ignored.\n", >>>> + nr_cpu_ids - 1, max_logical_cpuid, apicid); >>>> + return -1; >>>> + } >>> So, the original code didn't have this failure mode, why is this >>> different for the new code? >> It is not different. Since max_logical_cpuid is new, this is ensure it won't >> go beyond NR_CPUS. > If the above condition can happen, the original code should have had a > similar check as above, right? Sure, max_logical_cpuid is a new thing > but that doesn't seem to change whether the above condition can happen > or not, no? Right, indeed. It is in generic_processor_info() |--> if (num_processors >= nr_cpu_ids) Will remove my new added check. Thanks. > > Thanks. >