Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1236815pxb; Sat, 23 Apr 2022 00:32:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ0fCIHOh7CAi+XgIdBKiV5AHTD5MNPie4m8lhUvWrcsId7BP49lCx7Gpac64Vgw9CmS3W X-Received: by 2002:a17:907:ea9:b0:6f3:6af6:d21e with SMTP id ho41-20020a1709070ea900b006f36af6d21emr3372501ejc.409.1650699144339; Sat, 23 Apr 2022 00:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650699144; cv=none; d=google.com; s=arc-20160816; b=L7Xse0pB1avAK55PDTWQLTadKG8y79smasbMMgKeQ8CeTjay35MCBCC6JItC7ppdOj 1s2ovd6SfOVm9MEe1q2iappIn6i5unl3cwgBAJJ4ay541WN1qv+MQlB+XOh81IS+Xy7+ sIUKWk8w05V8U78wGHixX4N+52khf+qeoDc9OSZCFvspZ5ELfpzBPZT5mxFOP+P6KRcP F/t0Suj8TQb/JH6FszMHV1ADUkcJtPswlCbPmAZywcfD+WA+Xvsww0gBUgmKwV9WSaJI mwKGJ/eZaf0sIxc99eZvJ9TlluEhcuUjLj2Kl5l+HFFgyBGr1I1KGnyn/eZK8XbCvlCQ AgmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=sbU8RRqvuKwLWG8J3BfpPsUyUgY2ByjD6sNT/NW9Qas=; b=JOwQBS5wTJADcyP9l5vWaZifpJ3GZ1uyp5tHtNZQ6X5Obyl264Gn0hvlic2d3qzwAO OZRxKN/Q3AiU+oF12umlCg1+WFkqShC93lL8ENrp59TAhEFTJpIftZr384myci0uWh+h LMpLRpT0KBx/jZ0ki4mDmBjBpr3rQka0Xo4SzvNEWRXLDfsRl8ovxIAbYz2IMKOMay2D 1f2e+qHC6Wb0vwyH2vEovyzzLxTJrEsrNHt6D/9+N3AwZrCyyCPc6GvCNpNDSzsYbB0w tMJDKfR/Yq3fZucxDyayQcDmX9Zsx7XGVpe0ZEaUKo5dBnxlkW8C6xsOiOk83Eaq2ajk mtBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=B6wZBHSz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb6-20020a0564020d0600b0041f7893ca86si9697015edb.509.2022.04.23.00.31.57; Sat, 23 Apr 2022 00:32:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=B6wZBHSz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233348AbiDWFYk (ORCPT + 99 others); Sat, 23 Apr 2022 01:24:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233372AbiDWFYh (ORCPT ); Sat, 23 Apr 2022 01:24:37 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E78F5A584 for ; Fri, 22 Apr 2022 22:21:40 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id v64-20020a1cac43000000b0038cfd1b3a6dso9217660wme.5 for ; Fri, 22 Apr 2022 22:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=sbU8RRqvuKwLWG8J3BfpPsUyUgY2ByjD6sNT/NW9Qas=; b=B6wZBHSzUPdCcDLRt1WF1wSVUZ6IaPZJKGzRkGxcMgrYRTCyx7oSwk7DfdsA3pIH0/ 3L/eQ8eCefAuJK0ZDUAcwKkxBObXj+j74XX2+U401kaeQ8NEUVwctEUF0ORbQx01jUtF lWQ+vcl0M/AV6JkP/osjzHeMq8XbkJX5EMKF0NUF4yrSw+6jnZbRZ090GCI3c0teQ1pW sp8FdQOPq969THiLOqq0bUDuzvxKY5guY3vvvPNRUzi1QBR+2pfwyt/kAvH9k0BZjNwO 9qoFuOcNsY9/WEXcJwGkVg9bb9iW458LYRNr4pr9LIhMCmUeBudX6sG/Kphcpldtz6hY rsrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=sbU8RRqvuKwLWG8J3BfpPsUyUgY2ByjD6sNT/NW9Qas=; b=S7bZ0U/Bj2ZuycypDNVcG9XRNwWUaBK+Dhx8BMIIpeiITVWf698YDaXEhIKjR032sh g64WP6YEK/fBClUoMeu13/u46/WroC2LmEDuh/xJLwZQDxbiHgVEbsQSxNWb8aC2Vtb+ Gwd2wvIz+5VhffV3dZnn9ghZXWXFxSJK6YPFjRPtrKfQhR1jxigyPTf/dTdrWeM2w/Dn yCs1oKJQdBZA6yz/L+KPE5zFVQzELdhrSAVnje5KlWz04HUMxV5R+0yKAq7egcZBj7Se G9rUT1REkuZj5KCWptgynGjExx9S+Hp4XnnRrMDai8fPZOP3FRe75IWGRzUyxtIAsMLd FQ3Q== X-Gm-Message-State: AOAM531owkdaVEdsbkjmyg81iVWMyRkJMWKJyCp8GLb8vCpPE8qoZFb2 YfMOhRB1JfxUY5RKsG94WKqtp405TeNT2h0XeLtNuQ== X-Received: by 2002:a05:600c:1d15:b0:393:e534:eb93 with SMTP id l21-20020a05600c1d1500b00393e534eb93mr816388wms.137.1650691298392; Fri, 22 Apr 2022 22:21:38 -0700 (PDT) MIME-Version: 1.0 References: <20220420112408.155561-1-apatel@ventanamicro.com> <3fa5215b-84c3-5e4c-cb53-6c05d05e4350@canonical.com> In-Reply-To: From: Anup Patel Date: Sat, 23 Apr 2022 10:51:26 +0530 Message-ID: Subject: Re: [PATCH v3] RISC-V: Increase range and default value of NR_CPUS To: Atish Patra Cc: Heinrich Schuchardt , Anup Patel , Palmer Dabbelt , Paul Walmsley , Arnd Bergmann , Alistair Francis , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Alistair On Sat, Apr 23, 2022 at 7:19 AM Atish Patra wrote: > > On Fri, Apr 22, 2022 at 5:16 PM Atish Patra wrote= : > > > > On Thu, Apr 21, 2022 at 12:05 AM Heinrich Schuchardt > > wrote: > > > > > > > > > > > > On 4/20/22 13:24, Anup Patel wrote: > > > > Currently, the range and default value of NR_CPUS is too restrictiv= e > > > > for high-end RISC-V systems with large number of HARTs. The latest > > > > QEMU virt machine supports upto 512 CPUs so the current NR_CPUS is > > > > restrictive for QEMU as well. Other major architectures (such as > > > > ARM64, x86_64, MIPS, etc) have a much higher range and default > > > > value of NR_CPUS. > > > > > > > > This patch increases NR_CPUS range to 2-512 and default value to > > > > XLEN (i.e. 32 for RV32 and 64 for RV64). > > > > > > > > Signed-off-by: Anup Patel > > > > > > > This works upto 207 harts in upstream Qemu + OpenSBI. Beyond that, > > firmware size becomes > 2MB and PMP protection > > kicks in for the kernel boot address (0x80200000) > > > > Just wanted to clarify that this is as per the current configuration > in OpenSBI. The boot address > is configured to be 0x80000000 for the generic platform. Thus, it can > support a maximum of 207 harts. > > If anybody wishes to boot more than that, the boot address should be > changed to a valid DRAM address such that > it doesn't step on kernel/DT or other resident boot loaders (e.g. U-Boot)= . > > It should be changed per platform (if supporting more than 128 harts) > rather than changing > to a common address for all platforms. The OpenSBI limit of 128 harts was carefully chosen considering the fact that QEMU by default loads OpenSBI at start of DRAM and kernel at 2M (for RV64) or 4M (for RV32) offset. This means for RV64 if OpenSBI is loaded at the start of DRAM then we only have 2M space for OpenSBI hence the 128 harts limit. To use more than 128 harts with OpenSBI, we will have to load it somewhere else (probably in the middle of DRAM) but this will be a platform specific choice. If a separate LOADER booting stage (e.g. U-Boot SPL) is available on a platform then it can load OpenSBI at desired platform specific location. Overall, this is indeed a platform configuration issue. We will continue to optimize OpenSBI to support more harts with less RAM usage but this is a separate topic. Regards, Anup > > > Here is the OpenSBI boot prints for 256 harts with some hacks around > > sanitize_domain to disable sbi_domain_check_addr > > > > Platform Name : riscv-virtio,qemu > > Platform Features : medeleg > > Platform HART Count : 208 > > Platform IPI Device : aclint-mswi > > Platform Timer Device : aclint-mtimer @ 10000000Hz > > Platform Console Device : uart8250 > > Platform HSM Device : --- > > Platform Reboot Device : sifive_test > > Platform Shutdown Device : sifive_test > > Firmware Base : 0x80000000 > > Firmware Size : 2052 KB ---------->>> Firmware size is > > greater than 2MB where > > Runtime SBI Version : 0.3 > > > > Domain0 Name : root > > Domain0 Boot HART : 122 > > Domain0 HARTs : > > 0*,1*,2*,3*,4*,5*,6*,7*,8*,9*,10*,11*,12*,13*,14*,15*,16*,17*,18*,19*,2= 0*,21*,22*,23*,24*,25*,26*,27*,28*,29*,30*,31*,32*,33*,34*,35*,36*,37*,38*,= 39*,40*,41*,42*,43*,44*,45*,46*,47*,48*,49*,50*,51*,52*,53*,54*,55*,56*,57*= ,58*,59*,60*,61*,62*,63*,64*,65*,66*,67*,68*,69*,70*,71*,72*,73*,74*,75*,76= *,77*,78*,79*,80*,81*,82*,83*,84*,85*,86*,87*,88*,89*,90*,91*,92*,93*,94*,9= 5*,96*,97*,98*,99*,100*,101*,102*,103*,104*,105*,106*,107*,108*,109*,110*,1= 11*,112*,113*,114*,115*,116*,117*,118*,119*,120*,121*,122*,123*,124*,125*,1= 26*,127*,128*,129*,130*,131*,132*,133*,134*,135*,136*,137*,138*,139*,140*,1= 41*,142*,143*,144*,145*,146*,147*,148*,149*,150*,151*,152*,153*,154*,155*,1= 56*,157*,158*,159*,160*,161*,162*,163*,164*,165*,166*,167*,168*,169*,170*,1= 71*,172*,173*,174*,175*,176*,177*,178*,179*,180*,181*,182*,183*,184*,185*,1= 86*,187*,188*,189*,190*,191*,192*,193*,194*,195*,196*,197*,198*,199*,200*,2= 01*,202*,203*,204*,205*,206*,207* > > Domain0 Region00 : 0x0000000002000000-0x000000000200ffff (I) > > Domain0 Region01 : 0x0000000080000000-0x00000000803fffff () > > Domain0 Region02 : 0x0000000000000000-0xffffffffffffffff (R,W,= X) > > Domain0 Next Address : 0x0000000080200000 > > Domain0 Next Arg1 : 0x00000000bf000000 > > Domain0 Next Mode : S-mode > > Domain0 SysReset : yes > > > > Boot HART ID : 122 > > Boot HART Domain : root > > Boot HART ISA : rv64imafdcsuh > > Boot HART Features : scounteren,mcounteren,time > > Boot HART PMP Count : 16 > > Boot HART PMP Granularity : 4 > > Boot HART PMP Address Bits: 54 > > Boot HART MHPM Count : 0 > > Boot HART MIDELEG : 0x0000000000001666 > > Boot HART MEDELEG : 0x0000000000f0b509 > > > > > > > Reviewed-by: Heinrich Schuchardt > > > > > > > --- > > > > Changes since v2: > > > > - Rebased on Linux-5.18-rc3 > > > > - Use a different range when SBI v0.1 is enabled > > > > Changes since v1: > > > > - Updated NR_CPUS range to 2-512 which reflects maximum number of > > > > CPUs supported by QEMU virt machine. > > > > --- > > > > arch/riscv/Kconfig | 9 ++++++--- > > > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > > > index 00fd9c548f26..1823f281069f 100644 > > > > --- a/arch/riscv/Kconfig > > > > +++ b/arch/riscv/Kconfig > > > > @@ -275,10 +275,13 @@ config SMP > > > > If you don't know what to do here, say N. > > > > > > > > config NR_CPUS > > > > - int "Maximum number of CPUs (2-32)" > > > > - range 2 32 > > > > + int "Maximum number of CPUs (2-512)" > > > > depends on SMP > > > > - default "8" > > > > + range 2 512 if !SBI_V01 > > > > + range 2 32 if SBI_V01 && 32BIT > > > > + range 2 64 if SBI_V01 && 64BIT > > > > + default "32" if 32BIT > > > > + default "64" if 64BIT > > > > > > > > config HOTPLUG_CPU > > > > bool "Support for hot-pluggable CPUs" > > > > > > > > -- > > Regards, > > Atish > > > > -- > Regards, > Atish