From: Andrew Jones <drjones@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: mttcg@greensocs.com, peter.maydell@linaro.org,
"Alex Bennée" <alex@bennee.com>,
claudio.fontana@huawei.com, kvm@vger.kernel.org,
a.spyridakis@virtualopensystems.com, mark.burton@greensocs.com,
a.rigo@virtualopensystems.com, qemu-devel@nongnu.org,
fred.konrad@greensocs.com
Subject: Re: [Qemu-devel] [kvm-unit-tests PATCH v5 09/11] arm: query /dev/kvm for maximum vcpus
Date: Fri, 31 Jul 2015 21:17:12 +0200 [thread overview]
Message-ID: <20150731191712.GI3680@hawk.localdomain> (raw)
In-Reply-To: <1438358041-18021-10-git-send-email-alex.bennee@linaro.org>
On Fri, Jul 31, 2015 at 04:53:59PM +0100, Alex Bennée wrote:
> From: Alex Bennée <alex@bennee.com>
>
> The previous $(getconf _NPROCESSORS_CONF) isn't correct as the default
> maximum VCPU configuration is 4 on arm64 machines which typically have
> more actual cores.
The kernel should probably bump that up to 8, but that's an aside,
as it wouldn't resolve the general issue.
For this patch, I don't think we need a C utility as we can probe
with QEMU, and thus just need a script.
$QEMU -machine virt,accel=kvm -smp 9
Number of SMP cpus requested (9), exceeds max cpus supported by machine `virt' (8)
The script can live in $root/scripts/, which is a directory recently
created for standalone test support.
Thanks,
drew
>
> This introduces a simple utility program to query the KVM capabilities
> and use the correct maximum number of vcpus.
>
> [FOR DISCUSSION: this fails on TCG which could use _NPROCESSORS_CONF]
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> arm/unittests.cfg | 10 +++++-----
> arm/utils/kvm-query.c | 41 +++++++++++++++++++++++++++++++++++++++++
> config/config-arm-common.mak | 8 +++++++-
> 3 files changed, 53 insertions(+), 6 deletions(-)
> create mode 100644 arm/utils/kvm-query.c
>
> diff --git a/arm/unittests.cfg b/arm/unittests.cfg
> index 19d72ad..7a3a32b 100644
> --- a/arm/unittests.cfg
> +++ b/arm/unittests.cfg
> @@ -32,30 +32,30 @@ groups = selftest
> # Test SMP support
> [selftest::smp]
> file = selftest.flat
> -smp = $(getconf _NPROCESSORS_CONF)
> +smp = $(./arm/utils/kvm-query max_vcpu)
> extra_params = -append 'smp'
> groups = selftest
>
> # TLB Torture Tests
> [tlbflush::all_other]
> file = tlbflush-test.flat
> -smp = $(getconf _NPROCESSORS_CONF)
> +smp = $(./arm/utils/kvm-query max_vcpu)
> groups = tlbflush
>
> [tlbflush::page_other]
> file = tlbflush-test.flat
> -smp = $(getconf _NPROCESSORS_CONF)
> +smp = $(./arm/utils/kvm-query max_vcpu)
> extra_params = -append 'page'
> groups = tlbflush
>
> [tlbflush::all_self]
> file = tlbflush-test.flat
> -smp = $(getconf _NPROCESSORS_CONF)
> +smp = $(./arm/utils/kvm-query max_vcpu)
> extra_params = -append 'self'
> groups = tlbflush
>
> [tlbflush::page_self]
> file = tlbflush-test.flat
> -smp = $(getconf _NPROCESSORS_CONF)
> +smp = $(./arm/utils/kvm-query max_vcpu)
> extra_params = -append 'page self'
> groups = tlbflush
> diff --git a/arm/utils/kvm-query.c b/arm/utils/kvm-query.c
> new file mode 100644
> index 0000000..4f979b1
> --- /dev/null
> +++ b/arm/utils/kvm-query.c
> @@ -0,0 +1,41 @@
> +/*
> + * kvm-query.c
> + *
> + * A simple utility to query KVM capabilities.
> + */
> +
> +#include <sys/ioctl.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +
> +#include <string.h>
> +#include <stdio.h>
> +
> +#include <linux/kvm.h>
> +
> +int get_max_vcpu(void)
> +{
> + int fd = open("/dev/kvm", O_RDWR);
> + if (fd>0) {
> + int ret = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS);
> + printf("%d\n", ret > 0 ? ret : 0);
> + close(fd);
> + return 0;
> + } else {
> + return -1;
> + }
> +}
> +
> +int main(int argc, char **argv)
> +{
> + for (int i=0; i<argc; i++) {
> + char *arg = argv[i];
> + if (strcmp(arg, "max_vcpu") == 0) {
> + return get_max_vcpu();
> + }
> + }
> +
> + return -1;
> +}
> diff --git a/config/config-arm-common.mak b/config/config-arm-common.mak
> index 164199b..9c7607b 100644
> --- a/config/config-arm-common.mak
> +++ b/config/config-arm-common.mak
> @@ -13,7 +13,9 @@ tests-common = $(TEST_DIR)/selftest.flat
> tests-common += $(TEST_DIR)/spinlock-test.flat
> tests-common += $(TEST_DIR)/tlbflush-test.flat
>
> -all: test_cases
> +utils-common = $(TEST_DIR)/utils/kvm-query
> +
> +all: test_cases utils
>
> ##################################################################
> phys_base = $(LOADADDR)
> @@ -58,6 +60,9 @@ FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
> $(libeabi): $(eabiobjs)
> $(AR) rcs $@ $^
>
> +$(TEST_DIR)/utils/%: $(TEST_DIR)/utils/%.c
> + $(CC) -std=gnu99 -o $@ $^
> +
> arm_clean: libfdt_clean asm_offsets_clean
> $(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \
> $(TEST_DIR)/.*.d lib/arm/.*.d
> @@ -69,6 +74,7 @@ tests_and_config = $(TEST_DIR)/*.flat $(TEST_DIR)/unittests.cfg
> generated_files = $(asm-offsets)
>
> test_cases: $(generated_files) $(tests-common) $(tests)
> +utils: $(utils-common)
>
> $(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
> $(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o
> --
> 2.5.0
>
>
next prev parent reply other threads:[~2015-07-31 19:17 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 15:53 [Qemu-devel] [kvm-unit-tests PATCH v5 00/11] My current MTTCG tests Alex Bennée
2015-07-31 15:53 ` [Qemu-devel] [kvm-unit-tests PATCH v5 01/11] arm/run: set indentation defaults for emacs Alex Bennée
2015-07-31 15:53 ` [Qemu-devel] [kvm-unit-tests PATCH v5 02/11] README: add some CONTRIBUTING notes Alex Bennée
2015-07-31 15:53 ` [Qemu-devel] [kvm-unit-tests PATCH v5 03/11] configure: emit HOST=$host to config.mak Alex Bennée
2015-07-31 15:53 ` [Qemu-devel] [kvm-unit-tests PATCH v5 04/11] arm/run: introduce usingkvm var and use it Alex Bennée
2015-08-02 16:36 ` Andrew Jones
2015-07-31 15:53 ` [Qemu-devel] [kvm-unit-tests PATCH v5 05/11] lib/printf: support the %u unsigned fmt field Alex Bennée
2015-07-31 18:25 ` Andrew Jones
2015-07-31 15:53 ` [Qemu-devel] [kvm-unit-tests PATCH v5 06/11] lib/arm: add flush_tlb_page mmu function Alex Bennée
2015-07-31 18:35 ` Andrew Jones
2015-07-31 15:53 ` [Qemu-devel] [kvm-unit-tests PATCH v5 07/11] new arm/tlbflush-test: TLB torture test Alex Bennée
2015-07-31 18:51 ` Andrew Jones
2015-07-31 15:53 ` [Qemu-devel] [kvm-unit-tests PATCH v5 08/11] arm/unittests.cfg: add the tlbflush tests Alex Bennée
2015-07-31 18:53 ` Andrew Jones
2015-07-31 15:53 ` [Qemu-devel] [kvm-unit-tests PATCH v5 09/11] arm: query /dev/kvm for maximum vcpus Alex Bennée
2015-07-31 19:17 ` Andrew Jones [this message]
2015-08-02 16:40 ` Andrew Jones
2015-07-31 15:54 ` [Qemu-devel] [kvm-unit-tests PATCH v5 10/11] new: add isaac prng library from CCAN Alex Bennée
2015-07-31 19:22 ` Andrew Jones
2015-07-31 15:54 ` [Qemu-devel] [kvm-unit-tests PATCH v5 11/11] new: arm/barrier-test for memory barriers Alex Bennée
2015-07-31 19:30 ` Andrew Jones
2015-08-03 10:02 ` alvise rigo
2015-08-03 10:30 ` Alex Bennée
2015-08-03 10:34 ` alvise rigo
2015-08-03 16:06 ` Alex Bennée
2015-08-03 16:46 ` alvise rigo
2015-08-04 7:30 ` Alex Bennée
2015-08-02 16:44 ` [Qemu-devel] [kvm-unit-tests PATCH v5 00/11] My current MTTCG tests Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150731191712.GI3680@hawk.localdomain \
--to=drjones@redhat.com \
--cc=a.rigo@virtualopensystems.com \
--cc=a.spyridakis@virtualopensystems.com \
--cc=alex.bennee@linaro.org \
--cc=alex@bennee.com \
--cc=claudio.fontana@huawei.com \
--cc=fred.konrad@greensocs.com \
--cc=kvm@vger.kernel.org \
--cc=mark.burton@greensocs.com \
--cc=mttcg@greensocs.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).