[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e8488e5c-7372-fc6e-daee-56633028854a@redhat.com>
Date: Sun, 27 Mar 2022 12:43:36 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Jon Kohler <jon@...anix.com>,
Sean Christopherson <seanjc@...gle.com>
Cc: Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"x86@...nel.org" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] KVM: x86: optimize PKU branching in
kvm_load_{guest|host}_xsave_state
On 3/26/22 02:37, Jon Kohler wrote:
>>> Flip the ordering of the || condition so that XFEATURE_MASK_PKRU is
>>> checked first, which when instrumented in our environment appeared
>>> to be always true and less overall work than kvm_read_cr4_bits.
>>
>> If it's always true, then it should be checked last, not first. And if
>
> Sean thanks for the review. This would be a left handed || short circuit, so
> wouldn’t we want always true to be first?
Yes.
>> Not that it really matters, since static_cpu_has() will patch out all the branches,
>> and in practice who cares about a JMP or NOP(s)? But...
>
> The reason I’ve been pursuing this is that the guest+host xsave adds up to
> a bit over ~1% as measured by perf top in an exit heavy workload. This is
> the first in a few patch we’ve drummed up to to get it back towards zero.
> I’ll send the rest out next week.
Can you add a testcase to x86/vmexit.c in kvm-unit-tests, too?
Thanks,
Paolo
Powered by blists - more mailing lists