From patchwork Tue Nov 21 01:04:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christoph Lameter (Ampere)" X-Patchwork-Id: 13462380 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 8E9FBC61D85 for ; Tue, 21 Nov 2023 01:05:12 +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=MdNRF7bVDpO9T1JmbBPhfZcuKHEl5tpzYhRIK7RA2p8=; b=Rq7cucxIZk3qfSgRdkSKStVF8I HfBaIWHGdUGNPvlNvF2I+8GHyg0JoPNlqMOlXjMXGGFPXJTTOiFZdYspGGTq0Q3GihimWyVt74NM+ hvM4/n3NJ2TgGARWmiABYfKsdI15GziEofFBuIGex7FSFNfQ+IB1l/yJYiWlUF0WwbHPxBXn0sbs0 oWWNyLcHQL49LiIVeofI0MFrkm0kFMFGagNALIcw7Q68b/pqCSj5gxo2QdjyCIKDj1+FVPJYHp0U+ 5fwg981tv6gTd591/gxzdbM+pWjt9d5VcpKIvt9wpv11BFj7yUzMZC6tKfxo5grMp31nAuCxBaC0N 6Rdncp+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5FBx-00FIBE-1u; Tue, 21 Nov 2023 01:04:41 +0000 Received: from gentwo.org ([62.72.0.81]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5FBv-00FI9Y-0E for linux-arm-kernel@lists.infradead.org; Tue, 21 Nov 2023 01:04:40 +0000 Received: by gentwo.org (Postfix, from userid 1003) id 8C6B648F42; Mon, 20 Nov 2023 17:04:35 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id 8B98E48F40; Mon, 20 Nov 2023 17:04:35 -0800 (PST) Date: Mon, 20 Nov 2023 17:04:35 -0800 (PST) From: "Christoph Lameter (Ampere)" To: linux-arm-kernel@lists.infradead.org cc: linux-kernel@vger.kernel.org, Anshuman.Khandual@arm.com, Valentin.Schneider@arm.com, Vanshidhar Konda , Jonathan Cameron , Catalin Marinas , Robin Murphy , Dave Kleikamp , Matteo Carlini Subject: [PATCH ARM64]: Introduce CONFIG_MAXSMP to allow up to 512 cpus Message-ID: <6a854175-5f89-c754-17b8-deda18447f1f@gentwo.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231120_170439_146505_29E1C0B3 X-CRM114-Status: GOOD ( 14.41 ) 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 Ampere Computing develops high end ARM processors that support an ever increasing number of processors. The current default of 256 processors is not enough for our newer products. The default is used by Linux distros and therefore our customers cannot use distro kernels because the number of processors is not supported. The x86 arch has support for a "CONFIG_MAXSMP" configuration option that enables support for the largest known configurations. This usually means hundreds or thousands of processors. For those sizes it is no longer practical to allocate bitmaps of cpus on the kernel stack. There is a kernel option CONFIG_CPUMASK_OFFSTACK that makes the kernel allocate and free bitmaps for cpu masks from slab memory instead of keeping it on the stack etc. With that is becomes possible to dynamically size the allocation of the bitmap depending on the quantity of processors detected on bootup. This patch enables that logic if CONFIG_MAXSMP is enabled. If CONFIG_MAXSMP is disabled then a default of 64 processors is supported. A bitmap for 64 processors fits into one word and therefore can be efficiently handled on the stack. Using a pointer to a bitmap would be overkill. The number of processors can be manually configured if CONFIG_MAXSMP is not set. Currently the default for CONFIG_MAXSMP is 512 processors. This will have to be increased if ARM processor vendors start supporting more processors. Signed-off-by: Christoph Lameter (Ampere) --- NR_CPU limits on ARM64 were discussed before at https://lore.kernel.org/all/20210110053615.3594358-1-vanshikonda@os.amperecomputing.com/ Index: linux/arch/arm64/Kconfig =================================================================== --- linux.orig/arch/arm64/Kconfig +++ linux/arch/arm64/Kconfig @@ -1402,10 +1402,56 @@ config SCHED_SMT MultiThreading at a cost of slightly increased overhead in some places. If unsure say N here. + +config MAXSMP + bool "Compile kernel with support for the maximum number of SMP Processors" + depends on SMP && DEBUG_KERNEL + select CPUMASK_OFFSTACK + help + Enable maximum number of CPUS and NUMA Nodes for this architecture. + If unsure, say N. + +# +# The maximum number of CPUs supported: +# +# The main config value is NR_CPUS, which defaults to NR_CPUS_DEFAULT, +# and which can be configured interactively in the +# [NR_CPUS_RANGE_BEGIN ... NR_CPUS_RANGE_END] range. +# +# ( If MAXSMP is enabled we just use the highest possible value and disable +# interactive configuration. ) +# + +config NR_CPUS_RANGE_BEGIN + int + default NR_CPUS_RANGE_END if MAXSMP + default 1 if !SMP + default 2 + +config NR_CPUS_RANGE_END + int + default 8192 if SMP && CPUMASK_OFFSTACK + default 512 if SMP && !CPUMASK_OFFSTACK + default 1 if !SMP + +config NR_CPUS_DEFAULT + int + default 512 if MAXSMP + default 64 if SMP + default 1 if !SMP + config NR_CPUS - int "Maximum number of CPUs (2-4096)" - range 2 4096 - default "256" + int "Set maximum number of CPUs" if SMP && !MAXSMP + range NR_CPUS_RANGE_BEGIN NR_CPUS_RANGE_END + default NR_CPUS_DEFAULT + help + This allows you to specify the maximum number of CPUs which this + kernel will support. If CPUMASK_OFFSTACK is enabled, the maximum + supported value is 8192, otherwise the maximum value is 512. The + minimum value which makes sense is 2. + + This is purely to save memory: each supported CPU adds about 8KB + to the kernel image. config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" Index: linux/arch/arm64/configs/defconfig =================================================================== --- linux.orig/arch/arm64/configs/defconfig +++ linux/arch/arm64/configs/defconfig @@ -15,6 +15,7 @@ CONFIG_TASK_IO_ACCOUNTING=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y CONFIG_NUMA_BALANCING=y +CONFIG_MAXSMP=y CONFIG_MEMCG=y CONFIG_BLK_CGROUP=y CONFIG_CGROUP_PIDS=y