From patchwork Wed Aug 16 05:14:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 9903025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AF8CB6028A for ; Wed, 16 Aug 2017 05:17:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A17E9288B3 for ; Wed, 16 Aug 2017 05:17:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 960A028966; Wed, 16 Aug 2017 05:17:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E8B2288C3 for ; Wed, 16 Aug 2017 05:17:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhqfs-0002Hd-UY; Wed, 16 Aug 2017 05:15:24 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhqfr-0002HD-VC for xen-devel@lists.xen.org; Wed, 16 Aug 2017 05:15:24 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 53/8A-09901-BE4D3995; Wed, 16 Aug 2017 05:15:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsVywNykWPfVlcm RBpMPaFos+biYxYHR4+ju30wBjFGsmXlJ+RUJrBnTZ55kK7jCV7F59kK2BsaDPF2MXBxCAtMZ JVZ+P8nSxcjJISHAK3Fk2QxWCNtfYt2ES2BxIYFyiYPtW5hBbDYBZYmLX3vZQGwRAWmJa58vM 4LYzAL5Ek37J4DVCwu4Ssz8/hIozsHBIqAq8fBdOkiYV8BJ4s+zbkaI8QoSUx6+ZwYp4RRwlu ibYQGxyUni2Yeb7BMYeRcwMqxi1ChOLSpLLdI1MtdLKspMzyjJTczM0TU0MNPLTS0uTkxPzUl MKtZLzs/dxAgMBQYg2MG4eG3gIUZJDiYlUd5FZydFCvEl5adUZiQWZ8QXleakFh9ilOHgUJLg tbk8OVJIsCg1PbUiLTMHGJQwaQkOHiUR3u0gad7igsTc4sx0iNQpRl2OVxP+f2MSYsnLz0uVE udNACkSACnKKM2DGwGLkEuMslLCvIxARwnxFKQW5WaWoMq/YhTnYFQS5m0EmcKTmVcCt+kV0B FMQEdcaZ8EckRJIkJKqoHRh/dWnfpHy1MzLPp3rJ5Y9Ihh9q5beu9jPIPDLjd+5xaYee0o66t 38Trrj9T8q9mhJ77htXTtq6i6dZ2+HvE73y6b0hfRtkDqyL+9F2Vdtx2brFPa03mn0FOL9+Th uY5rWI/12h8PPHFiAcOcpCmvZENE31uG3YquupySttsudnVlFu/tqh0rlFiKMxINtZiLihMBV Uz+FIsCAAA= X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1502860516!88773518!3 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35041 invoked from network); 16 Aug 2017 05:15:22 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-10.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 16 Aug 2017 05:15:22 -0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Aug 2017 22:15:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,381,1498546800"; d="scan'208";a="890430533" Received: from skl-2s3.sh.intel.com ([10.239.48.12]) by FMSMGA003.fm.intel.com with ESMTP; 15 Aug 2017 22:15:20 -0700 From: Chao Gao To: xen-devel@lists.xen.org Date: Wed, 16 Aug 2017 13:14:36 +0800 Message-Id: <1502860478-84512-3-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502860478-84512-1-git-send-email-chao.gao@intel.com> References: <1502860478-84512-1-git-send-email-chao.gao@intel.com> Cc: Andrew Cooper , Jan Beulich , Chao Gao Subject: [Xen-devel] [PATCH v5 2/4] x86/vcpu: track hvm vcpu number on the system X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This number is used to calculate the average vcpus per pcpu ratio. Signed-off-by: Chao Gao Acked-by: Jan Beulich --- v4: - move the place we increase/decrease the hvm vcpu number to hvm_vcpu_{initialise, destory} --- xen/arch/x86/hvm/hvm.c | 6 ++++++ xen/include/asm-x86/hvm/hvm.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 555133f..37afdb4 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -109,6 +109,9 @@ static const char __initconst warning_hvm_fep[] = static bool_t __initdata opt_altp2m_enabled = 0; boolean_param("altp2m", opt_altp2m_enabled); +/* Total number of HVM vCPUs on this system */ +atomic_t num_hvm_vcpus; + static int cpu_callback( struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -1511,6 +1514,7 @@ int hvm_vcpu_initialise(struct vcpu *v) hvm_update_guest_vendor(v); + atomic_inc(&num_hvm_vcpus); return 0; fail6: @@ -1529,6 +1533,8 @@ int hvm_vcpu_initialise(struct vcpu *v) void hvm_vcpu_destroy(struct vcpu *v) { + atomic_dec(&num_hvm_vcpus); + viridian_vcpu_deinit(v); hvm_all_ioreq_servers_remove_vcpu(v->domain, v); diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index b687e03..c51bd9f 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #ifdef CONFIG_HVM_FEP @@ -233,6 +234,8 @@ extern bool_t hvm_enabled; extern bool_t cpu_has_lmsl; extern s8 hvm_port80_allowed; +extern atomic_t num_hvm_vcpus; + extern const struct hvm_function_table *start_svm(void); extern const struct hvm_function_table *start_vmx(void);