Skip to contentSkip to conversation

riscv: uaccess: Relax the threshold for fast path

PATCH Applied Xiao Wang 3 participants 3 messages Mar 13, 2024 – May 22, 2024 RISC-V

lore
Share & tools
lore

Xiao Wang

author
#0 lore raw

PATCH 1/1 riscv: uaccess: Relax the threshold for fast path

The bytes copy for unaligned head would cover at most SZREG-1 bytes, so it's better to set the threshold as >= (SZREG-1 + word_copy stride size) which equals to 9*SZREG-1.

---
 arch/riscv/lib/uaccess.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/lib/uaccess.S +1 -1
index bc22c078aba8..2e665f8f8fcc 100644
@@ -44,7 +44,7 @@ SYM_FUNC_START(fallback_scalar_usercopy)
 	 * Use byte copy only if too small.
 	 * SZREG holds 4 for RV32 and 8 for RV64
 	 */
-	li	a3, 9*SZREG /* size must be larger than size in word_copy */
+	li	a3, 9*SZREG-1 /* size must >= (word_copy stride + SZREG-1) */
 	bltu	a2, a3, .Lbyte_copy_tail
 
 	/*
Signature · 1 line
2.25.1
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi Xiao,

Quoted 14 lines · Xiao Wang

The bytes copy for unaligned head would cover at most SZREG-1 bytes, so it's better to set the threshold as >= (SZREG-1 + word_copy stride size) which equals to 9*SZREG-1.

---
  arch/riscv/lib/uaccess.S | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/lib/uaccess.S +0 -0
index bc22c078aba8..2e665f8f8fcc 100644

arch/riscv/lib/uaccess.S SYM_FUNC_START(fallback_scalar_usercopy) · line 50

Quoted 8 lines
arch/riscv/lib/uaccess.S +1 -1
@@ -44,7 +44,7 @@ SYM_FUNC_START(fallback_scalar_usercopy)
  	 * Use byte copy only if too small.
  	 * SZREG holds 4 for RV32 and 8 for RV64
  	 */
-	li	a3, 9*SZREG /* size must be larger than size in word_copy */
+	li	a3, 9*SZREG-1 /* size must >= (word_copy stride + SZREG-1) */
  	bltu	a2, a3, .Lbyte_copy_tail
 
  	/*

This looks good to me:

Thanks,

Alex

#2 lore raw
In reply to Xiao Wang
This patch was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:

Quoted 8 lines · On Wed, 13 Mar 2024 17:19:29 +0800 you wrote:

The bytes copy for unaligned head would cover at most SZREG-1 bytes, so it's better to set the threshold as >= (SZREG-1 + word_copy stride size) which equals to 9*SZREG-1.

---
 arch/riscv/lib/uaccess.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- riscv: uaccess: Relax the threshold for fast path

    https://git.kernel.org/riscv/c/e8c7995ea148

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html