From: Saurabh Sengar <ssengar@linux.microsoft.com>
To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
linux-kernel@vger.kernel.org
Cc: ssengar@microsoft.com, libo.chen@oracle.com, mhklinux@outlook.com
Subject: [PATCH] x86/Kconfig: Allow NR_CPUS between 512 and 8192
Date: Tue, 20 Feb 2024 01:50:13 -0800 [thread overview]
Message-ID: <1708422613-15714-1-git-send-email-ssengar@linux.microsoft.com> (raw)
Today there is no way one can choose any value between 512 to 8192
for NR_CPUS seamlessly. NR_CPUS is guarded by NR_CPUS_RANGE_END which
is further dependent on CPUMASK_OFFSTACK to allow NR_CPUs > 512.
For x86, CPUMASK_OFFSTACK can only be enabled either by selecting MAXSMP
or DEBUG_PER_CPU_MAPS. Both of these options has a cost to pay. MAXSMP
will increase the NR_CPUS to 8192 which will have impact on kernel image
size whereas DEBUG_PER_CPU_MAPS will have additional run time overheads.
Thus there is no good way to have NR_CPUS anything between 512 to 8192.
Fix this by selecting CPUMASK_OFFSTACK if NR_CPUS > 512 and
let NR_CPUS_RANGE_END set to 8192.
On a Hyper-V system where max number of CPUs are only 2048, this
patch saves around 1 MB of kernel image size, compare to MAXSMP.
Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
---
I want to mention that in ARM and other archs its very simple
to select any value for NR_CPUS. This is an attempt to have more
flexibilty in x86 arch as well to choose NR_CPUS.
Some of the earlier discussions reated to it which could be of interest:
https://lore.kernel.org/lkml/1708092603-14504-1-git-send-email-ssengar@linux.microsoft.com/
https://lore.kernel.org/lkml/794a1211-630b-3ee5-55a3-c06f10df1490@linux.com/
Another approach I can think of is to allow CPUMASK_OFFSTACK to be enabled
more freely like the below patch of Libo Chen, that will also solve the
problem I am addressing. But I feel this patch may have impact on other
archs as well and I am not sure if that is in best interest of all the archs.
https://lore.kernel.org/lkml/20220412231508.32629-2-libo.chen@oracle.com/
arch/x86/Kconfig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 07a0c8d4e9c7..458f3f250d7f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -34,6 +34,7 @@ config X86_64
select SWIOTLB
select ARCH_HAS_ELFCORE_COMPAT
select ZONE_DMA32
+ select CPUMASK_OFFSTACK if NR_CPUS > 512
config FORCE_DYNAMIC_FTRACE
def_bool y
@@ -1006,8 +1007,7 @@ config NR_CPUS_RANGE_END
config NR_CPUS_RANGE_END
int
depends on X86_64
- default 8192 if SMP && CPUMASK_OFFSTACK
- default 512 if SMP && !CPUMASK_OFFSTACK
+ default 8192 if SMP
default 1 if !SMP
config NR_CPUS_DEFAULT
--
2.34.1
next reply other threads:[~2024-02-20 9:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-20 9:50 Saurabh Sengar [this message]
2024-03-04 16:13 ` [PATCH] x86/Kconfig: Allow NR_CPUS between 512 and 8192 Saurabh Singh Sengar
2024-04-14 16:31 ` Saurabh Singh Sengar
2025-01-03 22:10 ` Hardik Garg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1708422613-15714-1-git-send-email-ssengar@linux.microsoft.com \
--to=ssengar@linux.microsoft.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=libo.chen@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=ssengar@microsoft.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.