Content-Type: multipart/mixed; boundary="===============7669073296629869697==" MIME-Version: 1.0 From: Yury Norov To: kbuild-all@lists.01.org Subject: Re: [PATCH 4/4] lib/cpumask: add FORCE_NR_CPUS config option Date: Fri, 02 Sep 2022 10:31:20 -0700 Message-ID: In-Reply-To: List-Id: --===============7669073296629869697== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On Tue, Aug 30, 2022 at 02:05:09PM -0700, Yury Norov wrote: > + Vivek Goyal > + Yinghai Lu > + H. Peter Anvin > = > On Wed, Aug 31, 2022 at 02:33:41AM +0800, kernel test robot wrote: > > Hi Yury, > > = > > I love your patch! Perhaps something to improve: > > = > > [auto build test WARNING on tip/x86/core] > > [also build test WARNING on linus/master v6.0-rc3 next-20220830] > > [If your patch is applied to the wrong git tree, kindly drop us a note. > > And when submitting patch, we suggest to use '--base' as documented in > > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > = > > url: https://github.com/intel-lab-lkp/linux/commits/Yury-Norov/cpuma= sk-cleanup-nr_cpu_ids-vs-nr_cpumask_bits-mess/20220830-010755 > > base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git bc1= 2b70f7d216b36bd87701349374a13e486f8eb > > config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive= /20220831/202208310215.C2IzssKr-lkp(a)intel.com/config) > > compiler: gcc-11 (Debian 11.3.0-5) 11.3.0 > > = > > If you fix the issue, kindly add following tag where applicable > > Reported-by: kernel test robot > > = > > smatch warnings: > > arch/x86/kernel/apic/apic.c:2437 generic_processor_info() warn: always = true condition '(num_processors >=3D (1) - 1) =3D> (0-u32max >=3D 0)' > = > This is the code that woke up the smatch: > /* > * If boot cpu has not been detected yet, then only allow upto > * nr_cpu_ids - 1 processors and keep one slot free for boot cpu > */ > if (!boot_cpu_detected && num_processors >=3D nr_cpu_ids - 1 && > apicid !=3D boot_cpu_physical_apicid) { > int thiscpu =3D max + disabled_cpus - 1; > = > pr_warn("APIC: NR_CPUS/possible_cpus limit of %i almost" > " reached. Keeping one slot for boot cpu." > " Processor %d/0x%x ignored.\n", max, thiscpu, apicid); > = > disabled_cpus++; > return -ENODEV; > } > = > It has been added in a patch 14cb6dcf0a023f597 ("x86, boot: Wait for > boot cpu to show up if nr_cpus limit is about to hit") > = > My patch adds an option FORCE_NR_CPUS that makes nr_cpu_ids a compile-time > defined. > = > Hence, the num_processors >=3D nr_cpus - 1, > may become: num_processors >=3D 0, if NR_CPUS =3D=3D 1. > = > So the plain straightforward fix would be: > = > if (!boot_cpu_detected && > #if (NR_CPUS > 1) > num_processors >=3D nr_cpu_ids - 1 && > #endif > apicid !=3D boot_cpu_physical_apicid) { ... } > = > However, I have a feeling that all the logic above is not needed at > all on UP machines. If that's true, the '#if NR_CPUS > 1' should > protect the whole condition, or even bigger piece of the > generic_processor_info(). As Dave Hansen said: I think it's a reasonable warning, but it's also not something we need to hack around. We can surely only land in here with boot_cpu_detected=3D=3Dtrue if NR_CPUS=3D=3D1, so the rest of the express= ion is moot. = I don't think it's worth adding the #ifdef. So, leaving things as they are. If no other comments, moving the series into bitmap-for-next. Thanks, Yury --===============7669073296629869697==--