Message ID | 794a1211-630b-3ee5-55a3-c06f10df1490@linux.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-273-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8935993dys; Thu, 14 Dec 2023 16:06:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHyqz4iuN1stHqHogxPY/X1KIYAEpMzuNh1ZZJrd6IsJQOSoh937RJhpQdYVeyTfIZj1Te X-Received: by 2002:a05:6358:3419:b0:170:d7e8:4b16 with SMTP id h25-20020a056358341900b00170d7e84b16mr9133752rwd.23.1702598781306; Thu, 14 Dec 2023 16:06:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702598781; cv=none; d=google.com; s=arc-20160816; b=iaXGncd30X8j/O3VSbCXjoTSJ+bEkyNdIQd0w4b+oWyEgjsCbh+SwcxTQY6AmQil6q 0D+adiQHBTMkC1e1gUfnYMcMR93hLy5RP8KpiL12kVrAcQlwJ+k3tjBfrefNRsrFWQ3z KPcuPdEcMyyf4J7/NwWNVs3U2GRCOdsx7YLScud7cTy546TyKmbO7NMEbN1uhFkm0xeb 8SwCDDLOkSLr1pxVQASREAESmavFromkF7XZYWyC4gnLqYUYmSkaZwhFAwlWoJmmywW8 ypXWfNoRc1TmwyQoB+hNWqNxBOSQ62CF0/1enasT2ITFr7Np25fe642JmVJSa4ku/NwY JszQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:subject:cc:to:from:date; bh=bBtr7LN/hpfo2MNuOcxcIEm+IlbMg9kH3NHufS4DZSg=; fh=PbN0/9qzDGbjZiGib/79S/sGujsxkk4isE1h4NhX7qM=; b=FqcysDDx09Rprq3rP7BvdTjBUKVtBR8C/OAETvqyrhIS+nysOa3uYGTp/oY907JvZr 2goO83b4zXSi0I+G4zw96ejbWJaInAYhSs0cR6qqGuu4Cz8C6cuQ4x521fRfoX7ilEIZ QjjTMD/BadqOBifhDTc+OfLWaWIVZrWHmPp1VQNQEyBezULpbf1bcVogBhqNyJEs/2WE Au8kT8Lxz5Higxp5L9uu4LrDmcAxwCu1zebzlr2SoKKABjnUmJ4d1TVhm4JQjHo8e0M6 gYAZlWZAXmEJ3vZNvK6tK2gEP70Qv2143+eON3ZjELzylV7x9c2svCBMZ4srzf8EAIEI gxzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-273-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-273-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i3-20020a6551c3000000b005c6977f9c0dsi11991361pgq.214.2023.12.14.16.06.21 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 16:06:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-273-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-273-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-273-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1185D2839B8 for <ouuuleilei@gmail.com>; Fri, 15 Dec 2023 00:06:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5610CEC6; Fri, 15 Dec 2023 00:06:03 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from gentwo.org (gentwo.org [62.72.0.81]) (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 859507EA for <linux-kernel@vger.kernel.org>; Fri, 15 Dec 2023 00:05:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=linux.com Received: by gentwo.org (Postfix, from userid 1003) id 8FEFF40E8E; Thu, 14 Dec 2023 16:05:56 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id 8D6B440E89; Thu, 14 Dec 2023 16:05:56 -0800 (PST) Date: Thu, 14 Dec 2023 16:05:56 -0800 (PST) From: "Christoph Lameter (Ampere)" <cl@linux.com> To: Anshuman Khandual <anshuman.khandual@arm.com> cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Valentin.Schneider@arm.com, Vanshidhar Konda <vanshikonda@os.amperecomputing.com>, Jonathan Cameron <Jonathan.Cameron@Huawei.com>, Catalin Marinas <catalin.marinas@arm.com>, Robin Murphy <robin.murphy@arm.com>, Dave Kleikamp <dave.kleikamp@oracle.com>, Matteo Carlini <Matteo.Carlini@arm.com>, akpm@linux-foundation.org, yang@os.amperecomputing.com Subject: [PATCH] ARM64: Dynamically allocate cpumasks and increase supported CPUs to 512 Message-ID: <794a1211-630b-3ee5-55a3-c06f10df1490@linux.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785304219617708800 X-GMAIL-MSGID: 1785304219617708800 |
Series |
ARM64: Dynamically allocate cpumasks and increase supported CPUs to 512
|
|
Commit Message
Christoph Lameter (Ampere)
Dec. 15, 2023, 12:05 a.m. UTC
Ampere Computing develops high end ARM processor that support an ever
increasing number of processors. The default 256 processors are
not enough for our newer products. The default is used by
distros and therefore our customers cannot use distro kernels because
the number of processors is not supported.
One of the objections against earlier patches to increase the limit
was that the memory use becomes too high. There is a feature called
CPUMASK_OFFSTACK that configures the cpumasks in the kernel to be
dynamically allocated. This was used in the X86 architecture in the
past to enable support for larger CPU configurations up to 8k cpus.
With that is becomes possible to dynamically size the allocation of
the cpu bitmaps depending on the quantity of processors detected on
bootup.
This patch enables that logic if more than 256 processors
are configured and increases the default to 512 processors.
Further increases may be needed if ARM processor vendors start
supporting more processors. Given the current inflationary trends
in core counts from multiple processor manufacturers this may occur.
Signed-off-by: Christoph Lameter (Ampere) <cl@linux.com>
---
This was discussed earlier and this updated patch was proposed at
https://lore.kernel.org/linux-arm-kernel/6a854175-5f89-c754-17b8-deda18447f1f@gentwo.org/T/
Comments
On Thu, Dec 14, 2023 at 04:05:56PM -0800, Christoph Lameter (Ampere) wrote: > Index: linux/arch/arm64/Kconfig > =================================================================== > --- linux.orig/arch/arm64/Kconfig > +++ linux/arch/arm64/Kconfig > @@ -1407,7 +1407,21 @@ config SCHED_SMT > config NR_CPUS > int "Maximum number of CPUs (2-4096)" > range 2 4096 I think your mailer got to your patch and messed up the white space. There are two spaces before each of these lines rather than the usual one. > - default "256" > + default 512 > + > +# > +# Determines the placement of cpumasks. > +# > +# With CPUMASK_OFFSTACK the cpumasks are dynamically allocated. > +# Useful for machines with lots of core because it avoids increasing > +# the size of many of the data structures in the kernel. > +# > +# If this is off then the cpumasks have a static sizes and are > +# embedded within data structures. > +# > +config CPUMASK_OFFSTACK > + def_bool y > + depends on NR_CPUS > 256 Should that be ">= 256" ? > > config HOTPLUG_CPU > bool "Support for hot-pluggable CPUs" Same here.
Whitespace issues aside, I have applied the patch on top of kernel 6.1.55 and tested on both a dual-socket Ampere Altra machine with < 256 CPUs, and a dual-socket AmpereOne machine with > 256 CPUs. Works as expected, with all CPUs visible and functional. > config NR_CPUS > int "Maximum number of CPUs (2-4096)" > range 2 4096 > - default "256" > + default 512 Nit: the new default value should be in quotation marks, if we want to be pedantic Tested-by: Eric Mackay <eric.mackay@oracle.com>
On 2024/1/15 23:39, Russell King (Oracle) wrote: > On Thu, Dec 14, 2023 at 04:05:56PM -0800, Christoph Lameter (Ampere) wrote: >> Index: linux/arch/arm64/Kconfig >> =================================================================== >> --- linux.orig/arch/arm64/Kconfig >> +++ linux/arch/arm64/Kconfig >> @@ -1407,7 +1407,21 @@ config SCHED_SMT >> config NR_CPUS >> int "Maximum number of CPUs (2-4096)" >> range 2 4096 > > I think your mailer got to your patch and messed up the white space. > There are two spaces before each of these lines rather than the usual > one. > >> - default "256" >> + default 512 >> + >> +# >> +# Determines the placement of cpumasks. >> +# >> +# With CPUMASK_OFFSTACK the cpumasks are dynamically allocated. >> +# Useful for machines with lots of core because it avoids increasing >> +# the size of many of the data structures in the kernel. >> +# >> +# If this is off then the cpumasks have a static sizes and are >> +# embedded within data structures. >> +# >> +config CPUMASK_OFFSTACK >> + def_bool y >> + depends on NR_CPUS > 256 > > Should that be ">= 256" ? Maybe just select CPUMASK_OFFSTACK if NR_CPUS >= 256, But could we just make CPUMASK_OFFSTACK configurable and let user/distro to enable it? diff --git a/lib/Kconfig b/lib/Kconfig index 5ddda7c2ed9b..4254be5aa843 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -535,7 +535,9 @@ config CHECK_SIGNATURE bool config CPUMASK_OFFSTACK - bool "Force CPU masks off stack" if DEBUG_PER_CPU_MAPS + bool "Force CPU masks off stack" + depends on SMP + default n help Use dynamic allocation for cpumask_var_t, instead of putting them on the stack. This is a bit more expensive, but avoids > >> >> config HOTPLUG_CPU >> bool "Support for hot-pluggable CPUs" > > Same here. >
On Tue, Jan 16, 2024 at 03:10:26PM +0800, Kefeng Wang wrote: > On 2024/1/15 23:39, Russell King (Oracle) wrote: > > On Thu, Dec 14, 2023 at 04:05:56PM -0800, Christoph Lameter (Ampere) wrote: > > > Index: linux/arch/arm64/Kconfig > > > =================================================================== > > > --- linux.orig/arch/arm64/Kconfig > > > +++ linux/arch/arm64/Kconfig > > > @@ -1407,7 +1407,21 @@ config SCHED_SMT > > > config NR_CPUS > > > int "Maximum number of CPUs (2-4096)" > > > range 2 4096 > > > > I think your mailer got to your patch and messed up the white space. > > There are two spaces before each of these lines rather than the usual > > one. > > > > > - default "256" > > > + default 512 > > > + > > > +# > > > +# Determines the placement of cpumasks. > > > +# > > > +# With CPUMASK_OFFSTACK the cpumasks are dynamically allocated. > > > +# Useful for machines with lots of core because it avoids increasing > > > +# the size of many of the data structures in the kernel. > > > +# > > > +# If this is off then the cpumasks have a static sizes and are > > > +# embedded within data structures. > > > +# > > > +config CPUMASK_OFFSTACK > > > + def_bool y > > > + depends on NR_CPUS > 256 > > > > Should that be ">= 256" ? > > Maybe just select CPUMASK_OFFSTACK if NR_CPUS >= 256, > > > But could we just make CPUMASK_OFFSTACK configurable and let user/distro > to enable it? > > diff --git a/lib/Kconfig b/lib/Kconfig > index 5ddda7c2ed9b..4254be5aa843 100644 > --- a/lib/Kconfig > +++ b/lib/Kconfig > @@ -535,7 +535,9 @@ config CHECK_SIGNATURE > bool > > config CPUMASK_OFFSTACK > - bool "Force CPU masks off stack" if DEBUG_PER_CPU_MAPS > + bool "Force CPU masks off stack" > + depends on SMP > + default n Please. No. There is no point in defining a default of n. The default default is n. Therefore, specifying a default of n is utterly redundant as the option will still default to n and just adds clutter to Kconfig files.
On Mon, Jan 15, 2024 at 03:59:11PM -0800, Eric Mackay wrote: > Whitespace issues aside, I have applied the patch on top of kernel 6.1.55 and tested on both a dual-socket Ampere Altra machine with < 256 CPUs, and a dual-socket AmpereOne machine with > 256 CPUs. Works as expected, with all CPUs visible and functional. > > > config NR_CPUS > > int "Maximum number of CPUs (2-4096)" > > range 2 4096 > > - default "256" > > + default 512 > > Nit: the new default value should be in quotation marks, if we want to be pedantic I can't find anything that requires the quotes - and as "range" doesn't for consistency it seems that default shouldn't either. There's nothing in the documentation that indicates quotes should be used, and looking at the code, it's just treated as a string. The only thing that quotes seem to do is to ensure that whitespace will be included.
On Mon, Jan 15, 2024 at 03:39:00PM +0000, Russell King (Oracle) wrote: > On Thu, Dec 14, 2023 at 04:05:56PM -0800, Christoph Lameter (Ampere) wrote: > > +# Determines the placement of cpumasks. > > +# > > +# With CPUMASK_OFFSTACK the cpumasks are dynamically allocated. > > +# Useful for machines with lots of core because it avoids increasing > > +# the size of many of the data structures in the kernel. > > +# > > +# If this is off then the cpumasks have a static sizes and are > > +# embedded within data structures. > > +# > > +config CPUMASK_OFFSTACK > > + def_bool y > > + depends on NR_CPUS > 256 > > Should that be ">= 256" ? I don't think that ">= 256" makes sense. Note that since the cpumasks are arrays of unsigned long, they're chunked into groups of 64 bits: 2 to 64 cpus: 1 x unsigned long => 8 bytes 65 to 128 cpus: 2 x unsigned long => 16 bytes 129 to 192 cpus: 3 x unsigned long => 24 bytes 193 to 256 cpus: 4 x unsigned long => 32 bytes 257 to 320 cpus: 5 x unsigned long => 40 bytes .. and so if a mask for 256 CPUs is too big to go in the stack, so is any mask for 193+ CPUs, and so ">= 256" should be clamped down to ">= 193" or "> 192". The boundary should be just after a multiple of 64. How did we choose 256 specifically? I note that x86-64 allows 512 CPUs before requiring CPUMASK_OFFSTACK, and I see that powerpc selects CPUMASK_OFFSTACK when NR_CPUS >= 8192. Mark.
On Tue, Jan 16, 2024 1:08:20PM +0000, Mark Rutland wrote: > On Mon, Jan 15, 2024 at 03:39:00PM +0000, Russell King (Oracle) wrote: > > On Thu, Dec 14, 2023 at 04:05:56PM -0800, Christoph Lameter (Ampere) wrote: > > > +# Determines the placement of cpumasks. > > > +# > > > +# With CPUMASK_OFFSTACK the cpumasks are dynamically allocated. > > > +# Useful for machines with lots of core because it avoids increasing > > > +# the size of many of the data structures in the kernel. > > > +# > > > +# If this is off then the cpumasks have a static sizes and are > > > +# embedded within data structures. > > > +# > > > +config CPUMASK_OFFSTACK > > > + def_bool y > > > + depends on NR_CPUS > 256 > > > > Should that be ">= 256" ? > > I don't think that ">= 256" makes sense. Note that since the cpumasks are > arrays of unsigned long, they're chunked into groups of 64 bits: > > 2 to 64 cpus: 1 x unsigned long => 8 bytes > 65 to 128 cpus: 2 x unsigned long => 16 bytes > 129 to 192 cpus: 3 x unsigned long => 24 bytes > 193 to 256 cpus: 4 x unsigned long => 32 bytes > 257 to 320 cpus: 5 x unsigned long => 40 bytes > > ... and so if a mask for 256 CPUs is too big to go in the stack, so is any mask > for 193+ CPUs, and so ">= 256" should be clamped down to ">= 193" or "> 192". > The boundary should be just after a multiple of 64. > > How did we choose 256 specifically? I note that x86-64 allows 512 CPUs before > requiring CPUMASK_OFFSTACK, and I see that powerpc selects CPUMASK_OFFSTACK > when NR_CPUS >= 8192. > > Mark. The suggestion for >= 256 may have been a zero-index/one-index mixup. It seems > 256 was chosen as the cutoff simply because it preserves existing behavior. The patch description seems to imply there was pushback from distro maintainers on just increasing the default NR_CPUS. The existing default value of 256 is probably already a strain for smaller ARM systems, to which x86-64 isn't a reasonable comparison. I'm not sure what the reaction to increasing from 64 to 256 in 2019 was like, but picking a pivot point for CPUMASK_OFFSTACK beyond 256 may skew the balance even less in favor of smaller ARM systems.
On Tue, Jan 16, 2024 11:24:18PM +0000, Russell King (Oracle) wrote: > On Mon, Jan 15, 2024 at 03:59:11PM -0800, Eric Mackay wrote: > > Whitespace issues aside, I have applied the patch on top of kernel 6.1.55 and tested on both a dual-socket Ampere Altra machine with < 256 CPUs, and a dual-socket AmpereOne machine with > 256 CPUs. Works as expected, with all CPUs visible and functional. > > > > > config NR_CPUS > > > int "Maximum number of CPUs (2-4096)" > > > range 2 4096 > > > - default "256" > > > + default 512 > > > > Nit: the new default value should be in quotation marks, if we want to be pedantic > > I can't find anything that requires the quotes - and as "range" doesn't > for consistency it seems that default shouldn't either. There's nothing > in the documentation that indicates quotes should be used, and looking > at the code, it's just treated as a string. The only thing that quotes > seem to do is to ensure that whitespace will be included. > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! Ack. I withdraw my nit.
Index: linux/arch/arm64/Kconfig =================================================================== --- linux.orig/arch/arm64/Kconfig +++ linux/arch/arm64/Kconfig @@ -1407,7 +1407,21 @@ config SCHED_SMT config NR_CPUS int "Maximum number of CPUs (2-4096)" range 2 4096 - default "256" + default 512 + +# +# Determines the placement of cpumasks. +# +# With CPUMASK_OFFSTACK the cpumasks are dynamically allocated. +# Useful for machines with lots of core because it avoids increasing +# the size of many of the data structures in the kernel. +# +# If this is off then the cpumasks have a static sizes and are +# embedded within data structures. +# +config CPUMASK_OFFSTACK + def_bool y + depends on NR_CPUS > 256 config HOTPLUG_CPU bool "Support for hot-pluggable CPUs"