Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp55166lqm; Tue, 30 Apr 2024 12:32:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXuzGowWkh/wt1T9hhv1H2oFmqt9sG9Beqp1Pwph05QSIBZTwnpxU11tiVgetJDnPAWMDThD9ZHySrqMChYj2hG4iAVedzXVylCAW6tHQ== X-Google-Smtp-Source: AGHT+IEU3bU6A+TYuBmvnS101tk0PYHi1N4jG0ayeL3htz6KjIrfdhBI8A75bRGqaU+k85UbhISi X-Received: by 2002:a17:90a:d38f:b0:2aa:b57c:b178 with SMTP id q15-20020a17090ad38f00b002aab57cb178mr485678pju.34.1714505578473; Tue, 30 Apr 2024 12:32:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714505578; cv=pass; d=google.com; s=arc-20160816; b=JhBgaL2e8NjH2ZED+iUhRwCVBG0qqL1CbzKNWmuPi5BKXyPP4zuYunfemeFnlwTNg1 yyncXs8VWhq0F22OnUu2Lb20rf18hio0Q4rBCX+ybkm0ebs18p1ZtIIyjypIYqT/y7ni Pjtk1McrH7eB6TVOCOYYzbEuVCABLPHuSaLQT4/QVqoMkT7XhxZ2OfkChnwRELKc5gK9 2w8zgGKsf8aHpYs/lGUFsWrXpAySkUACeOs2Rto/SKtAXwcmCDni0AD14PVv9DSV+fD/ +25ebIPHKGSdovisItls9+dFy7w0RJoU95lTOXn3nU1Bv6g+xLW8BOy625MFgox+Gf/6 P1+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=teE05Ylose2pcYDprhAFOjLN/sOw6wgj1YwY4a/EgBU=; fh=h+9DffERzjU74220b6IyhPHhVcdMiiB8fPUrs0Z5YkQ=; b=KdRcwhU7tEiUvG5AcLLJlF0MOYcp08LQNI3NJABl/oTJMmb+JALDB3qY0WNl18eKUW uakfekwO7I6Kex2DjGmSc89hOZIoOQdXX4wzHsd7RtYNvlwmb1JPM1xOWCJwFqsDCo2q 1HkKlK1hZZxHWrYkNLiAFw4Mq2iSEXw1ygyM1SWrPJ+RwVSdJVxG8npUTu8lrq1c23Ex y8A0NdMofVnXpslOXJvUVx+hEsrkwXxZEfPfJkC9z8Jw/ZKAkED3a66+KVRiKhXK6+BE L+B3Fuk6x+s3J2oVLwHFla922mRkJRy4hPkOZ6MK4a6OViUrY+w/HMSN0sPwwOOrBlta 4wcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pEws91zF; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-164644-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164644-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s8-20020a17090a1c0800b002a2e618912csi20157526pjs.27.2024.04.30.12.32.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 12:32:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164644-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pEws91zF; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-164644-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164644-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4F840B22BAE for ; Tue, 30 Apr 2024 19:32:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 159BA1A0B11; Tue, 30 Apr 2024 19:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pEws91zF" Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E6F4199EBC for ; Tue, 30 Apr 2024 19:32:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714505526; cv=none; b=TerTXFwnnSXmQNKaPsDovsdPoSycpOJOST3Gl7IQaSgh9JN0RU+WcJVDepadlgVbJDmzvVjsJYzTY93e6GA69xdRk/haH3JRWFxN7sAbV54aujKuXQS9hEOTbS7ba1Mz0GVAa3SdA32PWI3zMZq17r7/hgcRqfukNTrXUhX3iqk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714505526; c=relaxed/simple; bh=LpfSAtfaCACOaLvBplHLMq/lCqNS1Zqd5xDlARtwz50=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dAGIqmUJLKcL1584T9BbEHEX+qw2yZUueytP/JJaw90O1QOJBQtEF5qUFMcFWXRMHrPzKE4KF17uMRPTTrR206yPD8kp3cwvQqOQMajoEhuyJWOPAF3sfD1rW1Qm4cJWro67gBNshZDN+d1hqHRgu1o+f20hTcDa7gBsU1zrR3g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pEws91zF; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-5c670f70a37so6249124a12.2 for ; Tue, 30 Apr 2024 12:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714505524; x=1715110324; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=teE05Ylose2pcYDprhAFOjLN/sOw6wgj1YwY4a/EgBU=; b=pEws91zFBG08nKmAbcexKp1RDm1i0jD+JNppz1g4odAPDckiDS2EyY/utf4f2iltAX 3JX8LKG2DoEyY4nTDzeyKavCpWTjUDUVPwacQr3Ii9Wv+yZzRRwV5kdl29ePv4v8m5Oh EUVU7X61csMxGXG1V96eb/Hxhgk+G61QDMfjHb+ughUxynw/jcpIAkY3Fndy0kNQIOxO dcUpkMXbVAo0qtJBimEZq/TEibG2xoiTj+gxnm6eaLs0otz0pEkBc+A8tlw4PPhJfWoD mm/HTvkq+g02ECs6k+jCstGmkvhJlwQp5XQjGB8wuKfm3sKYNqTGWKPCq0kXKkeKlG/K g+ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714505524; x=1715110324; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=teE05Ylose2pcYDprhAFOjLN/sOw6wgj1YwY4a/EgBU=; b=DXMH/aBL12aZyPb2+oLOMENrxEtzuQGPOe+F/dmtx9E2JpSIyIsBFvjxwazd0epVIm 1Y4qAvgZvl7E42GTiHEVGIkYtIa6Wra8XKFYWIG/U2VFNmKX8ZM8QLW7k7Ga0zViolQB kxY+bVf7mKz3u/26mGOox1bLmEpoR5LbuYComlq93kaKFiAJ8o0Qq7e28vbDEXZH13Nc wrBavuPbDh5G0gRzPpE3ZaTfiGXU/0wRloXGdmwHeG1EeaXIAipP0Uvu5M8l6clZ9bS3 wUWcZl/6MjjAvneoTD7YO8H8GyEQrshOh+hk34Bvu8ZGCpwKc6ZdpN+hOC5VWY+XTOxE xzUg== X-Forwarded-Encrypted: i=1; AJvYcCVz1GgC/YmkI7VHhCihIza08FdEIcMrn/LybUZeSaHA2+LfrtIRl6ZlexLcCOECMUXmNxlpEmL+cFCIEnBWEcXBzmie4I/LDB5Trlg/ X-Gm-Message-State: AOJu0YyY01s1fQo4gBij/w6KC0eGFWX6BRYr/pizUecAGLuOrZaE6j1H eaE3MIxQZ517OeURVgN1DLjBglYWef4hZ81A6kIo05AYA2GIeFmeNVKjwAU+c+YzT80O7O/E/p7 h1Q== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a02:6a1:b0:5dc:5111:d8b1 with SMTP id ca33-20020a056a0206a100b005dc5111d8b1mr1313pgb.5.1714505523833; Tue, 30 Apr 2024 12:32:03 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 30 Apr 2024 12:31:55 -0700 In-Reply-To: <20240430193157.419425-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240430193157.419425-1-seanjc@google.com> X-Mailer: git-send-email 2.45.0.rc0.197.gbae5840b3b-goog Message-ID: <20240430193157.419425-3-seanjc@google.com> Subject: [PATCH 2/4] KVM: VMX: Move PLE grow/shrink helpers above vmx_vcpu_load() From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson , Paolo Bonzini Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Move VMX's {grow,shrink}_ple_window() above vmx_vcpu_load() in preparation of moving the sched_in logic, which handles shrinking the PLE window, into vmx_vcpu_load(). No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 64 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 6780313914f8..cb36db7b6140 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1402,6 +1402,38 @@ static void vmx_write_guest_kernel_gs_base(struct vcpu_vmx *vmx, u64 data) } #endif +static void grow_ple_window(struct kvm_vcpu *vcpu) +{ + struct vcpu_vmx *vmx = to_vmx(vcpu); + unsigned int old = vmx->ple_window; + + vmx->ple_window = __grow_ple_window(old, ple_window, + ple_window_grow, + ple_window_max); + + if (vmx->ple_window != old) { + vmx->ple_window_dirty = true; + trace_kvm_ple_window_update(vcpu->vcpu_id, + vmx->ple_window, old); + } +} + +static void shrink_ple_window(struct kvm_vcpu *vcpu) +{ + struct vcpu_vmx *vmx = to_vmx(vcpu); + unsigned int old = vmx->ple_window; + + vmx->ple_window = __shrink_ple_window(old, ple_window, + ple_window_shrink, + ple_window); + + if (vmx->ple_window != old) { + vmx->ple_window_dirty = true; + trace_kvm_ple_window_update(vcpu->vcpu_id, + vmx->ple_window, old); + } +} + void vmx_vcpu_load_vmcs(struct kvm_vcpu *vcpu, int cpu, struct loaded_vmcs *buddy) { @@ -5871,38 +5903,6 @@ int vmx_vcpu_pre_run(struct kvm_vcpu *vcpu) return 1; } -static void grow_ple_window(struct kvm_vcpu *vcpu) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - unsigned int old = vmx->ple_window; - - vmx->ple_window = __grow_ple_window(old, ple_window, - ple_window_grow, - ple_window_max); - - if (vmx->ple_window != old) { - vmx->ple_window_dirty = true; - trace_kvm_ple_window_update(vcpu->vcpu_id, - vmx->ple_window, old); - } -} - -static void shrink_ple_window(struct kvm_vcpu *vcpu) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - unsigned int old = vmx->ple_window; - - vmx->ple_window = __shrink_ple_window(old, ple_window, - ple_window_shrink, - ple_window); - - if (vmx->ple_window != old) { - vmx->ple_window_dirty = true; - trace_kvm_ple_window_update(vcpu->vcpu_id, - vmx->ple_window, old); - } -} - /* * Indicate a busy-waiting vcpu in spinlock. We do not enable the PAUSE * exiting, so only get here on cpu with PAUSE-Loop-Exiting. -- 2.45.0.rc0.197.gbae5840b3b-goog