[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2vOEkJDwlmJ2hv9@google.com>
Date: Wed, 9 Nov 2022 15:58:10 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
thomas.lendacky@....com, jmattson@...gle.com
Subject: Re: [PATCH 07/11] KVM: SVM: do not allocate struct svm_cpu_data
dynamically
On Wed, Nov 09, 2022, Paolo Bonzini wrote:
> The svm_data percpu variable is a pointer, but it is allocated when
> KVM is loaded (via svm_hardware_setup), not at hardware_enable time.
Parantheses.
> Just allocate room for it statically, that is more efficient and
> does not waste any memory compared to the status quo.
>
> Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
Reviewed-by: Sean Christopherson <seanjc@...gle.com>
> @@ -3442,7 +3431,7 @@ static int svm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
>
> static void reload_tss(struct kvm_vcpu *vcpu)
> {
> - struct svm_cpu_data *sd = per_cpu(svm_data, vcpu->cpu);
> + struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, vcpu->cpu);
>
> sd->tss_desc->type = 9; /* available 32/64-bit TSS */
> load_TR_desc();
> @@ -3450,7 +3439,7 @@ static void reload_tss(struct kvm_vcpu *vcpu)
>
> static void pre_svm_run(struct kvm_vcpu *vcpu)
> {
> - struct svm_cpu_data *sd = per_cpu(svm_data, vcpu->cpu);
> + struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, vcpu->cpu);
> struct vcpu_svm *svm = to_svm(vcpu);
>
> /*
> @@ -3919,7 +3908,7 @@ static noinstr void svm_vcpu_enter_exit(struct kvm_vcpu *vcpu)
> if (sev_es_guest(vcpu->kvm)) {
> __svm_sev_es_vcpu_run(svm);
> } else {
> - struct svm_cpu_data *sd = per_cpu(svm_data, vcpu->cpu);
> + struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, vcpu->cpu);
At some point we should replace the vcpu->cpu usage with this_cpu_ptr(). All of
the code that does per_cpu_ptr(&svm_data, vcpu->cpu) is doomed if vcpu->cpu isn't
the current CPU.
Powered by blists - more mailing lists