Received: by 10.223.185.116 with SMTP id b49csp174005wrg; Fri, 2 Mar 2018 16:14:16 -0800 (PST) X-Google-Smtp-Source: AG47ELtMevnNLsogW46q2GSWJXO/YDZu9j1JKq9wzQ1NPo6CDDpDY0MDTpmYALj2WoG59/hkgslH X-Received: by 10.101.80.193 with SMTP id s1mr5878952pgp.254.1520036055949; Fri, 02 Mar 2018 16:14:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520036055; cv=none; d=google.com; s=arc-20160816; b=RcMKsz6rj2mJ6P6WzhXTGD507EsDqI85xQxOC+eY2eVmOUgWSX50si+nm1HwSdHty3 WuOnh1J5mwQllI06mjiyJiFGq5o3PkoWkfTFjhjIs/niY/mFbuqUKrdyeC4raOhD7HU6 7jmLL0ft8GcBTKQdXjnbLMobKcQ0h2Hqa6kMB5/xplzviE2ai/uUFJBVgo+9v/oOhUnx q0GVL6yqLGC9vL4UhdutkLhCRUwbXdgy/vAaJquGVlWI6o97h3GGcfRzn90PR71mSmyN D3nJi6MkF+ez1sN2lq/XASFiNZqRH8O6s2bjNvwVRJ9WmraWmGJZF9eW6gHnowECG45j hJOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=c1cfXFZLL+b7XLDuuGitP4shPuprgGYYesE8VbGD2Ug=; b=cDVc3SXgz1/awqTxBM/xChnKXlOfOF8x4mmN/iMyxXTUoqQWzuwN0akwFXpvm88h7Y xYSvoG4ACn1hAJBKqY0HuJIxaN9HiRcicoruRz0ZcipGhSWz/xxLEdOxccKj7oysQGp7 F2Mv/M27mq2lFvRw/KyVBlNmurDqz4eAKYVhfmIU4bbzWOVdOFyuy5hrZqrWO+E6ol7a LeKru//OHYZdWlLX+93xW3FI8SMYowIiuiYK+FYwkg9sEtMMiCark+rsskbZcZTfd7J2 Jk/MT1RDx2RpcfsOlVUROR6t3X1CNhklBXqaEmf35PSmubJhT8VBqrNhgpL4EXpxXvmS 1wNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=IY0oxO2k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9si2280834pgs.541.2018.03.02.16.13.43; Fri, 02 Mar 2018 16:14:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=IY0oxO2k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936408AbeCBQSL (ORCPT + 99 others); Fri, 2 Mar 2018 11:18:11 -0500 Received: from mail-by2nam01on0044.outbound.protection.outlook.com ([104.47.34.44]:42045 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934083AbeCBQSF (ORCPT ); Fri, 2 Mar 2018 11:18:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=c1cfXFZLL+b7XLDuuGitP4shPuprgGYYesE8VbGD2Ug=; b=IY0oxO2kMQpb8eej0gHKkskaR3EQKVRNF1PmPORkscAGgRLYrlu+uwC4/FRvBRZ8Z9oArmgrJVUWivc47tqUi0Kjwyg/j67PVEPM9BRWlnIH48iaTKGQYAMzI8yofwVQZ22maqiz2hLSZRkrSa8nTbp+yRvqe7Pyw0ejxQGSl3k= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from linux-pyp0.amd.com (165.204.77.1) by BN6PR12MB1761.namprd12.prod.outlook.com (10.175.101.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.548.13; Fri, 2 Mar 2018 16:17:57 +0000 From: Babu Moger To: joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org Cc: babu.moger@amd.com, pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 2/3] arch/x86/kvm: VMX: Bring the common code to header file Date: Fri, 2 Mar 2018 11:17:35 -0500 Message-Id: <1520007456-85293-3-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1520007456-85293-1-git-send-email-babu.moger@amd.com> References: <1520007456-85293-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR14CA0041.namprd14.prod.outlook.com (10.171.172.155) To BN6PR12MB1761.namprd12.prod.outlook.com (10.175.101.22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 080d59b5-3a33-4136-71d4-08d58059294a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:BN6PR12MB1761; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1761;3:QIWvvBAsiWKKktUVA5AZDbNF0W/Z72HxrJOV67v0kVeVkl//1iYmduMycsHZPNIyjP1KDAKauu/lBZEHZkFvOMQFt2W5QAjNMAGStf3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D8Mu3qLCiXF00OF6Uks5VRNDwtGS2RDSsk071IDL2QvtDBXWdm2goLyrHontj5lF7wXTNjD8vwgHyKwx2cyK1wf+EEeKilGEtA68CnxZIPN0oqe6a/lLu32E1FaBFn2deGXAjloSGhgnjpKYtNnKRnSQsR1/2ps+fmfrsMJaH/JMz2iydFx/2pc2xim/9QLmbFeP4NF9p70SgIs824aZeAn7odytkY8VaB8BcI7xTulD8GoQh7iXdQ1/FNaxmWs;4:Vkv0cpmNou+qu8I0dXZMsAV/FL0Fn9Mvs2BWiqNiGjiC9wzvtheYHEgUVNli6Nj7niPYn6Xn+60aQ4jJCm8s1cuqq/5pWarKBmvKx3A1Uis6FtQWWRvZ1Law/FgOP/v3g04QQBLVNMl1ba5EFiEna+7LQaMQZk+XPCHX38dpVoitCwAZO2MZAiwYUN5Wo8dbn0uohjrykLaQrmgRbnZBULZIcSWGJOGpY3Cfz1p2nmo+SQv3QiqP75WVcPUsERRVDMPhVMvEV1tvrM7qwpt7tNB7l+plH0LzE7WbvHNOJBAJoadwvIWRDM7fSxRhne0P X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040501)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231220)(944501161)(10201501046)(6055026)(6041288)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:BN6PR12MB1761;BCL:0;PCL:0;RULEID:;SRVR:BN6PR12MB1761; X-Forefront-PRVS: 05991796DF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(396003)(39380400002)(39860400002)(366004)(346002)(199004)(189003)(51416003)(2950100002)(386003)(53936002)(186003)(26005)(7696005)(6486002)(52116002)(16526019)(68736007)(6666003)(4720700003)(76176011)(106356001)(16586007)(59450400001)(316002)(8936002)(50226002)(4326008)(5660300001)(36756003)(81166006)(86362001)(48376002)(50466002)(575784001)(81156014)(2906002)(7736002)(3846002)(66066001)(105586002)(305945005)(8676002)(53416004)(47776003)(97736004)(6116002)(478600001)(72206003)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1761;H:linux-pyp0.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR12MB1761;23:WU5l4TgvrJD5E/OZMJ4HTsXvltM0epbZc6sn/idxP?= =?us-ascii?Q?gaiMlg2WTzeO3wct9taz6QNY5fCM5b2nh5amAVYGKaI1dQ3v+X8PUz+7+0Nw?= =?us-ascii?Q?+L/tLFPlvm1MpWt9s6MYD/0glYHsJRJ7vhm71znaCPJyZezv03rBmU1cZHzL?= =?us-ascii?Q?Rd5MhgCuOZk8g+bQHXxXuhJiVWSc6OBC6gOnpg/nEiSy5DBrHl2PxCJm8Q6n?= =?us-ascii?Q?3DEP+OA/mliww03bOkPRc2NUgmfUzelsbjjWq6OU/SyHNYNyZXxVgzwlq9W7?= =?us-ascii?Q?5msznd4H8/t6GofL9YoYNpacqkI258fVUTT3KRe45rwzxYw5OWlDgYsF86JJ?= =?us-ascii?Q?tlPwwPBbwshs3Bec5ryuOayuuqBLMQBSokqGq8/8YbLpBO0on3VsDLcOg6nK?= =?us-ascii?Q?OuD7BMitiZkn1HRycb0If8K05EHn7ODmbzCEC8vKJDV78Ibp0RV2kais07JD?= =?us-ascii?Q?Fe0sMQriChXt61egwIzfdAzk6UScOGY4xbtSnuFsCRnp13x3nzyAAPqgB26a?= =?us-ascii?Q?devIZHwjePhJoOo9bt0hux6T5W05msrkvIHfGDDved2iq0jtls1wxyVP7WFy?= =?us-ascii?Q?cRDxqYMXUX0ibH/OJfiNpl7rtgdfyhkY3iGp9DY+pS/WhR9byhnYZyMMKKH3?= =?us-ascii?Q?cknh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/Q=;5:BXgmhxF4BUTkxddCqnOw9vPCgfiBfhDX6PxGGps0J6RIGJ4sXuQxVwlKBBrVhNLzKg/0buCtIU+j9ov6G68af9cTNy/wNVVTZPzxGsgkq0e/9xDyiY0duGYYeksOPjTsO9Tb672BLt4qqa7CzQdnpswKWKoGpNYuEnbGuBHrr9g=;24:Ay15W1ns5Rb4C0NApkYG8WCRfDbcL7+wCp+i6uUig6HS5/kWcxuH38et2rZtblcVyrDTF7Ztno3c0RZuU0J5lJAP0NUgrWmETyy3nAEHFJU=;7:ZJgSR+E4vj32A/B5MZqENuC4egg9RlOLVS/ctktVdkmNEz5qFpZbFtPq65OEI2R4uHA4suMTK0ydad6s6oRpW0Fr5eB2m8/NRxhUFBDaH2dTcwmrGfGR5PjGcOxeOnBZH9wfIe4z4AG2S220rL2YLRz/Vu3PHHxkJWD/yakqYPDOZNisD0+1Mp+FrpdKM6M0vGaJ20ilFI+waGCyvPLytL2hwIA95pqKY1FjLdY9R7jJAK67wa7FDUKh0JFsAZRU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1761;20:pa17tYMAMoqP6wzAsbBvn7VqHwn6WFeWSYH3KxhZtfZNj4/gVH64JusWS+iBo+tjONCbBmSjUSvGmggmPQo8sw7XEDjQwE6qDoAbyg/qbyiXGoW5Y7gV5xF6GEI2hGRaPK3MBfc3qQGX+RpihvlooR9jdWPZ8IVCafqUNlpEroajAnw9xwxK/ECtaK/NmeqdPmcSHUolTAymxkFhA33GLjFiRroYsmFlhS6J5G9Dz3BXmP61vVbrMex/6bdWAXi1 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2018 16:17:57.0828 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 080d59b5-3a33-4136-71d4-08d58059294a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1761 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is brings some of the code from vmx to x86.h. We can share this code between vmx and svm. Modified couple of functions to make it common. No functional change. Signed-off-by: Babu Moger --- arch/x86/kvm/vmx.c | 53 ++++++++++------------------------------------------- arch/x86/kvm/x86.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index c829d89..6b9fa7e 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -156,25 +156,19 @@ * Time is measured based on a counter that runs at the same rate as the TSC, * refer SDM volume 3b section 21.6.13 & 22.1.3. */ -#define KVM_VMX_DEFAULT_PLE_GAP 128 -#define KVM_VMX_DEFAULT_PLE_WINDOW 4096 -#define KVM_VMX_DEFAULT_PLE_WINDOW_GROW 2 -#define KVM_VMX_DEFAULT_PLE_WINDOW_SHRINK 0 -#define KVM_VMX_DEFAULT_PLE_WINDOW_MAX \ - INT_MAX / KVM_VMX_DEFAULT_PLE_WINDOW_GROW - -static int ple_gap = KVM_VMX_DEFAULT_PLE_GAP; + +static int ple_gap = KVM_DEFAULT_PLE_GAP; module_param(ple_gap, int, S_IRUGO); -static int ple_window = KVM_VMX_DEFAULT_PLE_WINDOW; +static int ple_window = KVM_DEFAULT_PLE_WINDOW; module_param(ple_window, int, S_IRUGO); /* Default doubles per-vcpu window every exit. */ -static int ple_window_grow = KVM_VMX_DEFAULT_PLE_WINDOW_GROW; +static int ple_window_grow = KVM_DEFAULT_PLE_WINDOW_GROW; module_param(ple_window_grow, int, S_IRUGO); /* Default resets per-vcpu window every exit to ple_window. */ -static int ple_window_shrink = KVM_VMX_DEFAULT_PLE_WINDOW_SHRINK; +static int ple_window_shrink = KVM_DEFAULT_PLE_WINDOW_SHRINK; module_param(ple_window_shrink, int, S_IRUGO); /* Default is to compute the maximum so we can never overflow. */ @@ -6640,40 +6634,13 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu) return ret; } -static int __grow_ple_window(int val) -{ - if (ple_window_grow < 1) - return ple_window; - - val = min(val, ple_window_actual_max); - - if (ple_window_grow < ple_window) - val *= ple_window_grow; - else - val += ple_window_grow; - - return val; -} - -static int __shrink_ple_window(int val, int modifier, int minimum) -{ - if (modifier < 1) - return ple_window; - - if (modifier < ple_window) - val /= modifier; - else - val -= modifier; - - return max(val, minimum); -} - static void grow_ple_window(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); int old = vmx->ple_window; - vmx->ple_window = __grow_ple_window(old); + vmx->ple_window = __grow_ple_window(old, ple_window, ple_window_grow, + ple_window_actual_max); if (vmx->ple_window != old) vmx->ple_window_dirty = true; @@ -6686,7 +6653,7 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu) struct vcpu_vmx *vmx = to_vmx(vcpu); int old = vmx->ple_window; - vmx->ple_window = __shrink_ple_window(old, + vmx->ple_window = __shrink_ple_window(old, ple_window, ple_window_shrink, ple_window); if (vmx->ple_window != old) @@ -6706,8 +6673,8 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu) static void update_ple_window_actual_max(void) { ple_window_actual_max = - __shrink_ple_window(max(ple_window_max, ple_window), - ple_window_grow, INT_MIN); + __shrink_ple_window(max(ple_window_max, ple_window), + ple_window, ple_window_grow, INT_MIN); } /* diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index d0b95b7..d1fb7bb 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -9,7 +9,41 @@ #include "kvm_cache_regs.h" #define MSR_IA32_CR_PAT_DEFAULT 0x0007040600070406ULL +#define KVM_DEFAULT_PLE_GAP 128 +#define KVM_DEFAULT_PLE_WINDOW 4096 +#define KVM_DEFAULT_PLE_WINDOW_GROW 2 +#define KVM_DEFAULT_PLE_WINDOW_SHRINK 0 +#define KVM_VMX_DEFAULT_PLE_WINDOW_MAX \ + (INT_MAX / KVM_DEFAULT_PLE_WINDOW_GROW) + +static inline int __grow_ple_window(int val, int base, int modifier, int max) +{ + if (modifier < 1) + return base; + + val = min(val, max); + + if (modifier < base) + val *= modifier; + else + val += modifier; + + return val; +} +static inline int __shrink_ple_window(int val, int base, int modifier, + int minimum) +{ + if (modifier < 1) + return base; + + if (modifier < base) + val /= modifier; + else + val -= modifier; + + return max(val, minimum); +} static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu) { vcpu->arch.exception.injected = false; -- 1.8.3.1