• Mark Brown's avatar
    arm64/sve: Leave SVE enabled on syscall if we don't context switch · 8c845e27
    Mark Brown authored
    The syscall ABI says that the SVE register state not shared with FPSIMD
    may not be preserved on syscall, and this is the only mechanism we have
    in the ABI to stop tracking the extra SVE state for a process. Currently
    we do this unconditionally by means of disabling SVE for the process on
    syscall, causing userspace to take a trap to EL1 if it uses SVE again.
    These extra traps result in a noticeable overhead for using SVE instead
    of FPSIMD in some workloads, especially for simple syscalls where we can
    return directly to userspace and would not otherwise need to update the
    floating point registers. Tests with fp-pidbench show an approximately
    70% overhead on a range of implementations when SVE is in use - while
    this is an extreme and entirely artificial benchmark it is clear that
    there is some useful room for improvement here.
    
    Now that we have the ability to track the decision about what to save
    seprately to TIF_SVE we can improve things by leaving TIF_SVE enabled on
    syscall but only saving the FPSIMD registers if we are in a syscall.
    This means that if we need to restore the register state from memory
    (eg, after a context switch or kernel mode NEON) we will drop TIF_SVE
    and reenable traps for userspace but if we can just return to userspace
    then traps will remain disabled.
    
    Since our current implementation and hence ABI has the effect of zeroing
    all the SVE register state not shared with FPSIMD on syscall we replace
    the disabling of TIF_SVE with a flush of the non-shared register state,
    this means that there is still some overhead for syscalls when SVE is in
    use but it is very much reduced.
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20221115094640.112848-8-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
    8c845e27
syscall.c 5.82 KB