smp: autodetect numbers of threads per core
RFC PATCH 1/1 smp: autodetect numbers of threads per core
At the moment only a whole CPU core can be assigned to a KVM. Since POWER7/8 support several threads per core, we want all threads of a core to go to the same KVM so every time we run QEMU with -enable-kvm on POWER, we have to add -smp X,threads=(4|8)" (4 for POWER7 and 8 for POWER8).
This patch tries to read smp_threads number from an accelerator and falls back to the default value (1) if the accelerator did not care to change it.
---
(!!!)
The usual question - what would be the normal way of doing this? What does this patch break? I cannot think of anything right now.
--- target-ppc/kvm.c | 6 ++++++ vl.c | 29 ++++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-)
target-ppc/kvm.c +6 -0
@@ -109,6 +109,12 @@ int kvm_arch_init(KVMState *s) "VM to stall at times!\n"); } +if (!smp_threads) { + smp_threads = cap_ppc_smt; + }else { + smp_threads =MIN (smp_threads, cap_ppc_smt); + } +kvm_ppc_register_host_cpu_type ();return 0 ;
vl.c +16 -13
@@ -210,7 +210,7 @@ int singlestep = 0;int smp_cpus =1 ;int max_cpus =0 ;int smp_cores =1 ; -int smp_threads =1 ; +int smp_threads =0 ;#ifdef CONFIG_VNC const char *vnc_display;#endif
@@ -1395,7 +1395,9 @@ static void smp_parse(QemuOpts *opts)if (cpus ==0 || sockets ==0 ) { sockets = sockets >0 ? sockets :1 ; cores = cores >0 ? cores :1 ; - threads = threads >0 ? threads :1 ; +if (!threads) { + threads = smp_threads >0 ? smp_threads :1 ; + }if (cpus ==0 ) { cpus = cores * threads * sockets; }
@@ -1413,7 +1415,8 @@ static void smp_parse(QemuOpts *opts) smp_cpus = cpus; smp_cores = cores >0 ? cores :1 ; smp_threads = threads >0 ? threads :1 ; - + }else if (!smp_threads) { + smp_threads =1 ; }if (max_cpus ==0 ) {
@@ -3880,16 +3883,6 @@ int main(int argc, char **argv, char **envp) data_dir[data_dir_idx++] =CONFIG_QEMU_DATADIR ; } -smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); - - machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ -if (smp_cpus > machine->max_cpus) { -fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " -"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, - machine->max_cpus); -exit (1 ); - } -/* * Get the default machine options from the machine if it is not already * specified either by the configuration file or by the command line.
@@ -4039,6 +4032,16 @@ int main(int argc, char **argv, char **envp)configure_accelerator (); +smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); + + machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ +if (smp_cpus > machine->max_cpus) { +fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " +"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, + machine->max_cpus); +exit (1 ); + } +if (!qtest_enabled () && qtest_chrdev) {qtest_init (); }
Signature · 1 line
1.8.4.rc4
Am 15.11.2013 um 00:12 schrieb Alexey Kardashevskiy <[email protected]>:
Quoted 10 lines
At the moment only a whole CPU core can be assigned to a KVM. Since POWER7/8 support several threads per core, we want all threads of a core to go to the same KVM so every time we run QEMU with -enable-kvm on POWER, we have to add -smp X,threads=(4|8)" (4 for POWER7 and 8 for POWER8).
This patch tries to read
smp_threadsnumber from an accelerator and falls back to the default value (1) if the accelerator did not care to change it.
Quoted 7 lines
Signed-off-by Alexey Kardashevskiy <[email protected]>---
(!!!)
The usual question - what would be the normal way of doing this? What does this patch break? I cannot think of anything right now.
Is this really what the user wants? On p7 you can run in no-smt, smt2 and smt4 mode. Today we simply default to no-smt. Changing defaults is usually a bad thing.
Alex
Quoted 96 lines
---
target-ppc/kvm.c| 6 ++++++vl.c| 29 ++++++++++++++++-------------2 files changed, 22 insertions(+), 13 deletions(-)target-ppc/kvm.c +6
-0@@ -109,6 +109,12 @@ int kvm_arch_init(KVMState *s) "VM to stall at times!\n"); } +if (!smp_threads) { + smp_threads = cap_ppc_smt; + }else { + smp_threads =MIN (smp_threads, cap_ppc_smt); + } +kvm_ppc_register_host_cpu_type ();return 0 ;vl.c +16
-13@@ -210,7 +210,7 @@ int singlestep = 0;int smp_cpus =1 ;int max_cpus =0 ;int smp_cores =1 ; -int smp_threads =1 ; +int smp_threads =0 ;#ifdef CONFIG_VNC const char *vnc_display;#endif @@ -1395,7 +1395,9 @@ static void smp_parse(QemuOpts *opts)if (cpus ==0 || sockets ==0 ) { sockets = sockets >0 ? sockets :1 ; cores = cores >0 ? cores :1 ; - threads = threads >0 ? threads :1 ; +if (!threads) { + threads = smp_threads >0 ? smp_threads :1 ; + }if (cpus ==0 ) { cpus = cores * threads * sockets; }@@ -1413,7 +1415,8 @@ static void smp_parse(QemuOpts *opts) smp_cpus = cpus; smp_cores = cores >0 ? cores :1 ; smp_threads = threads >0 ? threads :1 ; - + }else if (!smp_threads) { + smp_threads =1 ; }if (max_cpus ==0 ) {@@ -3880,16 +3883,6 @@ int main(int argc, char **argv, char **envp) data_dir[data_dir_idx++] =CONFIG_QEMU_DATADIR ; } -smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); - - machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ -if (smp_cpus > machine->max_cpus) { -fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " -"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, - machine->max_cpus); -exit (1 ); - } -/* * Get the default machine options from the machine if it is not already * specified either by the configuration file or by the command line. @@ -4039,6 +4032,16 @@ int main(int argc, char **argv, char **envp)configure_accelerator (); +smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); + + machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ +if (smp_cpus > machine->max_cpus) { +fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " +"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, + machine->max_cpus); +exit (1 ); + } +if (!qtest_enabled () && qtest_chrdev) {qtest_init (); }Signature · 1 line
1.8.4.rc4
Quoted 17 lines · Alexander Graf
Am 15.11.2013 um 00:12 schrieb Alexey Kardashevskiy <[email protected]>:
Quoted 13 lines
At the moment only a whole CPU core can be assigned to a KVM. Since POWER7/8 support several threads per core, we want all threads of a core to go to the same KVM so every time we run QEMU with -enable-kvm on POWER, we have to add -smp X,threads=(4|8)" (4 for POWER7 and 8 for POWER8).
This patch tries to read
smp_threadsnumber from an accelerator and falls back to the default value (1) if the accelerator did not care to change it.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Quoted 8 lines
Quoted 4 lines
(!!!)
The usual question - what would be the normal way of doing this? What does this patch break? I cannot think of anything right now.
Is this really what the user wants? On p7 you can run in no-smt, smt2 and smt4 mode. Today we simply default to no-smt. Changing defaults is usually a bad thing.
Defaulting to 1 thread on P7 is a bad thing (other threads stay unused - what is good about this?) and the only reason which I know why it is still threads=1 is that it is hard to make a patch for upstream to change this default.
Paul, please, help.
Quoted 96 lines
Alex
Quoted 92 lines
---
target-ppc/kvm.c| 6 ++++++vl.c| 29 ++++++++++++++++-------------2 files changed, 22 insertions(+), 13 deletions(-)target-ppc/kvm.c +6
-0@@ -109,6 +109,12 @@ int kvm_arch_init(KVMState *s) "VM to stall at times!\n"); } +if (!smp_threads) { + smp_threads = cap_ppc_smt; + }else { + smp_threads =MIN (smp_threads, cap_ppc_smt); + } +kvm_ppc_register_host_cpu_type ();return 0 ;vl.c +16
-13@@ -210,7 +210,7 @@ int singlestep = 0;int smp_cpus =1 ;int max_cpus =0 ;int smp_cores =1 ; -int smp_threads =1 ; +int smp_threads =0 ;#ifdef CONFIG_VNC const char *vnc_display;#endif @@ -1395,7 +1395,9 @@ static void smp_parse(QemuOpts *opts)if (cpus ==0 || sockets ==0 ) { sockets = sockets >0 ? sockets :1 ; cores = cores >0 ? cores :1 ; - threads = threads >0 ? threads :1 ; +if (!threads) { + threads = smp_threads >0 ? smp_threads :1 ; + }if (cpus ==0 ) { cpus = cores * threads * sockets; }@@ -1413,7 +1415,8 @@ static void smp_parse(QemuOpts *opts) smp_cpus = cpus; smp_cores = cores >0 ? cores :1 ; smp_threads = threads >0 ? threads :1 ; - + }else if (!smp_threads) { + smp_threads =1 ; }if (max_cpus ==0 ) {@@ -3880,16 +3883,6 @@ int main(int argc, char **argv, char **envp) data_dir[data_dir_idx++] =CONFIG_QEMU_DATADIR ; } -smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); - - machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ -if (smp_cpus > machine->max_cpus) { -fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " -"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, - machine->max_cpus); -exit (1 ); - } -/* * Get the default machine options from the machine if it is not already * specified either by the configuration file or by the command line. @@ -4039,6 +4032,16 @@ int main(int argc, char **argv, char **envp)configure_accelerator (); +smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); + + machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ +if (smp_cpus > machine->max_cpus) { +fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " +"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, + machine->max_cpus); +exit (1 ); + } +if (!qtest_enabled () && qtest_chrdev) {qtest_init (); }
Signature · 3 lines
With best regards Alexey Kardashevskiy -- icq: 52150396
Quoted 28 lines · Alexey Kardashevskiy
Quoted 17 lines · Alexander Graf
Am 15.11.2013 um 00:12 schrieb Alexey Kardashevskiy <[email protected]>:
Quoted 13 lines
At the moment only a whole CPU core can be assigned to a KVM. Since POWER7/8 support several threads per core, we want all threads of a core to go to the same KVM so every time we run QEMU with -enable-kvm on POWER, we have to add -smp X,threads=(4|8)" (4 for POWER7 and 8 for POWER8).
This patch tries to read
smp_threadsnumber from an accelerator and falls back to the default value (1) if the accelerator did not care to change it.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Quoted 8 lines
Quoted 4 lines
(!!!)
The usual question - what would be the normal way of doing this? What does this patch break? I cannot think of anything right now.
Is this really what the user wants? On p7 you can run in no-smt, smt2 and smt4 mode. Today we simply default to no-smt. Changing defaults is usually a bad thing.
Quoted 7 lines
Defaulting to 1 thread on P7 is a bad thing (other threads stay unused - what is good about this?) and the only reason which I know why it is still threads=1 is that it is hard to make a patch for upstream to change this default.
Paul, please, help.
Anyone, ping? Thanks.
Quoted 96 lines
Quoted 94 lines
Alex
Quoted 92 lines
---
target-ppc/kvm.c| 6 ++++++vl.c| 29 ++++++++++++++++-------------2 files changed, 22 insertions(+), 13 deletions(-)target-ppc/kvm.c +6
-0@@ -109,6 +109,12 @@ int kvm_arch_init(KVMState *s) "VM to stall at times!\n"); } +if (!smp_threads) { + smp_threads = cap_ppc_smt; + }else { + smp_threads =MIN (smp_threads, cap_ppc_smt); + } +kvm_ppc_register_host_cpu_type ();return 0 ;vl.c +16
-13@@ -210,7 +210,7 @@ int singlestep = 0;int smp_cpus =1 ;int max_cpus =0 ;int smp_cores =1 ; -int smp_threads =1 ; +int smp_threads =0 ;#ifdef CONFIG_VNC const char *vnc_display;#endif @@ -1395,7 +1395,9 @@ static void smp_parse(QemuOpts *opts)if (cpus ==0 || sockets ==0 ) { sockets = sockets >0 ? sockets :1 ; cores = cores >0 ? cores :1 ; - threads = threads >0 ? threads :1 ; +if (!threads) { + threads = smp_threads >0 ? smp_threads :1 ; + }if (cpus ==0 ) { cpus = cores * threads * sockets; }@@ -1413,7 +1415,8 @@ static void smp_parse(QemuOpts *opts) smp_cpus = cpus; smp_cores = cores >0 ? cores :1 ; smp_threads = threads >0 ? threads :1 ; - + }else if (!smp_threads) { + smp_threads =1 ; }if (max_cpus ==0 ) {@@ -3880,16 +3883,6 @@ int main(int argc, char **argv, char **envp) data_dir[data_dir_idx++] =CONFIG_QEMU_DATADIR ; } -smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); - - machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ -if (smp_cpus > machine->max_cpus) { -fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " -"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, - machine->max_cpus); -exit (1 ); - } -/* * Get the default machine options from the machine if it is not already * specified either by the configuration file or by the command line. @@ -4039,6 +4032,16 @@ int main(int argc, char **argv, char **envp)configure_accelerator (); +smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); + + machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ +if (smp_cpus > machine->max_cpus) { +fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " +"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, + machine->max_cpus); +exit (1 ); + } +if (!qtest_enabled () && qtest_chrdev) {qtest_init (); }
Signature · 1 line
Alexey
Quoted 35 lines · Alexey Kardashevskiy
Quoted 34 lines · Alexey Kardashevskiy
Quoted 17 lines · Alexander Graf
Am 15.11.2013 um 00:12 schrieb Alexey Kardashevskiy <[email protected]>:
Quoted 13 lines
At the moment only a whole CPU core can be assigned to a KVM. Since POWER7/8 support several threads per core, we want all threads of a core to go to the same KVM so every time we run QEMU with -enable-kvm on POWER, we have to add -smp X,threads=(4|8)" (4 for POWER7 and 8 for POWER8).
This patch tries to read
smp_threadsnumber from an accelerator and falls back to the default value (1) if the accelerator did not care to change it.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Quoted 8 lines
Quoted 4 lines
(!!!)
The usual question - what would be the normal way of doing this? What does this patch break? I cannot think of anything right now.
Is this really what the user wants? On p7 you can run in no-smt, smt2 and smt4 mode. Today we simply default to no-smt. Changing defaults is usually a bad thing.
Defaulting to 1 thread on P7 is a bad thing (other threads stay unused - what is good about this?) and the only reason which I know why it is still threads=1 is that it is hard to make a patch for upstream to change this default.
Quoted 4 lines
Quoted 1 line
Paul, please, help.
Anyone, ping? Thanks.
Everyone ignores me :(
Quoted 100 lines
Quoted 98 lines
Quoted 96 lines
Alex
Quoted 92 lines
---
target-ppc/kvm.c| 6 ++++++vl.c| 29 ++++++++++++++++-------------2 files changed, 22 insertions(+), 13 deletions(-)target-ppc/kvm.c +6
-0@@ -109,6 +109,12 @@ int kvm_arch_init(KVMState *s) "VM to stall at times!\n"); } +if (!smp_threads) { + smp_threads = cap_ppc_smt; + }else { + smp_threads =MIN (smp_threads, cap_ppc_smt); + } +kvm_ppc_register_host_cpu_type ();return 0 ;vl.c +16
-13@@ -210,7 +210,7 @@ int singlestep = 0;int smp_cpus =1 ;int max_cpus =0 ;int smp_cores =1 ; -int smp_threads =1 ; +int smp_threads =0 ;#ifdef CONFIG_VNC const char *vnc_display;#endif @@ -1395,7 +1395,9 @@ static void smp_parse(QemuOpts *opts)if (cpus ==0 || sockets ==0 ) { sockets = sockets >0 ? sockets :1 ; cores = cores >0 ? cores :1 ; - threads = threads >0 ? threads :1 ; +if (!threads) { + threads = smp_threads >0 ? smp_threads :1 ; + }if (cpus ==0 ) { cpus = cores * threads * sockets; }@@ -1413,7 +1415,8 @@ static void smp_parse(QemuOpts *opts) smp_cpus = cpus; smp_cores = cores >0 ? cores :1 ; smp_threads = threads >0 ? threads :1 ; - + }else if (!smp_threads) { + smp_threads =1 ; }if (max_cpus ==0 ) {@@ -3880,16 +3883,6 @@ int main(int argc, char **argv, char **envp) data_dir[data_dir_idx++] =CONFIG_QEMU_DATADIR ; } -smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); - - machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ -if (smp_cpus > machine->max_cpus) { -fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " -"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, - machine->max_cpus); -exit (1 ); - } -/* * Get the default machine options from the machine if it is not already * specified either by the configuration file or by the command line. @@ -4039,6 +4032,16 @@ int main(int argc, char **argv, char **envp)configure_accelerator (); +smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); + + machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ +if (smp_cpus > machine->max_cpus) { +fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " +"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, + machine->max_cpus); +exit (1 ); + } +if (!qtest_enabled () && qtest_chrdev) {qtest_init (); }
Signature · 1 line
Alexey
Quoted 36 lines · Alexey Kardashevskiy
Quoted 35 lines · Alexey Kardashevskiy
Quoted 34 lines · Alexey Kardashevskiy
Quoted 17 lines · Alexander Graf
Am 15.11.2013 um 00:12 schrieb Alexey Kardashevskiy <[email protected]>:
Quoted 13 lines
At the moment only a whole CPU core can be assigned to a KVM. Since POWER7/8 support several threads per core, we want all threads of a core to go to the same KVM so every time we run QEMU with -enable-kvm on POWER, we have to add -smp X,threads=(4|8)" (4 for POWER7 and 8 for POWER8).
This patch tries to read
smp_threadsnumber from an accelerator and falls back to the default value (1) if the accelerator did not care to change it.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Quoted 8 lines
Quoted 4 lines
(!!!)
The usual question - what would be the normal way of doing this? What does this patch break? I cannot think of anything right now.
Is this really what the user wants? On p7 you can run in no-smt, smt2 and smt4 mode. Today we simply default to no-smt. Changing defaults is usually a bad thing.
Defaulting to 1 thread on P7 is a bad thing (other threads stay unused - what is good about this?) and the only reason which I know why it is still threads=1 is that it is hard to make a patch for upstream to change this default.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Paul, please, help.
Anyone, ping? Thanks.
Everyone ignores me :(
Ping?
Quoted 104 lines
Quoted 102 lines
Quoted 100 lines
Quoted 98 lines
Alex
Quoted 92 lines
---
target-ppc/kvm.c| 6 ++++++vl.c| 29 ++++++++++++++++-------------2 files changed, 22 insertions(+), 13 deletions(-)target-ppc/kvm.c +6
-0@@ -109,6 +109,12 @@ int kvm_arch_init(KVMState *s) "VM to stall at times!\n"); } +if (!smp_threads) { + smp_threads = cap_ppc_smt; + }else { + smp_threads =MIN (smp_threads, cap_ppc_smt); + } +kvm_ppc_register_host_cpu_type ();return 0 ;vl.c +16
-13@@ -210,7 +210,7 @@ int singlestep = 0;int smp_cpus =1 ;int max_cpus =0 ;int smp_cores =1 ; -int smp_threads =1 ; +int smp_threads =0 ;#ifdef CONFIG_VNC const char *vnc_display;#endif @@ -1395,7 +1395,9 @@ static void smp_parse(QemuOpts *opts)if (cpus ==0 || sockets ==0 ) { sockets = sockets >0 ? sockets :1 ; cores = cores >0 ? cores :1 ; - threads = threads >0 ? threads :1 ; +if (!threads) { + threads = smp_threads >0 ? smp_threads :1 ; + }if (cpus ==0 ) { cpus = cores * threads * sockets; }@@ -1413,7 +1415,8 @@ static void smp_parse(QemuOpts *opts) smp_cpus = cpus; smp_cores = cores >0 ? cores :1 ; smp_threads = threads >0 ? threads :1 ; - + }else if (!smp_threads) { + smp_threads =1 ; }if (max_cpus ==0 ) {@@ -3880,16 +3883,6 @@ int main(int argc, char **argv, char **envp) data_dir[data_dir_idx++] =CONFIG_QEMU_DATADIR ; } -smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); - - machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ -if (smp_cpus > machine->max_cpus) { -fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " -"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, - machine->max_cpus); -exit (1 ); - } -/* * Get the default machine options from the machine if it is not already * specified either by the configuration file or by the command line. @@ -4039,6 +4032,16 @@ int main(int argc, char **argv, char **envp)configure_accelerator (); +smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); + + machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ +if (smp_cpus > machine->max_cpus) { +fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " +"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, + machine->max_cpus); +exit (1 ); + } +if (!qtest_enabled () && qtest_chrdev) {qtest_init (); }
Signature · 1 line
Alexey
Quoted 40 lines · Alexey Kardashevskiy
Quoted 39 lines · Alexey Kardashevskiy
Quoted 38 lines · Alexey Kardashevskiy
Quoted 35 lines · Alexey Kardashevskiy
Quoted 17 lines · Alexander Graf
Am 15.11.2013 um 00:12 schrieb Alexey Kardashevskiy <[email protected]>:
Quoted 13 lines
At the moment only a whole CPU core can be assigned to a KVM. Since POWER7/8 support several threads per core, we want all threads of a core to go to the same KVM so every time we run QEMU with -enable-kvm on POWER, we have to add -smp X,threads=(4|8)" (4 for POWER7 and 8 for POWER8).
This patch tries to read
smp_threadsnumber from an accelerator and falls back to the default value (1) if the accelerator did not care to change it.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Quoted 8 lines
Quoted 4 lines
(!!!)
The usual question - what would be the normal way of doing this? What does this patch break? I cannot think of anything right now.
Is this really what the user wants? On p7 you can run in no-smt, smt2 and smt4 mode. Today we simply default to no-smt. Changing defaults is usually a bad thing.
Defaulting to 1 thread on P7 is a bad thing (other threads stay unused - what is good about this?) and the only reason which I know why it is still threads=1 is that it is hard to make a patch for upstream to change this default.
Paul, please, help.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Anyone, ping? Thanks.
Everyone ignores me :(
Ping?
Does it make any sense pinging the list about this patch? Is it too ugly?
Quoted 108 lines
Quoted 106 lines
Quoted 104 lines
Quoted 102 lines
Quoted 100 lines
Alex
Quoted 92 lines
---
target-ppc/kvm.c| 6 ++++++vl.c| 29 ++++++++++++++++-------------2 files changed, 22 insertions(+), 13 deletions(-)target-ppc/kvm.c +6
-0@@ -109,6 +109,12 @@ int kvm_arch_init(KVMState *s) "VM to stall at times!\n"); } +if (!smp_threads) { + smp_threads = cap_ppc_smt; + }else { + smp_threads =MIN (smp_threads, cap_ppc_smt); + } +kvm_ppc_register_host_cpu_type ();return 0 ;vl.c +16
-13@@ -210,7 +210,7 @@ int singlestep = 0;int smp_cpus =1 ;int max_cpus =0 ;int smp_cores =1 ; -int smp_threads =1 ; +int smp_threads =0 ;#ifdef CONFIG_VNC const char *vnc_display;#endif @@ -1395,7 +1395,9 @@ static void smp_parse(QemuOpts *opts)if (cpus ==0 || sockets ==0 ) { sockets = sockets >0 ? sockets :1 ; cores = cores >0 ? cores :1 ; - threads = threads >0 ? threads :1 ; +if (!threads) { + threads = smp_threads >0 ? smp_threads :1 ; + }if (cpus ==0 ) { cpus = cores * threads * sockets; }@@ -1413,7 +1415,8 @@ static void smp_parse(QemuOpts *opts) smp_cpus = cpus; smp_cores = cores >0 ? cores :1 ; smp_threads = threads >0 ? threads :1 ; - + }else if (!smp_threads) { + smp_threads =1 ; }if (max_cpus ==0 ) {@@ -3880,16 +3883,6 @@ int main(int argc, char **argv, char **envp) data_dir[data_dir_idx++] =CONFIG_QEMU_DATADIR ; } -smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); - - machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ -if (smp_cpus > machine->max_cpus) { -fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " -"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, - machine->max_cpus); -exit (1 ); - } -/* * Get the default machine options from the machine if it is not already * specified either by the configuration file or by the command line. @@ -4039,6 +4032,16 @@ int main(int argc, char **argv, char **envp)configure_accelerator (); +smp_parse (qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL )); + + machine->max_cpus = machine->max_cpus ?:1 ;/* Default to UP */ +if (smp_cpus > machine->max_cpus) { +fprintf (stderr,"Number of SMP cpus requested (%d), exceeds max cpus " +"supported by machine `%s' (%d)\n" , smp_cpus, machine->name, + machine->max_cpus); +exit (1 ); + } +if (!qtest_enabled () && qtest_chrdev) {qtest_init (); }
Signature · 1 line
Alexey