You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/08/13 19:41:47 UTC
[incubator-nuttx] branch master updated: arch: qemu-rv: Fix high CPU usage in SMP mode
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 548540eb13 arch: qemu-rv: Fix high CPU usage in SMP mode
548540eb13 is described below
commit 548540eb13345e4cca9af7b25daae94fa6374fe2
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Sat Aug 13 22:33:52 2022 +0900
arch: qemu-rv: Fix high CPU usage in SMP mode
Summary:
- I noticed that QEMU shows high CPU usage if the number of
CPUs does not match the kernel configuration. (e.g. -smp 8
and CONFIG_SMP_NCPUS=2)
- This commit fixes this issue.
Impact:
- qemu-rv only
Testing:
- Tested with the following configs
- rv-virt:smp64 (CONFIG_NCPUS=1/2/8)
- rv-virt:nsh64
Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
arch/risc-v/src/qemu-rv/qemu_rv_head.S | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_head.S b/arch/risc-v/src/qemu-rv/qemu_rv_head.S
index ebfe5d1c68..f55ec9a30b 100644
--- a/arch/risc-v/src/qemu-rv/qemu_rv_head.S
+++ b/arch/risc-v/src/qemu-rv/qemu_rv_head.S
@@ -52,13 +52,21 @@ __start:
j 2f
1:
- /* In case of single CPU config, stop here */
+ /* Load the number of CPUs that the kernel supports */
-#if !defined(CONFIG_SMP) || (CONFIG_SMP_NCPUS == 1)
+#ifdef CONFIG_SMP
+ li t1, CONFIG_SMP_NCPUS
+#else
+ li t1, 1
+#endif
+
+ /* If a0 (mhartid) >= t1 (the number of CPUs), stop here */
+
+ blt a0, t1, 3f
csrw mie, zero
wfi
-#endif
+3:
/* To get g_cpu_basestack[mhartid], must get g_cpu_basestack first */
la t0, g_cpu_basestack