From: Andrew Jones <andrew.jones@linux.dev>
To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org,
linux-s390@vger.kernel.org
Cc: pbonzini@redhat.com, thuth@redhat.com, lvivier@redhat.com,
frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com,
atishp@rivosinc.com, cade.richard@berkeley.edu,
jamestiotio@gmail.com
Subject: [kvm-unit-tests PATCH 2/2] riscv: Make NR_CPUS configurable
Date: Tue, 3 Sep 2024 16:39:49 +0200 [thread overview]
Message-ID: <20240903143946.834864-6-andrew.jones@linux.dev> (raw)
In-Reply-To: <20240903143946.834864-4-andrew.jones@linux.dev>
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.
To override the default for NR_CPUS to, e.g. 256, testers should use
--add-config. For example,
$ cat <<EOF > 256.config
#undef CONFIG_NR_CPUS
#define CONFIG_NR_CPUS 256
EOF
$ ./configure --arch=riscv64 --cross-prefix=riscv64-linux-gnu- --add-config=256.config
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
configure | 3 ++-
lib/riscv/asm/setup.h | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 7a1317d0650d..5ed0c28fcaea 100755
--- a/configure
+++ b/configure
@@ -508,7 +508,8 @@ EOF
elif [ "$arch" = "riscv32" ] || [ "$arch" = "riscv64" ]; then
cat <<EOF >> lib/config.h
-#define CONFIG_UART_EARLY_BASE 0x10000000
+#define CONFIG_NR_CPUS (__riscv_xlen * 2)
+#define CONFIG_UART_EARLY_BASE 0x10000000
EOF
fi
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.46.0
prev parent reply other threads:[~2024-09-03 21:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 14:39 [kvm-unit-tests PATCH 0/2] configure: Support CONFIG_* extension Andrew Jones
2024-09-03 14:39 ` [kvm-unit-tests PATCH 1/2] configure: Introduce add-config Andrew Jones
2024-09-11 0:39 ` Nicholas Piggin
2024-09-11 8:15 ` Andrew Jones
2024-09-03 14:39 ` 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=20240903143946.834864-6-andrew.jones@linux.dev \
--to=andrew.jones@linux.dev \
--cc=atishp@rivosinc.com \
--cc=cade.richard@berkeley.edu \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=jamestiotio@gmail.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lvivier@redhat.com \
--cc=nrb@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=thuth@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).