* [PATCH] kvm tools: Default guest cpu count to host cpu count
@ 2011-05-18 19:56 Sasha Levin
2011-05-18 19:59 ` Cyrill Gorcunov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Sasha Levin @ 2011-05-18 19:56 UTC (permalink / raw)
To: penberg; +Cc: mingo, asias.hejun, gorcunov, prasadjoshi124, kvm, Sasha Levin
If user haven't specified cpu count for the guest, use
the amount of online cpus on the host.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/kvm-run.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
index 63181bf..1517264 100644
--- a/tools/kvm/kvm-run.c
+++ b/tools/kvm/kvm-run.c
@@ -70,7 +70,7 @@ extern int active_console;
bool do_debug_print = false;
-static int nrcpus = 1;
+static int nrcpus;
static const char * const run_usage[] = {
"kvm run [<options>] [<kernel image>]",
@@ -409,6 +409,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
signal(SIGQUIT, handle_sigquit);
signal(SIGUSR1, handle_sigusr1);
+ nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+
while (argc != 0) {
argc = parse_options(argc, argv, options, run_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
@@ -439,7 +441,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
vmlinux_filename = find_vmlinux();
- if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
+ if (nrcpus == 0)
+ nrcpus = nr_online_cpus;
+ else if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
die("Number of CPUs %d is out of [1;%d] range", nrcpus, KVM_NR_CPUS);
if (!ram_size)
@@ -575,7 +579,6 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
kvm__init_ram(kvm);
- nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
thread_pool__init(nr_online_cpus);
for (i = 0; i < nrcpus; i++) {
--
1.7.5.rc3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm tools: Default guest cpu count to host cpu count
2011-05-18 19:56 [PATCH] kvm tools: Default guest cpu count to host cpu count Sasha Levin
@ 2011-05-18 19:59 ` Cyrill Gorcunov
2011-05-19 10:35 ` Asias He
2011-05-19 19:04 ` David Ahern
2 siblings, 0 replies; 6+ messages in thread
From: Cyrill Gorcunov @ 2011-05-18 19:59 UTC (permalink / raw)
To: Sasha Levin; +Cc: penberg, mingo, asias.hejun, prasadjoshi124, kvm
On 05/18/2011 11:56 PM, Sasha Levin wrote:
> If user haven't specified cpu count for the guest, use
> the amount of online cpus on the host.
>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Looks good to me, thanks Sasha!
--
Cyrill
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm tools: Default guest cpu count to host cpu count
2011-05-18 19:56 [PATCH] kvm tools: Default guest cpu count to host cpu count Sasha Levin
2011-05-18 19:59 ` Cyrill Gorcunov
@ 2011-05-19 10:35 ` Asias He
2011-05-19 19:04 ` David Ahern
2 siblings, 0 replies; 6+ messages in thread
From: Asias He @ 2011-05-19 10:35 UTC (permalink / raw)
To: Sasha Levin; +Cc: penberg, mingo, gorcunov, prasadjoshi124, kvm
On 05/19/2011 03:56 AM, Sasha Levin wrote:
> If user haven't specified cpu count for the guest, use
> the amount of online cpus on the host.
>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
> tools/kvm/kvm-run.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
> index 63181bf..1517264 100644
> --- a/tools/kvm/kvm-run.c
> +++ b/tools/kvm/kvm-run.c
> @@ -70,7 +70,7 @@ extern int active_console;
>
> bool do_debug_print = false;
>
> -static int nrcpus = 1;
> +static int nrcpus;
>
> static const char * const run_usage[] = {
> "kvm run [<options>] [<kernel image>]",
> @@ -409,6 +409,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
> signal(SIGQUIT, handle_sigquit);
> signal(SIGUSR1, handle_sigusr1);
>
> + nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> +
> while (argc != 0) {
> argc = parse_options(argc, argv, options, run_usage,
> PARSE_OPT_STOP_AT_NON_OPTION);
> @@ -439,7 +441,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>
> vmlinux_filename = find_vmlinux();
>
> - if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
> + if (nrcpus == 0)
> + nrcpus = nr_online_cpus;
> + else if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
> die("Number of CPUs %d is out of [1;%d] range", nrcpus, KVM_NR_CPUS);
>
> if (!ram_size)
> @@ -575,7 +579,6 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>
> kvm__init_ram(kvm);
>
> - nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> thread_pool__init(nr_online_cpus);
>
> for (i = 0; i < nrcpus; i++) {
Looks good to me.
Tested-by: Asias He <asias.hejun@gmail.com>
--
Best Regards,
Asias He
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm tools: Default guest cpu count to host cpu count
2011-05-18 19:56 [PATCH] kvm tools: Default guest cpu count to host cpu count Sasha Levin
2011-05-18 19:59 ` Cyrill Gorcunov
2011-05-19 10:35 ` Asias He
@ 2011-05-19 19:04 ` David Ahern
2011-05-19 19:08 ` Cyrill Gorcunov
2 siblings, 1 reply; 6+ messages in thread
From: David Ahern @ 2011-05-19 19:04 UTC (permalink / raw)
To: Sasha Levin; +Cc: penberg, mingo, asias.hejun, gorcunov, prasadjoshi124, kvm
On 05/18/11 13:56, Sasha Levin wrote:
> If user haven't specified cpu count for the guest, use
> the amount of online cpus on the host.
>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
> tools/kvm/kvm-run.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
> index 63181bf..1517264 100644
> --- a/tools/kvm/kvm-run.c
> +++ b/tools/kvm/kvm-run.c
> @@ -70,7 +70,7 @@ extern int active_console;
>
> bool do_debug_print = false;
>
> -static int nrcpus = 1;
> +static int nrcpus;
>
> static const char * const run_usage[] = {
> "kvm run [<options>] [<kernel image>]",
> @@ -409,6 +409,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
> signal(SIGQUIT, handle_sigquit);
> signal(SIGUSR1, handle_sigusr1);
>
> + nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> +
> while (argc != 0) {
> argc = parse_options(argc, argv, options, run_usage,
> PARSE_OPT_STOP_AT_NON_OPTION);
> @@ -439,7 +441,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>
> vmlinux_filename = find_vmlinux();
>
> - if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
> + if (nrcpus == 0)
> + nrcpus = nr_online_cpus;
> + else if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
> die("Number of CPUs %d is out of [1;%d] range", nrcpus, KVM_NR_CPUS);
What prevents nr_online_cpus from being greater than KVM_NR_CPUS? Since
that latter is a #define, might want to change 'else if' to if there.
David
>
> if (!ram_size)
> @@ -575,7 +579,6 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>
> kvm__init_ram(kvm);
>
> - nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> thread_pool__init(nr_online_cpus);
>
> for (i = 0; i < nrcpus; i++) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm tools: Default guest cpu count to host cpu count
2011-05-19 19:04 ` David Ahern
@ 2011-05-19 19:08 ` Cyrill Gorcunov
2011-05-19 20:00 ` Cyrill Gorcunov
0 siblings, 1 reply; 6+ messages in thread
From: Cyrill Gorcunov @ 2011-05-19 19:08 UTC (permalink / raw)
To: David Ahern; +Cc: Sasha Levin, penberg, mingo, asias.hejun, prasadjoshi124, kvm
On 05/19/2011 11:04 PM, David Ahern wrote:
>
> On 05/18/11 13:56, Sasha Levin wrote:
>> If user haven't specified cpu count for the guest, use
>> the amount of online cpus on the host.
>>
>> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
>> ---
>> tools/kvm/kvm-run.c | 9 ++++++---
>> 1 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
>> index 63181bf..1517264 100644
>> --- a/tools/kvm/kvm-run.c
>> +++ b/tools/kvm/kvm-run.c
>> @@ -70,7 +70,7 @@ extern int active_console;
>>
>> bool do_debug_print = false;
>>
>> -static int nrcpus = 1;
>> +static int nrcpus;
>>
>> static const char * const run_usage[] = {
>> "kvm run [<options>] [<kernel image>]",
>> @@ -409,6 +409,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>> signal(SIGQUIT, handle_sigquit);
>> signal(SIGUSR1, handle_sigusr1);
>>
>> + nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
>> +
>> while (argc != 0) {
>> argc = parse_options(argc, argv, options, run_usage,
>> PARSE_OPT_STOP_AT_NON_OPTION);
>> @@ -439,7 +441,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>>
>> vmlinux_filename = find_vmlinux();
>>
>> - if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
>> + if (nrcpus == 0)
>> + nrcpus = nr_online_cpus;
>> + else if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
>> die("Number of CPUs %d is out of [1;%d] range", nrcpus, KVM_NR_CPUS);
>
> What prevents nr_online_cpus from being greater than KVM_NR_CPUS? Since
> that latter is a #define, might want to change 'else if' to if there.
>
> David
>
Good catch! We should add a constraint here and limit it to KVM_NR_CPUS.
--
Cyrill
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm tools: Default guest cpu count to host cpu count
2011-05-19 19:08 ` Cyrill Gorcunov
@ 2011-05-19 20:00 ` Cyrill Gorcunov
0 siblings, 0 replies; 6+ messages in thread
From: Cyrill Gorcunov @ 2011-05-19 20:00 UTC (permalink / raw)
To: David Ahern; +Cc: Sasha Levin, penberg, mingo, asias.hejun, prasadjoshi124, kvm
On 05/19/2011 11:08 PM, Cyrill Gorcunov wrote:
...
>>
>> What prevents nr_online_cpus from being greater than KVM_NR_CPUS? Since
>> that latter is a #define, might want to change 'else if' to if there.
>>
>> David
>>
>
> Good catch! We should add a constraint here and limit it to KVM_NR_CPUS.
>
Heh, actually it get catched futher in code by
max_cpus = kvm__max_cpus(kvm);
if (nrcpus > max_cpus) {
printf(" # Limit the number of CPUs to %d\n", max_cpus);
kvm->nrcpus = max_cpus;
}
so no issue here (except that MP table can support a limited number of
cpus and for 32bit apic addressing we need ACPI support implemented I think).
--
Cyrill
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-05-19 20:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-18 19:56 [PATCH] kvm tools: Default guest cpu count to host cpu count Sasha Levin
2011-05-18 19:59 ` Cyrill Gorcunov
2011-05-19 10:35 ` Asias He
2011-05-19 19:04 ` David Ahern
2011-05-19 19:08 ` Cyrill Gorcunov
2011-05-19 20:00 ` Cyrill Gorcunov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.