[PATCH] KVM: arm64: Remove redundant check for S2FWB

Jing Zhang jingzhangos at google.com
Fri Feb 5 13:56:41 EST 2021


Hi Marc,

Thanks for the comment.
On Fri, Feb 5, 2021 at 11:24 AM Marc Zyngier <maz at kernel.org> wrote:
>
> Hi Jing,
>
> On 2021-02-05 04:44, Jing Zhang wrote:
> > Remove redundant check for CPU feature S2FWB in dcache flush code
> > to save some CPU cycles for every memslot flush and unmapping.
>
> What CPU cycles? This is only a static branch. Can you actually
> measure the overhead? What does it represent in the face of
> a full memslot unmapping?
For CPU cycles, I mean CPU time spent for S2FWB check.
For memslot unmapping, there is actually no improvement, just move the
check to the stage2_unmap_walker since we removed the S2FWB check in
stage2_flush_dcache.
The saving is from the code path of memslot flush. The S2FWB check was
in stage2_flush_dcache, in which case, for a memslot flush, the check
was done for every page. Now it will save some CPU time if we do the
check at a higher level, like in kvm_toggle_cache, access_dcsw,
kvm_arch_prepare_memory_region.
The redundant check is as follows (Only the first check is necessary):
kvm_arch_prepare_memory_region -> S2FWB check -> stage2_flush_memslot
-> kvm_pgtable_stage2_flush -> S2FWB check -> stage2_flush_walker ->
S2FWB check -> __flush_dcache_area

>
> Thanks,
>
>          M.
> --
> Jazz is not dead. It just smells funny...



More information about the linux-arm-kernel mailing list