From patchwork Fri Jul 31 15:53:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 51789 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 36F1D22D9C for ; Fri, 31 Jul 2015 15:58:44 +0000 (UTC) Received: by lafd3 with SMTP id d3sf25809932laf.1 for ; Fri, 31 Jul 2015 08:58:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding:cc :subject:precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=A9sxb5CwBcw0kV17bhtUxp9Juwxxu2hHId3lWCM9urY=; b=IW7C39S/ff5kTlTCSoKEW9URRnqRlIEvMziuKBJLN8BSfizEAZeKQBeCiOH3WSB2Sn zprgE7cOmuUsMWf49sLdLRUL129d6zjyz4WxFY4ZW8t8jNMW4C/dulEPd9QsqipnNdbd JPweFvkPepnInYb5YU54Xz6+2mR/HzfhYkCWQK7cKORoSHQbpP76oqVXofLAh5LBYII0 qIQx59ruYPo+vIYvo1G8Loyuhm7TtQoJe3/8OCh5rNeCaSDOdx9eh2A15A1HpvJI3WHs MstNxlJiGymB4QHZCI2zSHSKy3XHLjMsOf6cWQhljoG3BifD/gmvB5C508hF17nHVleD 3akg== X-Gm-Message-State: ALoCoQkWwxaxL+QgN+d+tDUd6H6LCyy7UArhA30f8iy0/51VUx3twDSXvCVMM6j6jAlvyAoFatQp X-Received: by 10.152.87.46 with SMTP id u14mr1142376laz.5.1438358323212; Fri, 31 Jul 2015 08:58:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.100 with SMTP id j4ls341440lah.9.gmail; Fri, 31 Jul 2015 08:58:42 -0700 (PDT) X-Received: by 10.152.28.105 with SMTP id a9mr3859353lah.9.1438358322547; Fri, 31 Jul 2015 08:58:42 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id n14si4125712laa.83.2015.07.31.08.58.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Jul 2015 08:58:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lacct8 with SMTP id ct8so13783812lac.2 for ; Fri, 31 Jul 2015 08:58:42 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr3845739lal.35.1438358322402; Fri, 31 Jul 2015 08:58:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp474546lba; Fri, 31 Jul 2015 08:58:41 -0700 (PDT) X-Received: by 10.140.232.131 with SMTP id d125mr5719970qhc.1.1438358320991; Fri, 31 Jul 2015 08:58:40 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j63si6363974qgd.48.2015.07.31.08.58.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 31 Jul 2015 08:58:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:44898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLChk-0000Ok-0Q for patch@linaro.org; Fri, 31 Jul 2015 11:58:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLCdq-0000zD-4O for qemu-devel@nongnu.org; Fri, 31 Jul 2015 11:54:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZLCdi-0005uv-Ha for qemu-devel@nongnu.org; Fri, 31 Jul 2015 11:54:38 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:36631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLCdi-0005ul-9X for qemu-devel@nongnu.org; Fri, 31 Jul 2015 11:54:30 -0400 Received: by wicgj17 with SMTP id gj17so23709349wic.1 for ; Fri, 31 Jul 2015 08:54:29 -0700 (PDT) X-Received: by 10.194.89.98 with SMTP id bn2mr7878195wjb.153.1438358069610; Fri, 31 Jul 2015 08:54:29 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z9sm5110481wiv.9.2015.07.31.08.54.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Jul 2015 08:54:28 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 6C43D3E135D; Fri, 31 Jul 2015 16:54:23 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, mark.burton@greensocs.com, fred.konrad@greensocs.com Date: Fri, 31 Jul 2015 16:53:59 +0100 Message-Id: <1438358041-18021-10-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438358041-18021-1-git-send-email-alex.bennee@linaro.org> References: <1438358041-18021-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.169 Cc: peter.maydell@linaro.org, drjones@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvm@vger.kernel.org, a.spyridakis@virtualopensystems.com, claudio.fontana@huawei.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [Qemu-devel] [kvm-unit-tests PATCH v5 09/11] arm: query /dev/kvm for maximum vcpus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Alex Bennée 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. 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 --- 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 +#include +#include +#include +#include + +#include +#include + +#include + +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