From patchwork Thu Mar 7 01:45:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christoph Lameter (Ampere)" X-Patchwork-Id: 13584962 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B6C1C54E41 for ; Thu, 7 Mar 2024 01:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=QCbEuM+IVlPb2LLzD3GhGzyNw0eWpHVQ+ZiSxbvoNQ8=; b=3xD+PBq3cBc2G4AbvFDbtvsn+e wU4ToLLc9OaLq5NTGp9s/auLemj3CcJGoEyc7xH6BKhMdgmbO1az23DXiCMHhXGpCb8fxl5LHH97z UA8bxyUJv2pdQIMQj7QoYM8wOZKKXD92AjYL1hMyTtJKg/nw6nEKLDj5HeaYRUULOg6f+GAXWI8Iq egESB/EdP+okFfmm5WIxoveNvA0sfymtrisnch8iuLzCb6xZs9T3yGuV9IQvcRavIlt3uXINbI4xZ 9VJsx7Q6wMbewJAcwQkNbEEqg96Ax99YNl56oxpqjZj871R3D9zvTLTraLdFKIyKUG8FQL046VO/5 QB5uKISg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri2on-00000002YqR-2VCD; Thu, 07 Mar 2024 01:45:09 +0000 Received: from gentwo.org ([62.72.0.81]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri2oj-00000002Ypt-3OJU for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2024 01:45:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gentwo.org; s=default; t=1709775904; bh=aWSwUSkgwGQnBYXx/O6wZsg2pJVaxfIK5ZiFu+4pJiM=; h=Date:From:To:cc:Subject:From; b=WRye+pJLR+trpFSDcZ4fJaP+w34FsxMv4jhCYGzeYBguKZj9sMfw4npzfW5R8+vbt ff+pUuLlIOGn02EhmiXQ/u/sL3lpx97bT45tNjeYLGkTxKv82V2Fi3kqErb/hndxF7 y0tOM0LoYWspgM4XpLviFf82ReGKWy1xgMrmBwo0Zy7BTuYlBCEE1s9lYLQHBu4CnW 6E/qupm8E4VN91Y2UBGfOPzeaNqBECudKuo8XTFINnJoaWInraLbRvhJpxZViYel7V hc73NxJOs8nsNGoBxUHjubsZl13uOqQk0ncgN3THtki13nDyjrWfsGMGEv6Qmezpy1 sd3LWJ9sjRWYQ== Received: by gentwo.org (Postfix, from userid 1003) id 3501440A94; Wed, 6 Mar 2024 17:45:04 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id 30B1240789; Wed, 6 Mar 2024 17:45:04 -0800 (PST) Date: Wed, 6 Mar 2024 17:45:04 -0800 (PST) From: "Christoph Lameter (Ampere)" To: Mark Rutland cc: catalin.marinas@arm.com, Will Deacon , Jonathan.Cameron@huawei.com, Matteo.Carlini@arm.com, Valentin.Schneider@arm.com, akpm@linux-foundation.org, anshuman.khandual@arm.com, Eric Mackay , dave.kleikamp@oracle.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux@armlinux.org.uk, robin.murphy@arm.com, vanshikonda@os.amperecomputing.com, yang@os.amperecomputing.com Subject: [PATCH v3] ARM64: Dynamically allocate cpumasks and increase supported CPUs to 512 Message-ID: <37099a57-b655-3b3a-56d0-5f7fbd49d7db@gentwo.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240306_174505_907812_F6AA8041 X-CRM114-Status: GOOD ( 17.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently defconfig selects NR_CPUS=256, but some vendors (e.g. Ampere Computing) are planning to ship systems with 512 CPUs. So that all CPUs on these systems can be used with defconfig, we'd like to bump NR_CPUS to 512. Therefore this patch increases the default NR_CPUS from 256 to 512. As increasing NR_CPUS will increase the size of cpumasks, there's a fear that this might have a significant impact on stack usage due to code which places cpumasks on the stack. To mitigate that concern, we can select CPUMASK_OFFSTACK. As that doesn't seem to be a problem today with NR_CPUS=256, we only select this when NR_CPUS > 256. CPUMASK_OFFSTACK 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. Memory used for cpumasks will increase if the kernel is run on a machine with more cores. 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. There are minor regressions for hackbench. The kernel data size for 512 cpus is smaller with offstack than with onstack. Benchmark results using hackbench average over 10 runs of hackbench -s 512 -l 2000 -g 15 -f 25 -P on Altra 80 Core Support for 256 CPUs on stack. Baseline 7.8564 sec Support for 512 CUs on stack. 7.8713 sec + 0.18% 512 CPUS offstack 7.8916 sec + 0.44% Kernel size comparison: text data filename Difference to onstack256 baseline 25755648 9589248 vmlinuz-6.8.0-rc4-onstack256 25755648 9607680 vmlinuz-6.8.0-rc4-onstack512 +0.19% 25755648 9603584 vmlinuz-6.8.0-rc4-offstack512 +0.14% Tested-by: Eric Mackay Reviewed-by: Russell King (Oracle) Signed-off-by: Christoph Lameter (Ampere) Acked-by: Mark Rutland --- Original post: https://www.spinics.net/lists/linux-mm/msg369701.html V2: https://lkml.org/lkml/2024/2/7/505 V1->V2 - Keep quotation marks - Remove whiltespace damage - Add tested by V2->V3: - Add test results - Rework descriptions arch/arm64/Kconfig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index aa7c1d435139..4e767dede47d 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1427,7 +1427,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"