From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 716982951A7 for ; Sat, 22 Nov 2025 16:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763828677; cv=none; b=kOX0BgEmIFkl3+ZMTLOoFLXNwxfTOB6hxlwef4NdfwK6k9yywvkfoSi6nhTOCnLNR9LDDIq764UXeHCL7cQVFzVKrXuJVqphWtiDldTcfim6WltCWC+HiK2YPLW31kF+D7U/4JG12zBhY6DcfxtD5rJSKoKJO2+Fu8hG6BwyVYg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763828677; c=relaxed/simple; bh=EPMwbrlVRzMLcOrh1VdwBGk+0vB7WawtAV8itn5AXLs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=XizQbwl7ubnE8UN305bYBYB3xSvISSKhmNfPegOx9dSIFncpkzLJENdRqKtE7XdgiOYJ2EdHfmLDgkAUB0V47xC5xOBPcx+HhJg857ES5XTDJ49u4ZnHUeeyNuI8pB2aBzSdagJkTI/3HM1+SEYWUU72VS7Pp9gCr4iylewsRBM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=HQrVNRFj; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="HQrVNRFj" Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20251122162425euoutp0243c6248c74f33225379f34efc9bbdb44~6YNNzJHRf0470904709euoutp02B for ; Sat, 22 Nov 2025 16:24:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20251122162425euoutp0243c6248c74f33225379f34efc9bbdb44~6YNNzJHRf0470904709euoutp02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1763828665; bh=qttmMdVBZdl0qjNk15VEdC5tH9DQrpLyLtaOLkXaYpc=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=HQrVNRFjiCYxe1DkAFacwDO/d97qi+pIhEJ2W9zB1EH4tWRjLb8GlinAn6YE+9ES/ yjashbKVvokVloWFgWXQnrAoqgYAi3jurGYqOTbjVhXI+Ff7vrvWKWXNN1zMF3eTCx KA19o5s7pYnwKJaVCP3dPjGWNmqXPm9Wh1HsCjwU= Received: from eusmtip1.samsung.com (unknown [203.254.199.221]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20251122162424eucas1p2f72e78f8f8fca9136c7e2da01402204c~6YNM4B2BH2298422984eucas1p2m; Sat, 22 Nov 2025 16:24:24 +0000 (GMT) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20251122162423eusmtip1bbdab99e94dc55c8e02dafc4405aa36e~6YNLsnq9C2408524085eusmtip1K; Sat, 22 Nov 2025 16:24:23 +0000 (GMT) Message-ID: Date: Sat, 22 Nov 2025 17:24:22 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Betterbird (Windows) Subject: Re: [patch V5 09/20] cpumask: Cache num_possible_cpus() To: Thomas Gleixner , LKML Cc: Peter Zijlstra , Gabriele Monaco , Mathieu Desnoyers , Michael Jeanson , Jens Axboe , "Paul E. McKenney" , "Gautham R. Shenoy" , Florian Weimer , Tim Chen , Yury Norov , Shrikanth Hegde , Nathan Chancellor Content-Language: en-US From: Marek Szyprowski In-Reply-To: <87zf8ehyf7.ffs@tglx> Content-Transfer-Encoding: 8bit X-CMS-MailID: 20251122162424eucas1p2f72e78f8f8fca9136c7e2da01402204c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20251121225645eucas1p2d0165821efb61ea8732d14b62c50af52 X-EPHeader: CA X-CMS-RootMailID: 20251121225645eucas1p2d0165821efb61ea8732d14b62c50af52 References: <20251119171016.815482037@linutronix.de> <20251119172549.578653738@linutronix.de> <89c7106e-a431-443a-9527-3d5fbce77fe1@samsung.com> <87zf8ehyf7.ffs@tglx> On 22.11.2025 16:36, Thomas Gleixner wrote: > On Fri, Nov 21 2025 at 23:56, Marek Szyprowski wrote: >> Reverting it on top of linux-next fixes the issue. Let me know how can I >> help debugging it. > Can you test the fix below please? This fixes the observed issue. Thanks! Tested-by: Marek Szyprowski > Thanks, > > tglx > --- > Subject: cpu: Initialize __num_possible_cpus correctly > From: Thomas Gleixner > Date: Sat, 22 Nov 2025 16:19:18 +0100 > > The variable to cache the number of possible CPUs is initialized to NR_CPUS > at build time, but that's only correct when cpu_possible_mask is > initialized with CPU_BITS_ALL. That's only the case on PARISC. > > On x86 and some other architectures this does not matter because they > initialize cpu_possible_mask via init_cpu_possible() which does a proper > weight calculation. Though on architectures which do not, this results > in a completely wrong cached value 'NR_CPUS + actual possible CPUs'. > > Initialize it correctly to 0 when CONFIG_INIT_ALL_POSSIBLE=n and move the > NR_CPUS initialization into the PARISC specific section. > > Fixes: d0f23ccf6ba9 ("cpumask: Cache num_possible_cpus()") > Reported-by: Marek Szyprowski > Reported-by: Nathan Chancellor > Signed-off-by: Thomas Gleixner > Closes: https://lore.kernel.org/all/89c7106e-a431-443a-9527-3d5fbce77fe1@samsung.com > Closes: https://lore.kernel.org/all/20251122002755.GA2682494@ax162 > --- > kernel/cpu.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -3085,10 +3085,13 @@ EXPORT_SYMBOL(cpu_all_bits); > #ifdef CONFIG_INIT_ALL_POSSIBLE > struct cpumask __cpu_possible_mask __ro_after_init > = {CPU_BITS_ALL}; > +unsigned int __num_possible_cpus __ro_after_init = NR_CPUS; > #else > struct cpumask __cpu_possible_mask __ro_after_init; > +unsigned int __num_possible_cpus __ro_after_init; > #endif > EXPORT_SYMBOL(__cpu_possible_mask); > +EXPORT_SYMBOL(__num_possible_cpus); > > struct cpumask __cpu_online_mask __read_mostly; > EXPORT_SYMBOL(__cpu_online_mask); > @@ -3108,9 +3111,6 @@ EXPORT_SYMBOL(__cpu_dying_mask); > atomic_t __num_online_cpus __read_mostly; > EXPORT_SYMBOL(__num_online_cpus); > > -unsigned int __num_possible_cpus __ro_after_init = NR_CPUS; > -EXPORT_SYMBOL(__num_possible_cpus); > - > void init_cpu_present(const struct cpumask *src) > { > cpumask_copy(&__cpu_present_mask, src); > Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland