• Palmer Dabbelt's avatar
    Merge patch series "riscv: improve boot time isa extensions handling" · 9daca9a5
    Palmer Dabbelt authored
    Jisheng Zhang <jszhang@kernel.org> says:
    
    Generally, riscv ISA extensions are fixed for any specific hardware
    platform, so a hart's features won't change after booting, this
    chacteristic makes it straightforward to use a static branch to check
    a specific ISA extension is supported or not to optimize performance.
    
    However, some ISA extensions such as SVPBMT and ZICBOM are handled
    via. the alternative sequences.
    
    Basically, for ease of maintenance, we prefer to use static branches
    in C code, but recently, Samuel found that the static branch usage in
    cpu_relax() breaks building with CONFIG_CC_OPTIMIZE_FOR_SIZE[1]. As
    Samuel pointed out, "Having a static branch in cpu_relax() is
    problematic because that function is widely inlined, including in some
    quite complex functions like in the VDSO. A quick measurement shows
    this static branch is responsible by itself for around 40% of the jump
    table."
    
    Samuel's findings pointed out one of a few downsides of static branches
    usage in C code to handle ISA extensions detected at boot time:
    static branch's metadata in the __jump_table section, which is not
    discarded after ISA extensions are finalized, wastes some space.
    
    I want to try to solve the issue for all possible dynamic handling of
    ISA extensions at boot time. Inspired by Mark[2], this patch introduces
    riscv_has_extension_*() helpers, which work like static branches but
    are patched using alternatives, thus the metadata can be freed after
    patching.
    
    [1]https://lore.kernel.org/linux-riscv/20220922060958.44203-1-samuel@sholland.org/
    [2]https://lore.kernel.org/linux-arm-kernel/20220912162210.3626215-8-mark.rutland@arm.com/
    [3]https://lore.kernel.org/linux-riscv/20221130225614.1594256-1-heiko@sntech.de/
    
    * b4-shazam-merge:
      riscv: remove riscv_isa_ext_keys[] array and related usage
      riscv: KVM: Switch has_svinval() to riscv_has_extension_unlikely()
      riscv: cpu_relax: switch to riscv_has_extension_likely()
      riscv: alternative: patch alternatives in the vDSO
      riscv: switch to relative alternative entries
      riscv: module: Add ADD16 and SUB16 rela types
      riscv: module: move find_section to module.h
      riscv: fpu: switch has_fpu() to riscv_has_extension_likely()
      riscv: introduce riscv_has_extension_[un]likely()
      riscv: cpufeature: extend riscv_cpufeature_patch_func to all ISA extensions
      riscv: hwcap: make ISA extension ids can be used in asm
      riscv: cpufeature: detect RISCV_ALTERNATIVES_EARLY_BOOT earlier
      riscv: move riscv_noncoherent_supported() out of ZICBOM probe
    
    Link: https://lore.kernel.org/r/20230128172856.3814-1-jszhang@kernel.orgSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
    9daca9a5
errata_list.h 5 KB