mbox series

[v9,0/4] riscv: Use Kconfig to set unaligned access speed

Message ID 20240308-disable_misaligned_probe_config-v9-0-a388770ba0ce@rivosinc.com (mailing list archive)
Headers show
Series riscv: Use Kconfig to set unaligned access speed | expand

Message

Charlie Jenkins March 8, 2024, 6:25 p.m. UTC
If the hardware unaligned access speed is known at compile time, it is
possible to avoid running the unaligned access speed probe to speedup
boot-time.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
---
Changes in v9:
- Clarify wording for RISCV_MISALIGNED Kconfig option
- Link to v8: https://lore.kernel.org/r/20240307-disable_misaligned_probe_config-v8-0-55d696cb398b@rivosinc.com

Changes in v8:
- Minor commit message changes (Conor)
- Clean up hwprobe_misaligned() (Conor)
- Link to v7: https://lore.kernel.org/r/20240306-disable_misaligned_probe_config-v7-0-6c90419e7a96@rivosinc.com

Changes in v7:
- Fix check_unaligned_access_emulated_all_cpus to return false when any
  cpu has emulated accesses
- Fix wording in Kconfig (Conor)
- Link to v6: https://lore.kernel.org/r/20240301-disable_misaligned_probe_config-v6-0-612ebd69f430@rivosinc.com

Changes in v6:
- Consolidate Kconfig into 4 options (probe, emulated, slow,
  efficient)
- Change the behavior of "emulated" to allow hwprobe to return "slow" if
  unaligned accesses are not emulated by the kernel
- With this consolidation, check_unaligned_access_emulated is able to be
  moved back into the original file (traps_misaligned.c)
- Link to v5: https://lore.kernel.org/r/20240227-disable_misaligned_probe_config-v5-0-b6853846e27a@rivosinc.com

Changes in v5:
- Clarify Kconfig options from Conor's feedback
- Use "unaligned" instead of "misaligned" in introduced file/function.
  This is a bit hard to standardize because the riscv manual says
  "misaligned" but the existing Linux configs say "unaligned".
- Link to v4: https://lore.kernel.org/r/20240216-disable_misaligned_probe_config-v4-0-dc01e581c0ac@rivosinc.com

Changes in v4:
- Add additional Kconfig options for the other unaligned access speeds
- Link to v3: https://lore.kernel.org/r/20240202-disable_misaligned_probe_config-v3-0-c44f91f03bb6@rivosinc.com

Changes in v3:
- Revert change to csum (Eric)
- Change ifndefs for ifdefs (Eric)
- Change config in Makefile (Elliot/Eric)
- Link to v2: https://lore.kernel.org/r/20240201-disable_misaligned_probe_config-v2-0-77c368bed7b2@rivosinc.com

Changes in v2:
- Move around definitions to reduce ifdefs (Clément)
- Make RISCV_MISALIGNED depend on !HAVE_EFFICIENT_UNALIGNED_ACCESS
  (Clément)
- Link to v1: https://lore.kernel.org/r/20240131-disable_misaligned_probe_config-v1-0-98d155e9cda8@rivosinc.com

---
Charlie Jenkins (4):
      riscv: lib: Introduce has_fast_unaligned_access()
      riscv: Only check online cpus for emulated accesses
      riscv: Decouple emulated unaligned accesses from access speed
      riscv: Set unaligned access speed at compile time

 arch/riscv/Kconfig                         |  58 ++++--
 arch/riscv/include/asm/cpufeature.h        |  31 ++--
 arch/riscv/kernel/Makefile                 |   4 +-
 arch/riscv/kernel/cpufeature.c             | 255 --------------------------
 arch/riscv/kernel/sys_hwprobe.c            |  13 ++
 arch/riscv/kernel/traps_misaligned.c       |  17 +-
 arch/riscv/kernel/unaligned_access_speed.c | 282 +++++++++++++++++++++++++++++
 arch/riscv/lib/csum.c                      |   7 +-
 8 files changed, 374 insertions(+), 293 deletions(-)
---
base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
change-id: 20240131-disable_misaligned_probe_config-043aea375f93

Comments

Samuel Holland March 12, 2024, 2:31 a.m. UTC | #1
On 2024-03-08 12:25 PM, Charlie Jenkins wrote:
> If the hardware unaligned access speed is known at compile time, it is
> possible to avoid running the unaligned access speed probe to speedup
> boot-time.
> 
> Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> ---
> Changes in v9:
> - Clarify wording for RISCV_MISALIGNED Kconfig option
> - Link to v8: https://lore.kernel.org/r/20240307-disable_misaligned_probe_config-v8-0-55d696cb398b@rivosinc.com
> 
> Changes in v8:
> - Minor commit message changes (Conor)
> - Clean up hwprobe_misaligned() (Conor)
> - Link to v7: https://lore.kernel.org/r/20240306-disable_misaligned_probe_config-v7-0-6c90419e7a96@rivosinc.com
> 
> Changes in v7:
> - Fix check_unaligned_access_emulated_all_cpus to return false when any
>   cpu has emulated accesses
> - Fix wording in Kconfig (Conor)
> - Link to v6: https://lore.kernel.org/r/20240301-disable_misaligned_probe_config-v6-0-612ebd69f430@rivosinc.com
> 
> Changes in v6:
> - Consolidate Kconfig into 4 options (probe, emulated, slow,
>   efficient)
> - Change the behavior of "emulated" to allow hwprobe to return "slow" if
>   unaligned accesses are not emulated by the kernel
> - With this consolidation, check_unaligned_access_emulated is able to be
>   moved back into the original file (traps_misaligned.c)
> - Link to v5: https://lore.kernel.org/r/20240227-disable_misaligned_probe_config-v5-0-b6853846e27a@rivosinc.com
> 
> Changes in v5:
> - Clarify Kconfig options from Conor's feedback
> - Use "unaligned" instead of "misaligned" in introduced file/function.
>   This is a bit hard to standardize because the riscv manual says
>   "misaligned" but the existing Linux configs say "unaligned".
> - Link to v4: https://lore.kernel.org/r/20240216-disable_misaligned_probe_config-v4-0-dc01e581c0ac@rivosinc.com
> 
> Changes in v4:
> - Add additional Kconfig options for the other unaligned access speeds
> - Link to v3: https://lore.kernel.org/r/20240202-disable_misaligned_probe_config-v3-0-c44f91f03bb6@rivosinc.com
> 
> Changes in v3:
> - Revert change to csum (Eric)
> - Change ifndefs for ifdefs (Eric)
> - Change config in Makefile (Elliot/Eric)
> - Link to v2: https://lore.kernel.org/r/20240201-disable_misaligned_probe_config-v2-0-77c368bed7b2@rivosinc.com
> 
> Changes in v2:
> - Move around definitions to reduce ifdefs (Clément)
> - Make RISCV_MISALIGNED depend on !HAVE_EFFICIENT_UNALIGNED_ACCESS
>   (Clément)
> - Link to v1: https://lore.kernel.org/r/20240131-disable_misaligned_probe_config-v1-0-98d155e9cda8@rivosinc.com
> 
> ---
> Charlie Jenkins (4):
>       riscv: lib: Introduce has_fast_unaligned_access()
>       riscv: Only check online cpus for emulated accesses
>       riscv: Decouple emulated unaligned accesses from access speed
>       riscv: Set unaligned access speed at compile time
> 
>  arch/riscv/Kconfig                         |  58 ++++--
>  arch/riscv/include/asm/cpufeature.h        |  31 ++--
>  arch/riscv/kernel/Makefile                 |   4 +-
>  arch/riscv/kernel/cpufeature.c             | 255 --------------------------
>  arch/riscv/kernel/sys_hwprobe.c            |  13 ++
>  arch/riscv/kernel/traps_misaligned.c       |  17 +-
>  arch/riscv/kernel/unaligned_access_speed.c | 282 +++++++++++++++++++++++++++++
>  arch/riscv/lib/csum.c                      |   7 +-
>  8 files changed, 374 insertions(+), 293 deletions(-)

With the fix from [1] applied:

Tested-by: Samuel Holland <samuel.holland@sifive.com>

in all four configurations.

[1]: https://lore.kernel.org/linux-riscv/20240312022030.320789-1-samuel.holland@sifive.com/

> ---
> base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
> change-id: 20240131-disable_misaligned_probe_config-043aea375f93
patchwork-bot+linux-riscv@kernel.org March 14, 2024, 12:30 p.m. UTC | #2
Hello:

This series was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Fri, 08 Mar 2024 10:25:54 -0800 you wrote:
> If the hardware unaligned access speed is known at compile time, it is
> possible to avoid running the unaligned access speed probe to speedup
> boot-time.
> 
> Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> ---
> Changes in v9:
> - Clarify wording for RISCV_MISALIGNED Kconfig option
> - Link to v8: https://lore.kernel.org/r/20240307-disable_misaligned_probe_config-v8-0-55d696cb398b@rivosinc.com
> 
> [...]

Here is the summary with links:
  - [v9,1/4] riscv: lib: Introduce has_fast_unaligned_access()
    https://git.kernel.org/riscv/c/5a83e7313ee1
  - [v9,2/4] riscv: Only check online cpus for emulated accesses
    https://git.kernel.org/riscv/c/313130c62cf1
  - [v9,3/4] riscv: Decouple emulated unaligned accesses from access speed
    https://git.kernel.org/riscv/c/6e5ce7f2eae3
  - [v9,4/4] riscv: Set unaligned access speed at compile time
    https://git.kernel.org/riscv/c/f413aae96cda

You are awesome, thank you!