From: Andrew Jones <andrew.jones@linux.dev>
To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org
Cc: atishp@rivosinc.com, cade.richard@berkeley.edu, jamestiotio@gmail.com
Subject: Re: [kvm-unit-tests PATCH] riscv: Make NR_CPUS configurable
Date: Tue, 3 Sep 2024 16:43:13 +0200 [thread overview]
Message-ID: <20240903-cb3f09205bf9cc9906e32024@orel> (raw)
In-Reply-To: <20240820170150.377580-2-andrew.jones@linux.dev>
On Tue, Aug 20, 2024 at 07:01:51PM GMT, Andrew Jones wrote:
> Unit tests would like to go nuts with the number of harts in order
> to help shake out issues with hart number assumptions. Rather than
> set a huge number that will only be used when a platform supports
> a huge number or when QEMU is told to exceed the recommended
> number of vcpus, make the number configurable. However, we do bump
> the default from 16 to 2*xlen since we would like to always force
> kvm-unit-tests to use cpumasks with more than one word in order to
> ensure that code stays maintained.
>
> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
> ---
> configure | 8 ++++++++
> lib/riscv/asm/setup.h | 3 ++-
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 27ae9cc89657..6a8d6239a3cb 100755
> --- a/configure
> +++ b/configure
> @@ -77,6 +77,8 @@ usage() {
> Specify the page size (translation granule). PAGE_SIZE can be
> 4k [default], 16k, 64k for arm64.
> 4k [default], 64k for ppc64.
> + --max-cpus=MAX_CPUS
> + Specify the maximum number of CPUs supported. (riscv64 only)
> --earlycon=EARLYCON
> Specify the UART name, type and address (optional, arm and
> arm64 only). The specified address will overwrite the UART
> @@ -168,6 +170,9 @@ while [[ "$1" = -* ]]; do
> --page-size)
> page_size="$arg"
> ;;
> + --max-cpus)
> + max_cpus="$arg"
> + ;;
> --earlycon)
> earlycon="$arg"
> ;;
> @@ -496,8 +501,11 @@ cat <<EOF >> lib/config.h
>
> EOF
> elif [ "$arch" = "riscv32" ] || [ "$arch" = "riscv64" ]; then
> + [ -z $max_cpus ] && max_cpus='(__riscv_xlen * 2)'
> +
> cat <<EOF >> lib/config.h
>
> +#define CONFIG_NR_CPUS $max_cpus
> #define CONFIG_UART_EARLY_BASE 0x10000000
>
> EOF
> diff --git a/lib/riscv/asm/setup.h b/lib/riscv/asm/setup.h
> index a13159bfe395..43b63c56d96f 100644
> --- a/lib/riscv/asm/setup.h
> +++ b/lib/riscv/asm/setup.h
> @@ -2,9 +2,10 @@
> #ifndef _ASMRISCV_SETUP_H_
> #define _ASMRISCV_SETUP_H_
> #include <libcflat.h>
> +#include <config.h>
> #include <asm/processor.h>
>
> -#define NR_CPUS 16
> +#define NR_CPUS CONFIG_NR_CPUS
> extern struct thread_info cpus[NR_CPUS];
> extern int nr_cpus;
> extern uint64_t timebase_frequency;
> --
> 2.45.2
>
I started having second thoughts about this approach since we'll have to
keep adding configure command line options for every CONFIG option. I
posted an alternative approach now [1] and CC'ed everyone since other
architectures should chime in on the approach too.
[1] https://lore.kernel.org/all/20240903143946.834864-4-andrew.jones@linux.dev/
Thanks,
drew
prev parent reply other threads:[~2024-09-03 14:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 17:01 [kvm-unit-tests PATCH] riscv: Make NR_CPUS configurable Andrew Jones
2024-09-03 14:43 ` Andrew Jones [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240903-cb3f09205bf9cc9906e32024@orel \
--to=andrew.jones@linux.dev \
--cc=atishp@rivosinc.com \
--cc=cade.richard@berkeley.edu \
--cc=jamestiotio@gmail.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox