@@ -196,25 +196,31 @@ SRST
ERST
DEF("smp", HAS_ARG, QEMU_OPTION_smp,
- "-smp [cpus=]n[,maxcpus=cpus][,cores=cores][,threads=threads][,dies=dies][,sockets=sockets]\n"
+ "-smp [cpus=]n[,maxcpus=cpus][,cores=cores][,threads=threads][,dies=dies][,sockets=sockets][,expose=on|off]\n"
" set the number of CPUs to 'n' [default=1]\n"
" maxcpus= maximum number of total cpus, including\n"
" offline CPUs for hotplug, etc\n"
" cores= number of CPU cores on one socket (for PC, it's on one die)\n"
" threads= number of threads on one CPU core\n"
" dies= number of CPU dies on one socket (for PC only)\n"
- " sockets= number of discrete sockets in the system\n",
+ " sockets= number of discrete sockets in the system\n"
+ " expose=on|off controls support for exposing cpu topology\n"
+ " to the guest (default=off)\n",
QEMU_ARCH_ALL)
SRST
-``-smp [cpus=]n[,cores=cores][,threads=threads][,dies=dies][,sockets=sockets][,maxcpus=maxcpus]``
+``-smp [cpus=]n[,cores=cores][,threads=threads][,dies=dies][,sockets=sockets][,maxcpus=maxcpus][,expose=on|off]``
Simulate an SMP system with n CPUs. On the PC target, up to 255 CPUs
- are supported. On Sparc32 target, Linux limits the number of usable
- CPUs to 4. For the PC target, the number of cores per die, the
- number of threads per cores, the number of dies per packages and the
- total number of sockets can be specified. Missing values will be
- computed. If any on the three values is given, the total number of
- CPUs n can be omitted. maxcpus specifies the maximum number of
+ are supported. On the Sparc32 target, Linux limits the number of usable
+ CPUs to 4. For the PC target, the number of cores per die, the number
+ of threads per core, the number of dies per package and the total number
+ of sockets can be specified. maxcpus specifies the maximum number of
hotpluggable CPUs.
+
+ With "expose=off" or not explicitly specified, missing values will be
+ computed, and the total number of CPUs n can be omitted if any on the
+ three values is given. Otherwise with "expose=on", much more detailed
+ configuration is required: cpus/sockets/cores/threads must be given,
+ while maxcpus is optional.
ERST
DEF("numa", HAS_ARG, QEMU_OPTION_numa,
@@ -729,6 +729,9 @@ static QemuOptsList qemu_smp_opts = {
}, {
.name = "maxcpus",
.type = QEMU_OPT_NUMBER,
+ }, {
+ .name = "expose",
+ .type = QEMU_OPT_BOOL,
},
{ /*End of list */ }
},
Once the view of virtual cpu topology is provided to guest kernel, with a well-designed vCPU pinning to the pCPU we could get a huge benefit, e.g., the scheduling performance improvement. However a virtual cpu topology view of guest may also have a negative impact if the pinning is badly-designed. See Dario Faggioli's research and the related performance tests in [1] for reference. [1] https://kvmforum2020.sched.com/event/eE1y/virtual-topology- for-virtual-machines-friend-or-foe-dario-faggioli-suse So here we go, let's introduce support of generating cpu topology descriptions to the guest. However, instead of quietly enforcing the support for the latest machine type, we'd better introduce a new parameter "expose=on|off" in -smp command line to leave QEMU users a choice to decide whether to enable the feature or not. This will allow the feature to work on different machine types and also ideally compat with already in-use -smp command lines. Furthermore, based on existing parsing rules of -smp command line in generic smp_parse() which allows to compute the missing values, another more strict rule is introduced to follow when exposure of cpu topology is enabled. With "expose=on", it's important to know what users actually want, so we require that all of cpus/sockets/ cores/threads must be provided while maxcpus is optional. Hopefully the new rule will apply to all kinds of architectures which support the feature. In conclusion, if a QEMU user doesn't hope to enable the virtual cpu topology support, then feel free to configure a -smp cmdline like below and everything will work just like before: -smp 96 -smp 96,expose=off -smp 96,sockets=2 -smp 96,sockets=2,expose=off ... While if a QEMU user is ready to take advantage of the virtual cpu topology support, then he must configure an accurate -smp cmdline like below, on different machine types: -smp 96,sockets=2,cores=48,threads=1,expose=on -smp 96,maxcpus=96,sockets=2,cores=48,threads=1,expose=on Suggested-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Yanan Wang <wangyanan55@huawei.com> --- qemu-options.hx | 24 +++++++++++++++--------- softmmu/vl.c | 3 +++ 2 files changed, 18 insertions(+), 9 deletions(-)