From patchwork Tue Feb 20 09:50:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurabh Singh Sengar X-Patchwork-Id: 203532 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp297110dyc; Tue, 20 Feb 2024 02:03:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXx/xhWj7Vuh2AUXcb6CEyLudQWIqmkq2CDECl6if5agAXILAZxbSJh90GTtY7B+MuN9TUo1RDuxUGV8S0r+FJAmNNLVA== X-Google-Smtp-Source: AGHT+IEBzdpV6ep+P3tBCXVCDtKJOsNy1tZejEO0YtAz88Do2fSpoXHGSQ0v0As3/QuNZdd6K29W X-Received: by 2002:a17:907:9483:b0:a3e:a383:3581 with SMTP id dm3-20020a170907948300b00a3ea3833581mr5669112ejc.24.1708423428696; Tue, 20 Feb 2024 02:03:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708423428; cv=pass; d=google.com; s=arc-20160816; b=p9RM/2WM6BA0cfzpH4l69FBBairSbnCG06c3a6xyuaGENxzzc86LwLSFM4vC/AVuSw jYLcVPNLEgNDAyqHdMq3SF7QEjj3ymMmDkGR73doJQc600Zu28EFmAL3B1tcBPh3qbUR +vkT28evUSKdL++us/JrG02OvNwD/z1RBcUIFFoJM1ez6MMoTVU7xvM/cZRsVU8yQdP1 DKG2gdR7zOgw6vy0XWqlP1cPepVjt062q95+qmP30tbNxWa2pEre4p4aJPGN5z7eFlXO z2UiZ3aoUh+x0to9iteXHNnK6Hj6fX1wa9QJKqDwsim6DWZubN0EEChJKp1d7yYOH8oP hMhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=3W4h4uwYh9kgjiCp95bdEHo8yCZlRGw0RiGys4AyqXo=; fh=E6fFfR0xPc/CpRpEEvWfruvhPDsQ7m8C+BwwUIghvEA=; b=D/ENpwJJ1ECxSnxO6kCR8hoovfWqrlK3+bgQInWO6IPHIjDAd5nBY2xbs6Rlq7g8Kn 3uE+iCMOO9kSXtBYRMtA+Glp4ARa+BcRMS8KyUPxh/fCs0bxBcKbV4yQ9Uab83MEln7m sqCOxVdUBTUWF5j5fLBcyGS7qVTY8z9Hf2Pfk1HjVyhIpNUTw8lp3JoUiLqpYquB+ne9 7bURlqLWZBAsbQ0yhWKG3cjTUKdkaUzzcPZz3ki2vrvsfQhwGp3eL0w37okE0VZMrZlZ ioDmiRWFzReOfXynSLKzk1ieusWfgZsV5vnRotTKBAvMvtjf+wA1jpUUkNAsD7hPoOp1 FzOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="gOlGqt/D"; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-72741-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72741-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dx23-20020a170906a85700b00a3e98ee43c1si1712649ejb.796.2024.02.20.02.03.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 02:03:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72741-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="gOlGqt/D"; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-72741-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72741-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1FF091F269A6 for ; Tue, 20 Feb 2024 09:52:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC1C461667; Tue, 20 Feb 2024 09:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="gOlGqt/D" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA1C660244 for ; Tue, 20 Feb 2024 09:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708422619; cv=none; b=UwBS/Qo3a43UMrKkTi+H+qLBxEhqkdevZvTSqK2qZ/hX8oOYa9Qjg/03JVfFOQW4nTaITm9i6YioZhLpKa7J9FWTbFz/5lbRRMkBTdB+WkKuOb5vCLO59LiYLV6+WAqMv54W9D1jz5SbbaDdi/Vsg4RW/QUx1fKijz0cRl2Sc/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708422619; c=relaxed/simple; bh=Pc+2+/vicu8XiIRtXQihQ0eQ9Yu0XvrHSeD0RBFf9Ek=; h=From:To:Cc:Subject:Date:Message-Id; b=ZUmKujevcrwFxJTHKzACt4TtKED/Kokze0BJC/10gQ6jW8DF5dilwYF8Q6zv8ogDhivPPt6Pf1k5F0glqyC8q1f4R1ZezeE2vE4AQR/5FRE+PRj5gP05OWyi4u76cmWwIXcZVNGuN2UhJNgn6zzJMxnLkjAIE9aI/j4WYGYMY00= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=gOlGqt/D; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 63C19208360E; Tue, 20 Feb 2024 01:50:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 63C19208360E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1708422617; bh=3W4h4uwYh9kgjiCp95bdEHo8yCZlRGw0RiGys4AyqXo=; h=From:To:Cc:Subject:Date:From; b=gOlGqt/DvMESbE+KajpygWnefeYTuLU3APOtS4/x8x6PWyxUL7euqP9YtK4kavAR/ 2Sin1jD6nfypTzdJNfel2jtZBnbi0TUAL0e4WiBAOrAECsewVwJHpMK23LWNah4E7B AwAdH9ZPdyc+AIsd3yCIjyH48jBHCK4KiTdiS+Sk= From: Saurabh Sengar 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 Message-Id: <1708422613-15714-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791411805587644657 X-GMAIL-MSGID: 1791411805587644657 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 --- 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