From: Sean Christopherson <seanjc@google.com>
To: kvm-riscv@lists.infradead.org
Subject: [PATCH v2 3/6] KVM: x86: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load()
Date: Tue, 28 May 2024 12:16:11 -0700 [thread overview]
Message-ID: <ZlYte16cvQpPGHkx@google.com> (raw)
In-Reply-To: <c77f3931-31b2-4695-bd74-c69cba9b96c1@intel.com>
On Fri, May 24, 2024, Kai Huang wrote:
> > @@ -1548,6 +1548,9 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > struct vcpu_svm *svm = to_svm(vcpu);
> > struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, cpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> [...]
>
> > @@ -1517,6 +1517,9 @@ void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > {
> > struct vcpu_vmx *vmx = to_vmx(vcpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> Nit: Perhaps we need a kvm_x86_ops::shrink_ple_window()? :-)
Heh, that duplicate code annoys me too. The problem is the "old" window value
comes from the VMCS/VMCB, so either we'd end up with multiple kvm_x86_ops, or
we'd only be able to consolidate the scheduled_out + kvm_pause_in_guest() code,
which isn't all that interesting.
Aha! Actually, VMX already open codes the functionality provided by VCPU_EXREG_*,
e.g. has vmx->ple_window_dirty. If we add VCPU_EXREG_PLE_WINDOW, then the info
get be made available to common x86 code without having to add new hooks. And
that would also allow moving the guts of handle_pause()/pause_interception() to
common code, i.e. will also allow deduplicating the "grow" side of things.
WARNING: multiple messages have this Message-ID (diff)
From: Sean Christopherson <seanjc@google.com>
To: Kai Huang <kai.huang@intel.com>
Cc: Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
Tianrui Zhao <zhaotianrui@loongson.cn>,
Bibo Mao <maobibo@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Anup Patel <anup@brainfault.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
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
Subject: Re: [PATCH v2 3/6] KVM: x86: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load()
Date: Tue, 28 May 2024 12:16:11 -0700 [thread overview]
Message-ID: <ZlYte16cvQpPGHkx@google.com> (raw)
In-Reply-To: <c77f3931-31b2-4695-bd74-c69cba9b96c1@intel.com>
On Fri, May 24, 2024, Kai Huang wrote:
> > @@ -1548,6 +1548,9 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > struct vcpu_svm *svm = to_svm(vcpu);
> > struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, cpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> [...]
>
> > @@ -1517,6 +1517,9 @@ void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > {
> > struct vcpu_vmx *vmx = to_vmx(vcpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> Nit: Perhaps we need a kvm_x86_ops::shrink_ple_window()? :-)
Heh, that duplicate code annoys me too. The problem is the "old" window value
comes from the VMCS/VMCB, so either we'd end up with multiple kvm_x86_ops, or
we'd only be able to consolidate the scheduled_out + kvm_pause_in_guest() code,
which isn't all that interesting.
Aha! Actually, VMX already open codes the functionality provided by VCPU_EXREG_*,
e.g. has vmx->ple_window_dirty. If we add VCPU_EXREG_PLE_WINDOW, then the info
get be made available to common x86 code without having to add new hooks. And
that would also allow moving the guts of handle_pause()/pause_interception() to
common code, i.e. will also allow deduplicating the "grow" side of things.
WARNING: multiple messages have this Message-ID (diff)
From: Sean Christopherson <seanjc@google.com>
To: Kai Huang <kai.huang@intel.com>
Cc: Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
Tianrui Zhao <zhaotianrui@loongson.cn>,
Bibo Mao <maobibo@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Anup Patel <anup@brainfault.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
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
Subject: Re: [PATCH v2 3/6] KVM: x86: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load()
Date: Tue, 28 May 2024 12:16:11 -0700 [thread overview]
Message-ID: <ZlYte16cvQpPGHkx@google.com> (raw)
In-Reply-To: <c77f3931-31b2-4695-bd74-c69cba9b96c1@intel.com>
On Fri, May 24, 2024, Kai Huang wrote:
> > @@ -1548,6 +1548,9 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > struct vcpu_svm *svm = to_svm(vcpu);
> > struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, cpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> [...]
>
> > @@ -1517,6 +1517,9 @@ void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > {
> > struct vcpu_vmx *vmx = to_vmx(vcpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> Nit: Perhaps we need a kvm_x86_ops::shrink_ple_window()? :-)
Heh, that duplicate code annoys me too. The problem is the "old" window value
comes from the VMCS/VMCB, so either we'd end up with multiple kvm_x86_ops, or
we'd only be able to consolidate the scheduled_out + kvm_pause_in_guest() code,
which isn't all that interesting.
Aha! Actually, VMX already open codes the functionality provided by VCPU_EXREG_*,
e.g. has vmx->ple_window_dirty. If we add VCPU_EXREG_PLE_WINDOW, then the info
get be made available to common x86 code without having to add new hooks. And
that would also allow moving the guts of handle_pause()/pause_interception() to
common code, i.e. will also allow deduplicating the "grow" side of things.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Sean Christopherson <seanjc@google.com>
To: Kai Huang <kai.huang@intel.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Marc Zyngier <maz@kernel.org>,
Janosch Frank <frankja@linux.ibm.com>,
Huacai Chen <chenhuacai@kernel.org>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Albert Ou <aou@eecs.berkeley.edu>, Bibo Mao <maobibo@loongson.cn>,
loongarch@lists.linux.dev,
Paul Walmsley <paul.walmsley@sifive.com>,
kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-mips@vger.kernel.org, Oliver Upton <oliver.upton@linux.dev>,
Palmer Dabbelt <palmer@dabbelt.com>,
kvm-riscv@lists.infradead.org, Anup Patel <anup@brainfault.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Tianrui Zhao <zhaotianrui@loongson.cn>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 3/6] KVM: x86: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load()
Date: Tue, 28 May 2024 12:16:11 -0700 [thread overview]
Message-ID: <ZlYte16cvQpPGHkx@google.com> (raw)
In-Reply-To: <c77f3931-31b2-4695-bd74-c69cba9b96c1@intel.com>
On Fri, May 24, 2024, Kai Huang wrote:
> > @@ -1548,6 +1548,9 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > struct vcpu_svm *svm = to_svm(vcpu);
> > struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, cpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> [...]
>
> > @@ -1517,6 +1517,9 @@ void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > {
> > struct vcpu_vmx *vmx = to_vmx(vcpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> Nit: Perhaps we need a kvm_x86_ops::shrink_ple_window()? :-)
Heh, that duplicate code annoys me too. The problem is the "old" window value
comes from the VMCS/VMCB, so either we'd end up with multiple kvm_x86_ops, or
we'd only be able to consolidate the scheduled_out + kvm_pause_in_guest() code,
which isn't all that interesting.
Aha! Actually, VMX already open codes the functionality provided by VCPU_EXREG_*,
e.g. has vmx->ple_window_dirty. If we add VCPU_EXREG_PLE_WINDOW, then the info
get be made available to common x86 code without having to add new hooks. And
that would also allow moving the guts of handle_pause()/pause_interception() to
common code, i.e. will also allow deduplicating the "grow" side of things.
WARNING: multiple messages have this Message-ID (diff)
From: Sean Christopherson <seanjc@google.com>
To: Kai Huang <kai.huang@intel.com>
Cc: Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
Tianrui Zhao <zhaotianrui@loongson.cn>,
Bibo Mao <maobibo@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Anup Patel <anup@brainfault.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
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
Subject: Re: [PATCH v2 3/6] KVM: x86: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load()
Date: Tue, 28 May 2024 12:16:11 -0700 [thread overview]
Message-ID: <ZlYte16cvQpPGHkx@google.com> (raw)
In-Reply-To: <c77f3931-31b2-4695-bd74-c69cba9b96c1@intel.com>
On Fri, May 24, 2024, Kai Huang wrote:
> > @@ -1548,6 +1548,9 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > struct vcpu_svm *svm = to_svm(vcpu);
> > struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, cpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> [...]
>
> > @@ -1517,6 +1517,9 @@ void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> > {
> > struct vcpu_vmx *vmx = to_vmx(vcpu);
> > + if (vcpu->scheduled_out && !kvm_pause_in_guest(vcpu->kvm))
> > + shrink_ple_window(vcpu);
> > +
>
> Nit: Perhaps we need a kvm_x86_ops::shrink_ple_window()? :-)
Heh, that duplicate code annoys me too. The problem is the "old" window value
comes from the VMCS/VMCB, so either we'd end up with multiple kvm_x86_ops, or
we'd only be able to consolidate the scheduled_out + kvm_pause_in_guest() code,
which isn't all that interesting.
Aha! Actually, VMX already open codes the functionality provided by VCPU_EXREG_*,
e.g. has vmx->ple_window_dirty. If we add VCPU_EXREG_PLE_WINDOW, then the info
get be made available to common x86 code without having to add new hooks. And
that would also allow moving the guts of handle_pause()/pause_interception() to
common code, i.e. will also allow deduplicating the "grow" side of things.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-05-28 19:16 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 1:40 [PATCH v2 0/6] KVM: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load() Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` [PATCH v2 1/6] KVM: Add a flag to track if a loaded vCPU is scheduled out Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 15:16 ` Oliver Upton
2024-05-22 15:16 ` Oliver Upton
2024-05-22 15:16 ` Oliver Upton
2024-05-22 15:16 ` Oliver Upton
2024-05-22 15:16 ` Oliver Upton
2024-05-22 1:40 ` [PATCH v2 2/6] KVM: VMX: Move PLE grow/shrink helpers above vmx_vcpu_load() Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` [PATCH v2 3/6] KVM: x86: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load() Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-23 22:47 ` Huang, Kai
2024-05-23 22:47 ` Huang, Kai
2024-05-23 22:47 ` Huang, Kai
2024-05-23 22:47 ` Huang, Kai
2024-05-23 22:47 ` Huang, Kai
2024-05-28 19:16 ` Sean Christopherson [this message]
2024-05-28 19:16 ` Sean Christopherson
2024-05-28 19:16 ` Sean Christopherson
2024-05-28 19:16 ` Sean Christopherson
2024-05-28 19:16 ` Sean Christopherson
2024-05-29 10:50 ` Huang, Kai
2024-05-29 10:50 ` Huang, Kai
2024-05-29 10:50 ` Huang, Kai
2024-05-29 10:50 ` Huang, Kai
2024-05-29 10:50 ` Huang, Kai
2024-05-29 12:54 ` Sean Christopherson
2024-05-29 12:54 ` Sean Christopherson
2024-05-29 12:54 ` Sean Christopherson
2024-05-29 12:54 ` Sean Christopherson
2024-05-29 12:54 ` Sean Christopherson
2024-05-22 1:40 ` [PATCH v2 4/6] KVM: Delete the now unused kvm_arch_sched_in() Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-24 1:50 ` maobibo
2024-05-24 1:50 ` maobibo
2024-05-24 1:50 ` maobibo
2024-05-24 1:50 ` maobibo
2024-05-24 1:50 ` maobibo
2024-05-22 1:40 ` [PATCH v2 5/6] KVM: x86: Unconditionally set l1tf_flush_l1d during vCPU load Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-23 22:42 ` Huang, Kai
2024-05-23 22:42 ` Huang, Kai
2024-05-23 22:42 ` Huang, Kai
2024-05-23 22:42 ` Huang, Kai
2024-05-23 22:42 ` Huang, Kai
2024-05-22 1:40 ` [PATCH v2 6/6] KVM: x86: Drop now-superflous setting of l1tf_flush_l1d in vcpu_run() Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-22 1:40 ` Sean Christopherson
2024-05-23 22:48 ` [PATCH v2 0/6] KVM: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load() Huang, Kai
2024-05-23 22:48 ` Huang, Kai
2024-05-23 22:48 ` Huang, Kai
2024-05-23 22:48 ` Huang, Kai
2024-05-23 22:48 ` Huang, Kai
2024-06-12 1:18 ` Sean Christopherson
2024-06-12 1:18 ` Sean Christopherson
2024-06-12 1:18 ` Sean Christopherson
2024-06-12 1:18 ` Sean Christopherson
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=ZlYte16cvQpPGHkx@google.com \
--to=seanjc@google.com \
--cc=kvm-riscv@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.