virt machine 最多只支持 smp = 8;有没有方法加大一点?
Closed this issue · 8 comments
问题是这样的:
用 QEMU RISCV64 跑 Fedora Dev Rawhide,使用的 virt ,跑回归测试,smp 开到最大 8,需要 90分钟跑完。
测试的机器是32核心的。看到后台 smp 4 的时候有4个进程,smp 8 的时候有 8 个进程。
有没有可能做到 smp 超过 8,例如 16 或者 32?
并不是必须用 virt,这是因为我只知道用这个板子。别的么有测试过,follow 的是 fedora installing riscv64 的 wiki
so 有没有可能,say,做一个 plct machine,支持 riscv64gcv ,smp 到 32?
按照建议修改了 max_cpus = 32
但是看到好像有一个
Platform Name : QEMU Virt Machine
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs : 8
Current Hart : 7
Firmware Base : 0x80000000
Firmware Size : 116 KB
Runtime SBI Version : 0.2
可能在其他地方进行了限制
qemu-system-riscv64: warning: No -bios option specified. Not loading a firmware.
qemu-system-riscv64: warning: This default will change in a future QEMU release. Please use the -bios option to avoid breakages when this happens.
qemu-system-riscv64: warning: See QEMU's deprecation documentation for details.
OpenSBI v0.5 (Nov 19 2019 00:00:00)
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : QEMU Virt Machine
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs : 8
Current Hart : 7
Firmware Base : 0x80000000
Firmware Size : 116 KB
Runtime SBI Version : 0.2
PMP0: 0x0000000080000000-0x000000008001ffff (A)
PMP1: 0x0000000000000000-0xffffffffffffffff (A,R,W,X)
在这里时间停止了(卡死了)
我用下面的方法支持linux kernel 32 smp,fedora目前还在探索中。
步骤
u-boot
$ export CROSS_COMPILE=riscv64-linux-gnu- // 设置环境变量
$ git clone https://github.com/u-boot/u-boot
$ cd u-boot
$ diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 3f221dccdb..00e4fd1df3 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -202,7 +202,7 @@ config NR_CPUS
int "Maximum number of CPUs (2-32)"
range 2 32
depends on SMP || SPL_SMP
- default 8
+ default 32 // 对u-boot做的唯一修改是这里,我把默认值由8改为32
help
On multiprocessor machines, U-Boot sets up a stack for each CPU.
Stack memory is pre-allocated. U-Boot must therefore know the
$ make menuconfig
malloc size增加到 0x2000
$ make -j12 // 编译
opensbi
$ git clone https://github.com/riscv/opensbi.git
$ cd opensbi
$ make PLATFORM=generic
linux kernel
$ git clone https://github.com/torvalds/linux
$ cd linux
$ make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- menuconfig // 我们需要用菜单去选择maxcpus
$ make -j12 // 编译
qemu
这里应该使用生成的opensbi,u-boot,linux Image地址
$ ./qemu-system-riscv64 -M virt -m 256M -smp 32 -nographic \
-bios ~/PLCT/Src/opensbi/build/platform/generic/firmware/fw_jump.elf \
-kernel ~/PLCT/Src/u-boot/u-boot.bin -device loader,file=/home/ardxwe/PLCT/Src/machine/linux/arch/riscv/boot/Image,addr=0x84000000 \
-drive file=/home/ardxwe/PLCT/Src/machine/linux/rootfs.img,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0
进入u-boot使用如下的命令就可以启动 linux kernel
$ setenv bootargs "root=/dev/vda rw console=ttyS0 earlycon=sbi"
$ cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000
$ booti ${kernel_addr_r} - ${fdt_addr_r}
查看
/ # cd sys/devices/system/
/sys/devices/system # ls
clockevents clocksource container cpu
/sys/devices/system # cd cpu
/sys/devices/system/cpu # ls
cpu0 cpu15 cpu21 cpu28 cpu6 online
cpu1 cpu16 cpu22 cpu29 cpu7 possible
cpu10 cpu17 cpu23 cpu3 cpu8 present
cpu11 cpu18 cpu24 cpu30 cpu9 uevent
cpu12 cpu19 cpu25 cpu31 isolated
cpu13 cpu2 cpu26 cpu4 kernel_max
cpu14 cpu20 cpu27 cpu5 offline
/sys/devices/system/cpu # cat kernel_max
31
我用下面的方法支持linux kernel 32 smp,fedora目前还在探索中。
步骤
u-boot
$ export CROSS_COMPILE=riscv64-linux-gnu- // 设置环境变量 $ git clone https://github.com/u-boot/u-boot $ cd u-boot $ diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 3f221dccdb..00e4fd1df3 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -202,7 +202,7 @@ config NR_CPUS int "Maximum number of CPUs (2-32)" range 2 32 depends on SMP || SPL_SMP - default 8 + default 32 // 对u-boot做的唯一修改是这里,我把默认值由8改为32 help On multiprocessor machines, U-Boot sets up a stack for each CPU. Stack memory is pre-allocated. U-Boot must therefore know the $ make qemu-riscv64_smode_defconfig // 生成 config文件 $ make -j12 // 编译
opensbi
$ git clone https://github.com/riscv/opensbi.git $ cd opensbi $ make PLATFORM=generic
linux kernel
$ git clone https://github.com/torvalds/linux $ cd linux $ make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- menuconfig // 我们需要用菜单去选择maxcpus
$ make -j12 // 编译
qemu
这里应该使用生成的opensbi,u-boot,linux Image地址
$ ./qemu-system-riscv64 -M virt -m 256M -smp 32 -nographic \ -bios ~/PLCT/Src/opensbi/build/platform/generic/firmware/fw_jump.elf \ -kernel ~/PLCT/Src/u-boot/u-boot.bin -device loader,file=/home/ardxwe/PLCT/Src/machine/linux/arch/riscv/boot/Image,addr=0x84000000 \ -drive file=/home/ardxwe/PLCT/Src/machine/linux/rootfs.img,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0
进入u-boot使用如下的命令就可以启动 linux kernel
$ setenv bootargs "root=/dev/vda rw console=ttyS0 earlycon=sbi" $ cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000 $ booti ${kernel_addr_r} - ${fdt_addr_r}
查看
/ # cd sys/devices/system/ /sys/devices/system # ls clockevents clocksource container cpu /sys/devices/system # cd cpu /sys/devices/system/cpu # ls cpu0 cpu15 cpu21 cpu28 cpu6 online cpu1 cpu16 cpu22 cpu29 cpu7 possible cpu10 cpu17 cpu23 cpu3 cpu8 present cpu11 cpu18 cpu24 cpu30 cpu9 uevent cpu12 cpu19 cpu25 cpu31 isolated cpu13 cpu2 cpu26 cpu4 kernel_max cpu14 cpu20 cpu27 cpu5 offline /sys/devices/system/cpu # cat kernel_max 31
uboot menuconfig 中Size of malloc() pool before relocation需要修改到(0x2000)嘛?
opensbi 需要指定uboot地址
我用下面的方法支持linux kernel 32 smp,fedora目前还在探索中。
步骤
u-boot
$ export CROSS_COMPILE=riscv64-linux-gnu- // 设置环境变量 $ git clone https://github.com/u-boot/u-boot $ cd u-boot $ diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 3f221dccdb..00e4fd1df3 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -202,7 +202,7 @@ config NR_CPUS int "Maximum number of CPUs (2-32)" range 2 32 depends on SMP || SPL_SMP - default 8 + default 32 // 对u-boot做的唯一修改是这里,我把默认值由8改为32 help On multiprocessor machines, U-Boot sets up a stack for each CPU. Stack memory is pre-allocated. U-Boot must therefore know the $ make qemu-riscv64_smode_defconfig // 生成 config文件 $ make -j12 // 编译
opensbi
$ git clone https://github.com/riscv/opensbi.git $ cd opensbi $ make PLATFORM=generic
linux kernel
$ git clone https://github.com/torvalds/linux $ cd linux $ make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- menuconfig // 我们需要用菜单去选择maxcpus
$ make -j12 // 编译
qemu
这里应该使用生成的opensbi,u-boot,linux Image地址
$ ./qemu-system-riscv64 -M virt -m 256M -smp 32 -nographic \ -bios ~/PLCT/Src/opensbi/build/platform/generic/firmware/fw_jump.elf \ -kernel ~/PLCT/Src/u-boot/u-boot.bin -device loader,file=/home/ardxwe/PLCT/Src/machine/linux/arch/riscv/boot/Image,addr=0x84000000 \ -drive file=/home/ardxwe/PLCT/Src/machine/linux/rootfs.img,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0
进入u-boot使用如下的命令就可以启动 linux kernel
$ setenv bootargs "root=/dev/vda rw console=ttyS0 earlycon=sbi" $ cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000 $ booti ${kernel_addr_r} - ${fdt_addr_r}
查看
/ # cd sys/devices/system/ /sys/devices/system # ls clockevents clocksource container cpu /sys/devices/system # cd cpu /sys/devices/system/cpu # ls cpu0 cpu15 cpu21 cpu28 cpu6 online cpu1 cpu16 cpu22 cpu29 cpu7 possible cpu10 cpu17 cpu23 cpu3 cpu8 present cpu11 cpu18 cpu24 cpu30 cpu9 uevent cpu12 cpu19 cpu25 cpu31 isolated cpu13 cpu2 cpu26 cpu4 kernel_max cpu14 cpu20 cpu27 cpu5 offline /sys/devices/system/cpu # cat kernel_max 31
uboot menuconfig 中Size of malloc() pool before relocation需要修改到(0x2000)嘛?
opensbi 需要指定uboot地址
- 已修改
- 这里不需要指定,我重新编译 opensbi 没有指定u-boot地址, 没什么问题
Thanks.